Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 使用itextsharp在pdf中包含CSS文件_Vb.net_Itextsharp - Fatal编程技术网

Vb.net 使用itextsharp在pdf中包含CSS文件

Vb.net 使用itextsharp在pdf中包含CSS文件,vb.net,itextsharp,Vb.net,Itextsharp,我正在使用iTextSharp制作pdf文件 但是,在源HTML中链接的外部CSS不会显示在PDF中 如何包含外部css文件以便iTextSharp正确渲染 Dim doc As Document = New Document PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + _ "\ListingDetai

我正在使用iTextSharp制作pdf文件

但是,在源HTML中链接的外部CSS不会显示在PDF中

如何包含外部css文件以便iTextSharp正确渲染

Dim doc As Document = New Document 
PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + _ 
                                          "\ListingDetails.pdf", FileMode.Create)) 

Dim content As String = File.ReadAllText(Server.MapPath("~/PDFPage.aspx")) 

doc.Open() 

Dim parsedHtmlElements = HTMLWorker.ParseToList(New StringReader(content), Nothing) 

For Each htmlElement As Object In parsedHtmlElements 
   doc.Add(TryCast(htmlElement, IElement)) 
Next 

doc.Close()

你为什么要这么做?PDF文件不会在内部使用CSS,因此将其包含在PDF中不会起任何作用。当我将html转换为PDF时,设计没有达到应有的效果。那么我如何应用css呢?这就是代码比描述更能说明问题的地方。发布您当前的转换代码,以便了解itextsharp的人可以看到您正在做什么以及可以用它做什么。让你的描述更清晰也有助于理解。我对你的问题进行了编辑以使其更清晰。如果我错了,请改正。请添加您当前的代码。