Problem is with context. Pdf drawing commands are state-based. This is at
start of page:

/GSa gs
/CSp cs
/CSp CS
0.750000000 0 0 -0.750000000 28.5000000 813.500000 cm

There is no save of state prior to this transformation (cm) so it will
apply also to your commands. You need to prepend "q" before the original
contents and append (pairing) "Q" after it like this:

q
/GSa gs
/CSp cs
/CSp CS
0.750000000 0 0 -0.750000000 28.5000000 813.500000 cm
...
...
...
Q


On Sun, Mar 14, 2021 at 4:29 PM Kegin <kegin7...@gmail.com> wrote:

> I use wkhtmltopdf to generate pdf,
> and I want to draw a line on the pdf by the library-podofo,
> But this line is not at the exact position
> I manually converted html to pdf, used system printing to save the page as
> pdf
> and draw a line by library-podofo, This line is at the right place
>
> what is the problem? what different to generate pdf between "wkhtmltopdf"
> and "system printing"?
> please help me. Thank you
>
> Command Line
> wkhtmltopdf https://www.google.com google.pdf
>
> My Code
>
> try {
>             PdfMemDocument inputDocument;
>             PdfMemDocument document;
>             PdfPainter painter;
>             PdfPage *page;
>
>             document.Load("google.pdf");
>
>             page = document.GetPage(0);
>             painter.SetPage(page);
>
>             PdfFont *pFont = document.CreateFont("STHeiti Light", false, new 
> PdfIdentityEncoding(0, 0xffff, true));
>
>             pFont->SetFontSize(12);
>             painter.SetFont(pFont);
>
>
>             painter.DrawLine(page->GetPageSize().GetWidth() - 1, 
> page->GetPageSize().GetHeight(), page->GetPageSize().GetWidth() - 1, 0 );
>             painter.DrawLine(0, 1, page->GetPageSize().GetWidth(), 1 );
>
>
>             painter.FinishPage();
>             document.Write("output.pdf");
>
>         }
>         catch (...) {
>
>         }
>
>
> _______________________________________________
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users
>
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to