简体   繁体   中英

  Not working while generating PDF from HTML Using itextSharp dll

I am trying to generate a PDF file from Html string. I have used   for putting space between words, but it is not working in itextsharp. In pdf it is printed as word not putting space between words. As shown in below image.

在此处输入图片说明

I dont know about iTextSharp specifically, but a next version of the library from creators of iTextSharp does HTML to PDF conversion correctly. It is called iText7 (Incompatible with previous iTextSharp); here is HTML to PDF package: https://www.nuget.org/packages/itext7.pdfhtml/

Usage:

HtmlConverter.ConvertToPdf(
    new FileInfo(@"Path\to\Html\File.html"),
    new FileInfo(@"Path\to\Pdf\File.pdf")
);

(method has many other overloads too).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM