将页码添加到Pdf文档

Nar*_*ppa 2 c# asp.net abcpdf

如果pdf的内容并非全部适合单个页面,我如何将pdf的内容扩展到下一页.目前我正在创建Pdf作为A4.

另外,如何指定页数,例如右下角的第1页,共12页.

joh*_*hna 5

要将文本添加到PDF文档并在文本不适合时创建新页面,可以使用以下代码.

theID = theDoc.AddHtml(theText)
While theDoc.Chainable(theID)
  theDoc.Page = theDoc.AddPage()
  theDoc.FrameRect
  theID = theDoc.AddHtml("", theID)
Wend
Run Code Online (Sandbox Code Playgroud)

要将页码和页数添加到每个页面,请使用此选项.

theDoc.Rect = "100 50 500 150" 'position of page number
For i = 1 To theDoc.PageCount
  theDoc.PageNumber = i
  theDoc.AddText i & "/" & theDoc.PageCount
Next
Run Code Online (Sandbox Code Playgroud)

编辑:C#版本

Doc doc = new Doc();
doc.Page = doc.AddPage();
int id = doc.AddImageUrl("http://www.google.com/", true, 700, true);
while (true)
{
    if (!doc.Chainable(id))
        break;
    doc.Page = doc.AddPage();
    id = doc.AddImageToChain(id);
 }

 doc.Font = doc.AddFont("Arial");
 doc.FontSize = 9;
 for (int i = 1; i <= doc.PageCount; i++)
 {
     doc.PageNumber = i;
     doc.Rect.String = "470 55 570 65";
     doc.HPos = 1;
     doc.AddText("Page " + i.ToString() + " of " + doc.PageCount.ToString());
 }
Run Code Online (Sandbox Code Playgroud)