Hello ChunHsia Tang, hello all,
> On 21 February 2018 at 10:16 chunhsia_t...@mazak.co.jp wrote:
I'm sorry I'm replying only now, I just got your email from
the mailing list (approved there: Tue, 06 Mar 2018 01:07:23 +0000)
as there was an outage/reliability problem at SourceForge.net.
> a pdf page has some text and image
> add watermark, watermark appear on top text and image
I'm no expert on real (removal-protected) watermarks, sorry.
That said, when an image or some text is added to a PDF page
after other elements of the page, it appears on top of them.
That is because PoDoFo directly only supports appending to a
PDF page's content stream via the PdfPainter API, so to put
something in between, either lower-level PoDoFo APIs need to
be used or (only possible if the page is created with PoDoFo
of course) place the drawing call for it between the others.
> PdfExtGState gstate(&doc);
> pPage = doc.GetPage(0);
The Save() call should bif youe put before SetExtGState() so that
the (not yet "extended") graphics state set before the latter
call can be restored further down in the code by Restore().
> painter.DrawText(100, 100, "test test test test test test test test test");
Where do you add the image, please? I can't see it from this code.
> how to add watermark appear at front text but behind image?
To have the "watermark" (not a real one AFAIK) appear in front
of the text but behind the image, either draw it after the text
but before the image (if you're using PoDoFo for all that) or
use PdfContentsTokenizer to find where the text ends, copy the
part of the content stream (from PdfPainter::GetCanvas()) after
that offset in it to somewhere else, then truncate the original
there (FinishPage(), then use PdfStream methods for that, after
it's done call PdfPainter::SetPage() again) then draw to it:
Save() before SetExtGState(), see above, call Restore(), then
append the saved part of the content stream (just Append(), don't
call BeginAppend() or EndAppend() or any method which is to call
these, PdfPainter::SetPage() has already called the first one),
then call PdfPainter::FinishPage() (calls EndAppend() for you)
and it should work (I haven't tested it myself, though, or I
would still be busy with that for quite some time).
You're welcome, I hope this helps you enough.
Best regards, mabri
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Podofo-users mailing list