I use abcpdf to create a pdf from a html string. The following snippet shows the way I do it:
var pdfDocument = new Doc();
pdfDocument.Page = pdfDocument.AddPage();
pdfDocument.Font = pdfDocument.AddFont("Times-Roman");
pdfDocument.FontSize = 12;
var documentId = pdfDocument.AddImageHtml(innerHtml);
var counter = 0;
while (true)
{
counter++;
if (!pdfDocument.Chainable(documentId))
{
break;
}
pdfDocument.Page = pdfDocument.AddPage();
// how to add a inset of 20, 0 on every page after the second? The following 2lines don't affect the pdf pages
if (counter >= 3)
pdfDocument.Rect.Inset(20, 0);
documentId = pdfDocument.AddImageToChain(documentId);
}
After the AddPage I want to add a new inset for every page with pagenumber > 2
Thanks in advance
Comment #1 from SwissCoder was right. AddImageHtml
already adds the first page. After also contacting the WebSuperGoo support, they recommend me to use PageCount
of class Doc
.
while (true)
{
if (!pdfDocument.Chainable(documentId))
{
break;
}
pdfDocument.Page = pdfDocument.AddPage();
if (pdfDocument.PageCount >= 3)
pdfDocument.Rect.Inset(0, 20);
documentId = pdfDocument.AddImageToChain(documentId);
}
The other solution would be to adjust the index to count unto required pagenumber - 1
as ÀddImageHtml
already adds the first page to the document.