Page 1 of 1

URL in pdf

Posted: Mon Mar 24, 2008 5:56 am
by jrademan
Hi,

How do I insert text into pdf and it displays 'abc' but it is an url to a website without displaying the url info in the PDF.

thanks

Johan

Posted: Mon Mar 24, 2008 8:44 am
by Lzcat - Tracker Supp
The Common way to do this - place your text 'abc' and add link annotation to the corresponding rect.

If you creating new pdf file using pxclib30.dll (pxclib40.dll) you should use PXC_AddLink function. Or, if pdf file is alredy created you should use the PXCp_AddLink function from xcpro35.dll (xcpro40.dll when V4 is released later this week).

In both cases you need to specify the rect on the page and the URL string.

See the corresponding help file for more details.

Posted: Tue Mar 25, 2008 8:32 am
by johanr
Hi Victor

I am currently using TextOut to place the text and then would like to straight after that add the link for that piece of text.

Are there any examples that could provide same sample code?

I have been through some of the examples but am struggling to find one.

thanks

Johan

Posted: Tue Mar 25, 2008 5:00 pm
by John - Tracker Supp
Hi Johan,

best you place your messages in the Clarion forum - then you will get a Clarion developer to answer you - rather than our C++/VB/C#/DOTNET generic dev's trying to answer.

Craig will respond as soon as possible.

Posted: Tue Mar 25, 2008 11:22 pm
by Tracker - Clarion Support
Hi Johan!

John asked me to look at your problem.

First, you can only add text to a NEW PDF, not one that you have already created. This is because the PDF Specification, to which our software adheres, differentiates between "Content" - text and images - which should never change once created, and a variety of "Annotations" which may be added, changed or deleted after PDF creation. There are also "Fields" which are a feature of the Acrobat Forms (or "AcroForms") capability which may contain default text that may be changed by the user using a Viewer capable of that.

Links are considered to be Annotations and are NOT tied to any text but to an area of the PDF page. If that area happens to surround a word or words, then clicking on the word will be inside the active area of the link ("hotspot") and the link will be activated.

One thing you might try is to look at the C++ example that you can find in the PDF-XChange PRO 3.5 Library Help for function PXCp_ET_AnalyzePageContent by clicking the 4th button on the help page toolbar (mostly blue and tooltipped as "Usage examples (1)". That shows how to extract ALL the text from an existing PDF and copy it to a new PDF retaining the font formatting. You could insert code to search for your "keywords" in each text element (line) and then replace them where they appear. You would have to fix up the PXP_TextElement contents to reflect the changes. Notice that the PXP_TextElement character array information includes the baseline and offset information for each word in the line so you could save that to build a Link around the word(s) as necessary. Not simple but it would work.

Alternatively, you could create an opaque foreground Text Watermark to overlay over the existing PDF text which would hide it with the new text. You'd know the height and width of the watermark, and could calculate the starting position by analyzing the text as indicated above. Note that this is simple but relies on you leaving enough space in the original PDF for the watermark to fit while not covering the words on either side.

Posted: Wed Mar 26, 2008 6:55 pm
by johanr
Hi Craig

Thanks.

I found the AddLink function in the CW source files.

Can I call this directly after TextOut, to set up the url area for the newly created text string?
Where do I get more info on the parameters?
and what are the units for top,left,right,bottom?
Or even better is there a clarion example perhaps that might be doing something similiar?

I have a PDF template file and I am creating a new file with the data, and then overlaying to create one file.

thanks,

Johan

Posted: Wed Mar 26, 2008 11:54 pm
by Tracker - Clarion Support
Hi Johan!

You should be able to call AddLink after TextOut.

Measurements are always in points, i.e. 1/72 inch. Also, the vertical Y position is measured from the BOTTOM edge of the PDF page.

The PDF Overlay idea is a good one.

Posted: Thu Mar 27, 2008 8:19 am
by johanr
Hi Craig

Thanks for the info, that helps a lot, will let you know if I have further problems.

Do you have more info on the parametrs from piOpacity onwords?
Or if you can point me to the docs for this?

PDFManagerClass.AddLink
PROCEDURE(
LONG pPageNo,
STRING szURL,
REAL pLeft,
REAL pTop,
REAL pRight,
REAL pBottom,
LONG piOpacity, ??
COLORREF piColor, ??
LONG piFlags, ??
LONG pbWidth, ??
LONG pbType, ??
LONG pbDashCount, ??
LONG pbDashArray ??


My problem with search and replace is on hold and I will look into at a later stage, it is not crucial for the first version.
If there is something in newer releases that can help please let me know.

TIA

Johan

Posted: Thu Mar 27, 2008 1:18 pm
by Tracker - Clarion Support
Hi Johan!

The parameters for the AddLink method are a "flattened" version of the PXCp_AddLink parameters including the PXC_CommonAnnotInfo and PXC_AnnotBorder structures. Please check PDFLib30Help.chm for those topics for more detailed information.

Some suggested values to help you get going:

LONG piOpacity, 0=transparent to 255=opaque: 255
COLORREF piColor, Any of the standard Clarion COLOR: equates such as COLOR:Blue
LONG piFlags, AF_Print
LONG pbWidth, Width of the border in points: 2
LONG pbType, Try ABS_Underline, or ABS_Solid if the first doesn't work.
LONG pbDashCount, set to zero.
LONG pbDashArray, set to zero

The parameters for the AddLink method are a "flattened" version of the PXCp_AddLink parameters including the PXC_CommonAnnotInfo and PXC_AnnotBorder structures. Please check PDFLib30Help.chm for those topics for more detailed information.