-1

I want to convert a static html file to pdf file with the styles as it is. I have only a few fields in html , Like text,select,textarea,button,label ( but all contains inline styles) I have checked itextsharp, which is converting to pdf with no styles.

Can I generate the pdf as I see the html file in browser

I am using c# win-form application to do that.

4

3 回答 3

1

Generating pdf from html page using http://www.html-to-pdf.net/ First download dll from site and refer it in ur code...i have written rest of the code below, have a look.

 PdfConverter pdfConverter = new PdfConverter();
            //pdfConverter.LicenseKey = "put your license key here";

            pdfConverter.PdfDocumentOptions.EmbedFonts = false;
            pdfConverter.PdfDocumentOptions.ShowFooter = false;
            pdfConverter.PdfDocumentOptions.ShowHeader = false;
            pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;
            pdfConverter.ActiveXEnabled = true;
            pdfConverter.AvoidImageBreak = true;
            pdfConverter.NavigationTimeout = 2147483647;

            pdfConverter.ScriptsEnabled = true;
            pdfConverter.PdfDocumentOptions.AutoSizePdfPage = true;
            pdfConverter.SavePdfFromUrlToFile(html file path, output file path filepath);
于 2012-09-19T13:03:53.707 回答
0

I use WKHtmlToPdf a shell utility which is based on the standard WebKit engine. Give it a try.

于 2012-09-19T13:14:35.483 回答
0

Amyuni WebkitPDF is a free library that can be used for HTML to PDF conversion. It comes with sample code in C# and C++ and a sample desktop application that you can use for evaluating the results.

usual disclaimer applies

于 2012-09-20T13:15:48.343 回答