You are not logged in.
Pages: 1
Hello,
so far the project looks pretty awesome.
Thank you for the effort you have spent developing the whole synopse project.
I've been using the htm2pdf unit to convert a newsletter from html to pdf.
I have added the event to fetch images from the server and everything seems fine.
The only thing I can't get to work are hyperlinks.
Does the converter support hyperlinks?
Or do I have to manually use the PDF-Class(es) from the synopse framework
to create pages and hyperlinks from hand?
I have looked into the source code, but to be honest,
it is a little bit too complicated for me...
Thank you for your help in advance
Matthew
Offline
The PDF engine is able to recognize EMR_GDICOMMENT blocks inside the TMetaFile content, to embedd some SynPDF related data (like bookmarks, links, and document outline) in the source TMetaFile.
This feature is used e.g. by TSQLite3Pages.
You can use the following methods:
/// append a EMR_GDICOMMENT message for handling PDF bookmarks
// - will create a PDF destination at the current position (i.e. the last Y
// parameter of a Move), with some text supplied as bookmark name
procedure GDICommentBookmark(MetaHandle: HDC; const aBookmarkName: RawUTF8);
/// append a EMR_GDICOMMENT message for handling PDF outline
// - used to add an outline at the current position (i.e. the last Y parameter of
// a Move): the text is the associated title, UTF-8 encoded and the outline tree
// is created from the specified numerical level (0=root)
procedure GDICommentOutline(MetaHandle: HDC; const aTitle: RawUTF8; aLevel: Integer);
/// append a EMR_GDICOMMENT message for creating a Link into a specified bookmark
procedure GDICommentLink(MetaHandle: HDC; const aBookmarkName: RawUTF8; const aRect: TRect);
This should be done at rendering time, when the content is written from the THTmlView into the internal TMetaFile canvas.
Online
Thanks for your help.
But I still dont understand how those two Classes can be combined.
I have absolutely no idea where I have to insert the code.
Here is my code:
With THtml2Pdf.Create do
begin
DefaultPaperSize := psA4;
CompressionMethod := cmFlateDecode;
ForceJPEGCompression := StrToInt(CompressionRate.Text);
Viewer := Thtmlviewer.Create(self);
Viewer.Parent := Self;
Viewer.Visible := False;
Viewer.OnImageRequest := HTMLViewerImageRequest; // Assign event to get images from server
Viewer.LoadFromFile(IncludeTrailingPathDelimiter(TempPath.Text) + NewsletterNameFile + '.html');
Execute;
SaveToFile(IncludeTrailingPathDelimiter(PDFPath.Text) + NewsletterNameFile + '.pdf');
Free;
end;
Where do I need to intercept?
How do I get the metahandle...
There seems to be no way to get specific text in the pdf.
Maybe I am doing something wrong.
Thanks in advance for your help.
Last edited by Preddy2012 (2012-03-29 10:50:49)
Offline
You'll have to change the THtmlView classes rendering, and add the expected comments within the TMetaFile canvas, during the rendering itself.
This is something to do on the THtmlView side, not on the SynPdf side, which does not need to be modified.
SynPdf does not know what is a link in the supplied page content, and where it points to (only exception is http links).
Online
hi
i am trying to use comments.. and i changed thtmlviewe render to CreateWithComment and it does that ok, but do i need to add something on synopse side to make it visible?
Offline
I do not think so.
But I'm not sure.
well, it is not visible in newly created PDF file, and if you dont know, who does? ;-)
Offline
What did you include?
Links? Outlines? BookMarks?We used and tested outline and bookmark without any problem.
What is not "visible" in your end pdf?
i think we misunderstood, i just added TMetaFileCanvas.CreateWithComment in htmlviewer part, and that should appear like bookmark or i understood wrong?
Offline
Pages: 1