Jump to content
Sign in to follow this  
microtronx

TIP for Creating PDF Files from HTML / Image

Recommended Posts

Hi folks,

 

after searching a lot for different possibilities, Alexander remembered me that we can use his components (https://delphihtmlcomponents.com/) to create very simply pdf files on the fly.

If you search for a component to create PDF files without much code from HTML (incl. using images files) use this code:

thtdocument.HTMLtoPDFFile(ahtmlstring:string; aPDFfile:string);

Thanks to @Alexander Sviridenkov for his wonderfull components.

 

  • Like 2

Share this post


Link to post
43 minutes ago, Der schöne Günther said:

WebView2 (used by TEdgeBrowser) can directly print to PDF, just saying.

Yes, but with thtdocument you do not have any dependencies to other libs/dll's ...

Share this post


Link to post
On 5/10/2022 at 8:49 AM, Der schöne Günther said:

WebView2 (used by TEdgeBrowser) can directly print to PDF, just saying.

Browsers do not support page headers and footers, different page sizes/orientation, printing page number and count of pages, repeated table headers, etc.

  • Thanks 1

Share this post


Link to post

Not sure where you got that from, browsers can do that perfectly fine.

 

Here is an example with TEdgeBrowser and no additional libraries in Delphi:

 

image.thumb.png.5d9ad2ba76a6c7866ce16fc1c626a305.png

 

Printed, for example, in landscape orientation:

image.thumb.png.f848b854ec4356e4904fef307ea24110.png

Share this post


Link to post

Thanks, I didn't know Edge supports header/footer customization. Are header/footer embedded into page or passed separately? Does it support different headers/footers for different pages?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×