You are not logged in.
Pages: 1
While the issue is solved, I have some suggestions for future versions:
- to add explanations that sizes are measured in points, and coordinates are measured from the bottom left corner
- an option to suppress a black border for links
- ability to add links to external URLs and files; yes, URLs are auto-detected, but a visible text and a link target are not necessary identical.
By the way, I created a demo for making PDF files from RTF and RVF files using Synopse PDF Engine and our components:
http://www.trichview.com/forums/viewtopic.php?p=30151
You are right, thank you!
Y positions for CreateBookmark and CreateLink are counted from the page bottom
Well, probably I need to provide mode information.
Here is the example, I want to make a hyperlink around "Prep" text.
Content is made by drawing on VCLCanvas. The origin of coordinates is moved to the point marked with a green circle (using SetWindowOrgEx).
In the code below, I draw a red rectangle around the link area, and create the link.
Input:
R - link rectangle, in pixels, relative to the origin.
DocRect - rectangle of document inside the margin
// drawing a red rectangle
FPdfDoc.VCLCanvas.Brush.Style := bsClear;
FPdfDoc.VCLCanvas.Pen.Width := 1;
FPdfDoc.VCLCanvas.Pen.Style := psSolid;
FPdfDoc.VCLCanvas.Pen.Color := clRed;
FPdfDoc.VCLCanvas.Rectangle(R.Left, R.Top, R.Right, R.Bottom);
// adding a link
OffsetRect(R, DocRect.Left, DocRect.Top);
dpi := Screen.PixelsPerInch;
PdfRect.Left := R.Left * 72 / dpi;
PdfRect.Top := R.Top * 72 / dpi;
PdfRect.Right := R.Right * 72 / dpi;
PdfRect.Bottom := R.Bottom * 72 / dpi;
FPdfDoc.CreateLink(PdfRect, StringToUTF8(Copy(Target, 2, MaxInt)));
The result is below:
Everything is correct except for Y coordinates. You can see that the link is shifted down a lot.
Well, it should be 72, not 75.
With 72 dpi, scale and X coordinates are correct, however, the rectangle is shifted by Y, and may be shifted by a huge distance.
I assign FPdfDoc.DefaultPaperSize (FPdfDoc is TPdfDocumentGDI)
Additionally, I assign FPdfDoc.ScreenLogPixels (currently to Screen.PixelsPerInch, but in future it may be another value).
Then call FPdfDoc.AddPage.
Then I draw onto FPdfDoc.VCLCanvas using pixel coordinates.
I have pixels positions of bookmarks and links (relative to the top of the page), how to convert them to coordinates for CreateLink and CreateBookmark?
I tried Value * 75 / 96, the results are close, but not exactly correct:
I am trying to implement PDF export for our TRichView editor using SynPDF.
Everything is ok, except for links.
I do not understand which coordinates should I pass to CreateLink.
I assumed that pixels, but I am obviously wrong.
For example, for a test, I am trying to put a hyperlink around the whole page inside margins ((76, 76, 718, 1047) at 96 dpi).
The result is completely out of place and has wrong size:
Can you help me?
Pages: 1