Ale*_*ois 6 html c# asp.net abcpdf
我目前正在使用abcPDF 7将HTML转换为PDF.这是通过ASPX页面完成的,我覆盖了Render方法.
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();
Run Code Online (Sandbox Code Playgroud)
这适用于第一页,但随后截断页面并且不会继续呈现剩余的页面.
有人知道为什么它会在页面后停止吗?
小智 11
我有同样的问题.答案是使用链接,但上一个答案中提供的页面并不能准确地告诉您如何执行此操作.这是我网站上的一个例子:请注意,变量htmlOutput是我的对象中的一个变量,它接受我要渲染的htmlOutput.我收集这些从网页要么只需按下HTML直接插入变量,或者如果其当前页面,我运行受保护的覆盖无效渲染(HtmlTextWriter的输出)的页面,推的渲染到这个htmlOutput变量的内容.
Doc theDoc = new Doc();
int theID;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageHtml(htmlOutput);
while (true)
{
theDoc.FrameRect(); // add a black border
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
//reset back to page 1 so the pdf starts displaying there
if(theDoc.PageCount > 0)
theDoc.PageNumber = 1;
//now get your pdf content from the document
byte[] theData = theDoc.GetData();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12906 次 |
| 最近记录: |