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.
|