Я использую библиотеку expertpdf для преобразования html-страницы в pdf, и функция выдает ошибку «Тайм-аут навигации WebKit».
public void ConvertHTMLStringToPDF(string compHTML)
{
var isIE8 = Request.Browser.Browser == "IE" && Request.Browser.MajorVersion <= 8;
string htmlString = compHTML.Replace("valuesss", "value").Replace("scheckedss", "checked")
.Replace("<link href='includes/Print.css' />", "<style>\n" +
System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("includes/Print.css")).Replace("../images/", "images/") + "</style>");
//Create the PDF converter. Optionally you can specify the virtual browser
//width as parameter. 1024 pixels is default, 0 means auto detect
string baseURL = this.Request.Url.ToString();
var pdfConverter = new PdfConverter(0);
//pdfConverter.DrawBackColors = true;
pdfConverter.DrawBackground = true;
pdfConverter.PdfDocumentOptions.EmbedFonts = true;
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
pdfConverter.LicenseKey = "78Tdz9fP3d/cz9bB38/c3sHe3cHW1tbW";
// set the converter options
pdfConverter.PdfDocumentOptions.AutoSizePdfPage = true;
pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
pdfConverter.PdfDocumentOptions.TopMargin = 10;
pdfConverter.PdfDocumentOptions.BottomMargin = 1;
pdfConverter.PdfDocumentOptions.LeftMargin = 1;
pdfConverter.PdfDocumentOptions.RightMargin = 1;
pdfConverter.PdfDocumentOptions.SinglePage = SinglePagePDF;
pdfConverter.AvoidTextBreak = true;
pdfConverter.AvoidImageBreak = true;
if (PrintinLandScape)
{
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Landscape;
}
else
{
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
}
//pdfConverter.PdfDocumentOptions.EmbedFonts = true;
pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = false;
pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = false;
//FOOTER OPTIONS
pdfConverter.PdfDocumentOptions.ShowFooter = true;
pdfConverter.PdfFooterOptions.FooterHeight = 10;
pdfConverter.PdfFooterOptions.FooterTextColor = Color.Black;
pdfConverter.PdfFooterOptions.FooterTextFontType = PdfFontType.HelveticaOblique;
pdfConverter.PdfFooterOptions.FooterTextFontSize = 6;
pdfConverter.PdfFooterOptions.DrawFooterLine = true;
pdfConverter.PdfFooterOptions.PageNumberText = "Page";
pdfConverter.PdfFooterOptions.PageNumberTextColor = Color.Black;
pdfConverter.PdfFooterOptions.PageNumberTextFontType = PdfFontType.HelveticaBold;
pdfConverter.PdfFooterOptions.PageNumberTextFontSize = 6;
pdfConverter.PdfFooterOptions.PageNumberYLocation = (float)2.0;
pdfConverter.PdfFooterOptions.ShowPageNumber = true;
pdfConverter.ImgTransparency = 0;
//System.IO.File.WriteAllText(Server.MapPath("abc.html"), htmlString);
var objpdf = pdfConverter.GetPdfDocumentObjectFromHtmlString(htmlString, baseURL);
SavePrintHtmlOnFile(htmlString); //save print html string in print.html file
var attach = "inline";
var content = "application/pdf";
var filename = GetDownloadFileName + DateTime.Now.Ticks + ".pdf";
var fpath = SessionFolder + "\\" + filename;
if (RenderIn == RenderMode.PRINTPDF)
{
objpdf.OpenAction.Action = new ExpertPdf.HtmlToPdf.PdfDocument.PdfActionJavaScript("this.print({bShrinkToFit: true});");
Response.AddHeader("Content-Disposition", "inline; filename=" + pdfPageName);
}
else
{
if (isIE8)
{
attach = "attachment";
ScriptManager.RegisterStartupScript(this, this.GetType(), "asdfw3safsd", "window.location.href=('Download.aspx?name=" + (Server.UrlEncode(GetDownloadFileName + ".pdf")) + "&file=" + Server.UrlEncode("sessionfolders/" + Session.SessionID + "/" + filename) + "&content=" + Server.UrlEncode(content) + "');", true);
}
else
{
attach = "attachment";
ScriptManager.RegisterStartupScript(this, this.GetType(), "asdfw3safsd", "window.open('Download.aspx?name=" + (Server.UrlEncode(GetDownloadFileName + ".pdf")) + "&file=" + Server.UrlEncode("sessionfolders/" + Session.SessionID + "/" + filename) + "&content=" + Server.UrlEncode(content) + "');", true);
}
}
Response.ContentType = "application/pdf";
Response.ClearContent();
objpdf.Save(Response.OutputStream);
Response.End();
}
выдает ошибку в точке
var objpdf = pdfConverter.GetPdfDocumentObjectFromHtmlString(htmlString, baseURL);
подробности об исключениях приведены в виде стипендиатов
в ExpertPdf.HtmlToPdf.ImgConverter.GetMetafileFromHTMLStringWithWebKit (String htmlString, String baseUrl, String internalLinksDocUrl, ᦕ [] & fonts.Pht.PhtPT.Phtml.html), String htmlString, String baseUrl, String internalLinksDocUrl, Boolean fromUrl) в ExpertPdf.HtmlToPdf.PdfConverter.GetPdfDocumentObjectFromHtmlString (String htmlString, Строка urlBase) в ThemeablePage.cs: строка 768 в Export.Refresh () в D: \ GIT \ HondaBikeWeb \ ClearViewAPP \ Export.aspx.cs: строка 61 в Export.Page_Load (отправитель объекта, EventArgs e) в D: \ GIT \ HondaBikeWeb \ ClearViewAPP \ Export.aspx.cs: строка 14 в System.Web.Util.CalliEventHandlerDelegateProxy.Callback (Отправитель объекта, EventArgs e) в System.Web.UI.Control.OnLoad (EventArgs e) в System.Web.UI.Control.LoadRecursive () в System.Web.UI.Page.ProcessRequestMain (Boolean include), Boolean includeStagesAfterAsyncPoint)