【问题标题】:How do I make ABCPdf to automatically write to a new page when text requires more than 1 page?当文本需要超过 1 页时,如何使 ABCPdf 自动写入新页面?
【发布时间】:2014-05-08 07:52:00
【问题描述】:

我处理动态输入文本,所以页面应该是动态创建的。如果第 1 页已经满了,它应该写入一个新页面,所以这意味着我可以根据处理的数据拥有第 2 页、第 3 页等等。

目前,我的文本被截断。只写第1页,其余数据不写。

我当前的代码如下:

//add page 1
theDoc.Page = theDoc.AddPage();
theDoc.AddImageHtml(html, true, 826, true);

//continue adding page if needed                             
while (theDoc.GetInfo(theID, "Truncated") == "1")
{
   theDoc.Page = theDoc.AddPage();
   theDoc.AddImageHtml(html, true, 826, true);
}

//save file
String pdfFilePath = WebConfigurationManager.AppSettings["pdfFilePath"];
Guid fileName = Guid.NewGuid();
pdfLink = pdfFilePath + fileName.ToString() + ".pdf";
theDoc.Save(pdfLink);
theDoc.Clear();

variable html 包含所有数据(网页),我的 while 循环中可能遗漏了一些东西。任何帮助表示赞赏!谢谢

【问题讨论】:

    标签: dynamic abcpdf truncated


    【解决方案1】:
    Found it, Use Chainable and then Flatten()
    
    theDoc.Page = theDoc.AddPage();
    int theID;
    theID = theDoc.AddImageUrl("http://www.yahoo.com/");
    
    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();
    }
    

    【讨论】:

      猜你喜欢
      • 2010-12-24
      • 1970-01-01
      • 1970-01-01
      • 2012-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多