我使用aspose.html想将一些html网页转换为pdf,这个html里面有一些网络加载的js和css文件,当我用官方文档的例子转换后,发现效果和原来的网页完全不一样,html里面的内容基本都丢失了。
这是我用来转换的文件附件,里面有html,你们可以帮忙转换一下看看吗?是我的代码部分有什么错误吗?感谢你们。
11个html页面.zip (1.2 MB)
转换代码:
Aspose.Html.Configuration TempConfig= new Aspose.Html.Configuration();
Aspose.Html.Rendering.Pdf.PdfRenderingOptions TempPdfRenderOption = new Aspose.Html.Rendering.Pdf.PdfRenderingOptions();
TempPdfRenderOption.Css.MediaType = Aspose.Html.Rendering.MediaType.Screen;
TempPdfRenderOption.PageSetup.AdjustToWidestPage = true;
//using (Aspose.Html.HTMLDocument TempDocument = new Aspose.Html.HTMLDocument(DocumentFileName))
//{
// using Aspose.Html.Rendering.Pdf.PdfDevice TempPdfDevice = new Aspose.Html.Rendering.Pdf.PdfDevice(TempPdfRenderOption, SavedFileName);
// TempDocument.RenderTo(TempPdfDevice);
//};
INetworkService networkService = TempConfig.GetService<INetworkService>();
networkService.MessageHandlers.Insert(0, new TimeoutMessageHandler());
Aspose.Html.Saving.PdfSaveOptions TempOption = new Aspose.Html.Saving.PdfSaveOptions()
{
JpegQuality = 100,
};
TempOption.PageSetup.AdjustToWidestPage = true;
Aspose.Html.Converters.Converter.ConvertHTML(DocumentFileName, TempConfig, TempOption, SavedFileName);