使用Itext 7将HTML转换为PDF时如何显示页码

时间:2018-11-20 05:27:15

标签: itext7 html-to-pdf page-numbering

我正在尝试下面的代码,但未得到结果,这会干扰现有功能,因此请与我分享相同的指导原则。

// Generate PDF file name with full path

string lsPDFFileFullPath = fsFileDestination + fsDestinationFileName;

ConverterProperties loproperties = new ConverterProperties();
loproperties.SetFontProvider(new DefaultFontProvider(true, true, true));
MediaDeviceDescription mediaDeviceDescription = new MediaDeviceDescription(MediaType.SCREEN);
loproperties.SetMediaDeviceDescription(mediaDeviceDescription);

// Set BaseUri for access css and images for PDF.
loproperties.SetBaseUri(fsWebRootPath);

if (!System.IO.Directory.Exists(fsFileDestination))
{
    System.IO.Directory.CreateDirectory(fsFileDestination);
}


var loElements = HtmlConverter.ConvertToElements(fsSourceHTML, loproperties);
PdfDocument loPDFDoc = new PdfDocument(new PdfWriter(lsPDFFileFullPath));
loPDFDoc.SetTagged();


Document loDocument = new Document(loPDFDoc);
loDocument.SetMargins(20, 20, 20, 20);
foreach (var loElement in loElements)
{
    loDocument.Add((IBlockElement)loElement);
}

loDocument.Close();

0 个答案:

没有答案