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!
Search a PDF and add links to text strings |
Post Reply |
Author | |
jjohnston
Beginner Joined: 17 Dec 05 Status: Offline Points: 18 |
Post Options
Thanks(0)
Posted: 25 Jun 07 at 11:52AM |
Is there an easy way search a PDF for a specific text string and link it to a URL then save out the new PDF?
For example. Say I want to search a PDF for the word "Yahoo" and I want to modify it so that the word "Yahoo" is linked to http://www.yahoo.com. Any help greatly appreciated... Edited by jjohnston - 25 Jun 07 at 11:58AM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
Searching the text isn't a problem. Linking textstrings with urls isn't difficult, too. Doing both together in an existing pdf-document is nearly unbeleavable. Have a look in pdf-structures then you know what i mean. Welcome here and best regards, Ingo |
|
jjohnston
Beginner Joined: 17 Dec 05 Status: Offline Points: 18 |
Post Options
Thanks(0)
|
How would you link a text string? If I can write a new string to the page over the old one in another layer that would work right? Or maybe a transparent link over the top of the text I want to link? GetPageText returns the coordinates. I just need to know the function for linking that region of the page to a specific URL. :) Thanks for the quick reply. -jjohnston Edited by jjohnston - 25 Jun 07 at 7:44PM |
|
jjohnston
Beginner Joined: 17 Dec 05 Status: Offline Points: 18 |
Post Options
Thanks(0)
|
I was hoping for something more elegant but this is what I've come up with.
If anyone else has any ideas for improving this I'd love to hear them. :) -------------------------------------- Private Function AddLinks(lPage As Long, sSearchText As String, sLink As String) Dim lTmp As Long Dim aWords() As String, aParams() As String Dim dLeft As Double, dTop As Double, dWidth As Double, dHeight As Double If m_pdf.SelectedPage <> lPage Then m_pdf.SelectPage lPage End If aWords = Split(m_pdf.GetPageText(3), vbCrLf) For lTmp = 0 To UBound(aWords) DoEvents If InStr(1, aWords(lTmp), sSearchText, vbTextCompare) Then Debug.Print Mid$(aWords(lTmp), InStr(1, aWords(lTmp), "#")) aParams = Split(Mid$(aWords(lTmp), InStr(1, aWords(lTmp), "#")), ",") dLeft = CDbl(aParams(2)) dTop = CDbl(aParams(3)) + CDbl(aParams(1)) dWidth = CDbl(aParams(4)) - CDbl(aParams(2)) dHeight = CDbl(aParams(7)) - CDbl(aParams(3)) sLink = sLink Debug.Print dLeft, dTop, dWidth, dHeight, sLink m_pdf.AddLinkToWeb dLeft, dTop, dWidth, dHeight, sLink, 0 End If Next End Function ------------------------------------------ I just loop through the each page with each phrase I want to link and call this function. If you have a big list of phrases/links and the PDF has alot of pages it can take a good while but it does work. When I'm done I just call "m_pdf.SaveToFile" to save it to a new file. -jjohnston Edited by jjohnston - 26 Jun 07 at 12:21AM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
Yes... Your solution will works. I had understand that you want to dig directly into the code to change or implement these things... and this won't work. The functions you're asking for are: AddLinkToFile AddLinkToPage AddLinkToWeb ...the first functions described in the documentation on page 3...4 ;-) Best regards, 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