#1 2013-03-30 15:56:05

randydom
Member
Registered: 2011-05-11
Posts: 5

Convert Html File into PDF

Hello i've an Html File with some tables on it .
please how can i convert this html file into a PDF file using  SynPdf library .

this's what i want as a pseudo code :

Procedure ConvertHtmlToPdf(AsourceHtMLFile,ATargetPDFFile:String);
var 
lPdf   : TPdfDocument;
lPage  : TPdfPage;

begin
     lPdf := TPdfDocument.Create;
     try
     lPdf.LoadFromFile(AsourceHtMLFile);//<--- this procedure doesn't exist just to show you what i want
     //**
     //**
    lPdf.SaveToFile(ATargetPDFFile);

  finally
        lPdf.Free;
        end;
end;

and here's an Html file sample :
http://img17.imageshack.us/img17/8859/htmlsample.png

htmlsample.png

Please is This possible ?.

many thanks , Randy

Offline

#2 2013-03-31 08:51:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Convert Html File into PDF

The SynPDF library does not have any HTML renderer built-in.

You have to use an HTML renderer, able to convert the HTML content into metafile content.

We have tested it with THtmlViewer, and it works very well.
See http://blog.synopse.info/post/2010/07/1 … -free-tool
But we tested it with Delphi < 2009, i.e. non Unicode Delphi: this THtmlViewer component was not compatible with Unicode at this time.
The SynPDF library is perfectly Unicode ready, on its side.

Offline

#3 2013-03-31 10:36:09

ebz
Member
Registered: 2011-07-20
Posts: 18

Re: Convert Html File into PDF

Hi ab, the latest version THtmlViewer (version 11) already support unicode, using TntUnicodeControls and also support WideStrings
maybe you could update htm2pdf-free. It'll be useful tools
https://code.google.com/p/thtmlviewer/

Last edited by ebz (2013-03-31 10:37:04)

Offline

#4 2013-03-31 11:38:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Convert Html File into PDF

So you can for sure use THtmlViewer to render the content and export it as PDF.

You just need to adapt the code supplied in http://blog.synopse.info/post/2010/07/1 … -free-tool

Offline

Board footer

Powered by FluxBB