如何使用ABCpdf将HTML文件转换为PDF格式

问题描述:

您好,



我使用Abcpdf.dll将html转换为pdf,但我收到以下错误。请帮帮我。

'WebSupergoo.ABCpdf7.Internal.NDoc'的类型初始化程序引发异常。



这是代码:

Hi There,

I am using Abcpdf.dll for converting html into pdf, but I am getting following error. Please help me out.
"The type initializer for 'WebSupergoo.ABCpdf7.Internal.NDoc' threw an exception."

This is the code:

Doc theDoc = new Doc();
theDoc.AddImageUrl("http://www.example.com");
byte[] theData = theDoc.GetData();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF");
Response.AddHeader("content-length", theData.Length.ToString());
Response.BinaryWrite(theData);
Response.End();

Doc theDoc = new Doc();

theDoc.SetInfo(0,License,m_License);

theDoc.HtmlOptions.Paged = true;

theDoc.HtmlOptions.Timeout = 1000000;



string callUrl =http://我的应用页面;

theDoc.AddImageUrl(callUrl);

Response.Clear ();



Response.Cache.SetCacheability(HttpCacheability.Private);

Response.AddHeader(Content-Disposition,attachment ; filename =+ sFile +。pdf);

Response.ContentType =application / octet-stream;



theDoc .Save(Response.OutputStream);



Response.Flush();
Doc theDoc = new Doc();
theDoc.SetInfo(0, "License", m_License );
theDoc.HtmlOptions.Paged = true;
theDoc.HtmlOptions.Timeout = 1000000;

string callUrl = "http:// my app page";
theDoc.AddImageUrl(callUrl);
Response.Clear();

Response.Cache.SetCacheability(HttpCacheability.Private);
Response.AddHeader("Content-Disposition", "attachment; filename=" + sFile + ".pdf");
Response.ContentType = "application/octet-stream";

theDoc.Save(Response.OutputStream);

Response.Flush();