最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

PoDoFo::PdfPainter::DrawText doesn't render text to subsequent pages - Stack Overflow

programmeradmin1浏览0评论

I'm trying to create a pdf document with multiple pages, and render text to each page with PoDoFo::PdfPainter::DrawText(). The text is only rendered once, text on subsequent pages isn't rendered. I can write to first page, then text isn't rendered on second. If however I would write to second page, not to first page, the text is rendered on second ok. Images rendered to a page with DrawImage() are rendered to each page ok. Am I doing something wrong?

    PdfMemDocument document;
    PdfPainter painter;
    PdfFont* font = document.GetFonts().SearchFont("Arial");

    auto& page1 = document.GetPages().CreatePage(PdfPageSize::A4);

    painter.SetCanvas(page1);
    painter.TextState.SetFont(*font, 12);
    painter.DrawText("hello", 20, page1.GetRect().Height - 80); //if i comment this 
                                                                //line, text is written 
                                                                //to second page ok
    painter.FinishDrawing();

    auto& page2 = document.GetPages().CreatePage(PdfPageSize::A4);

    painter.SetCanvas(page2);
    painter.TextState.SetFont(*font, 12);
    painter.DrawText("hello again", 20, page2.GetRect().Height - 80);
    painter.FinishDrawing();

    document.Save("test.pdf");
发布评论

评论列表(0)

  1. 暂无评论