How to make ABCPdf automatically write to a new page when the text requires more than 1 page?

I deal with dynamic input text, so pages must be dynamically created. If page 1 is already full, it should be written to a new page, so this means that I can have page 2, page 3, etc. Depending on the data being processed.

My text is currently truncated. Page 1 only, other data not recorded.

My current code is below:

//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();

the html variable contains all the data (web page), maybe something in my while loop. Any help is appreciated! Thanks

+4
source share
1 answer
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();
}
+4
source

Source: https://habr.com/ru/post/1539714/


All Articles