Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Add Link To Embedded File |
Post Reply ![]() |
Author | ||
syntax3k ![]() Beginner ![]() Joined: 29 Apr 10 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 29 Apr 10 at 8:17AM |
|
Hi,
I am new to Quick ODF and currently evaluating it. This is the last bit that I need to do, and it looks like I hit a roadblock. Situation is this: the pdf is created. There is a certain text in the pdf, and also, there is a st of files. What I need to do is; 1. embed the files 2. find the certain text, create a hotspot to link to the embedded file The embedding is smooth; however, the AddLinkToEmbeddedFile function always returns zero. I am not sure what I am doing wrong, I hope that someone can help me here, so I can finish this and go and purchase this library. Here is the part of the code. qp.LoadFromFile(destinationFile); foreach (KeyValuePair<int, string> file in sourceFiles) { string textToSearch = "Open " + file.Key; int pageCount = qp.PageCount(); int pageNumber = 1; int matchesFound = 0; bool fileLinked = false; int fileId = 0; while (pageNumber <= pageCount) { qp.SelectPage(pageNumber); string pageText = qp.GetPageText(3); string[] lines = pageText.Split('\n'); string[][] grid = new string[pageText.Length][]; for (int i = 0; i < lines.Length; i++) { grid = lines.Split(','); } foreach (string[] line in grid) { if (line == null || line.Length < 12) continue; string findMatch = line[11]; if (findMatch.Contains(textToSearch)) { string title = file.Key.ToString() + ".pdf"; if (!fileLinked) { fileId = qp.EmbedFile(title, file.Value, "application / pdf"); fileLinked = true; } qp.DrawBox(Convert.ToDouble(line[3]), Convert.ToDouble(line[8]), 100, 20, 0); int result = qp.AddLinkToEmbeddedFile(Convert.ToDouble(line[3]), Convert.ToDouble(line[8]), 100, 20, fileId, title, 1); } } pageNumber++; } } qp.SaveToFile(destinationFile); Everything works just fine, even the box is drawn (I put there to test), however the result variable is always zero (0), suggesting that the link is not added. And fair enough, after everything is done, I open the Pdf file and attachments are embedded, the box is drawn but the link is not created. Is there something that I am doing wrong? I even tried to save the document right after embedding but that did not make a difference. Also, the fileId is always 1. Does that mean it is returning a success code instead of the EmbeddedFileID? If so, how can I get the embedded File ID frmthat function? Any help would be appreciated. |
||
![]() |
||
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
|
Hi Syntax ;-)
EmbedFile is an old (the wrong one) function if you want to get a file-id. Try AddEmbeddedFile: http://www.quickpdflibrary.com/help/quickpdf/AddEmbeddedFile.php Cheers and welcome here, Ingo |
||
![]() |
||
syntax3k ![]() Beginner ![]() Joined: 29 Apr 10 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
|
Hi Ingo,
Thank you so much. Worked like a charm. For those, who would need this functionality, here is the revised code: replace this code:
with this:
If QuickPDF guys are reading these forums, may I also suggest using the [Obsolete] tag on the EmbedFile function? I think it would help greatly. Once again, thank you Ingo.
|
||
![]() |
||
syntax3k ![]() Beginner ![]() Joined: 29 Apr 10 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
|
I do have another question Ingo (if you don't mind):
I added the link box after adding a new layer, as I found out that, if I do not do that, the link does not go over the "Open xxx" text at all. But even though my box's wodth is set to be 300, it still does not cover the whole "Open xxx" text for some reason. Since the link creating code is the same as above, is that not the right way to do so? And also (ok, second question), the link always have an icon. Is it possible to not have an icon, or at least have a custom one? Thank you once again for all your help.
|
||
![]() |
||
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
|
Hi!
'cause of your box: Perhaps it has to do with different value bases (pixels, mm, inches)? ...Perhaps with different orientations? Perhaps for the box you can only use pixel and for the rest you've made settings for inches? You should have a look in this direction. If you read here: http://www.quickpdflibrary.com/help/quickpdf/AddLinkToEmbeddedFile.php You see that there's the standard icon (0) or the disk icon (1). Perhaps you can try "2"? ...Try it. Cheers, Ingo |
||
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store