Hi,
I have a pre-existing PDF that I've opened with C++ with PDFLib. Once this PDF is open, I need to add content to it. But when I do, the content is always added on top of the pre-existing content. What determines the draw order for a PDF, and how do I modify it so I can draw underneath existing content? The code I'm using is just sample code to add a text run, like below (truncated/modified slightly):
PDPage pg = PDDocAcquirePage(_doc, 0);
PDEContent pageContent = PDPageAcquirePDEContent(pg, 0);
//Create new text run
PDETextAdd(pdeText, //Text container to add to
kPDETextRun, //kPDETextRun
0, //Index
(Uns8 *)HelloWorldStr, //Text to Add
strlen(HelloWorldStr), //Length of Text
pdeFont, //Font to apply to text
&gState, //Address of PDEGraphicState object
sizeof(gState), //size of graphic state ot apply to text
NULL,
0,
&textMatrix, //Transformation Matrix for text
NULL); //Stroke matrix
//Insert text into page content
PDEContentAddElem(pdeContent, kPDEAfterLast, (PDEElement)pdeText);
PDPageSetPDEContent(pg, 0);
PDPageNotifyContentsDidChange(pg);
PDDocSave(pdDoc, PDSaveFull | PDSaveLinearized, ASPathFromPlatformPath("out.pdf"), NULL, NULL, NULL);
Modifying both the index of PDEText or the addAfterIndex of PDEContentAddElem doesn't seem to make an affect. And I've tried to use PDEContainer to control draw order, but apparently the order the elements are in the container doesn't matter for draw order either...
Thanks!