Hi, I would suggest to not use PdfPagesTree::CreatePage but create a PdfPage by yourself.
Some pseudo coude as example: PdfPage * pPage = new PdfPage(rect, &(pdf.GetObjects()) ); pTree->InsertPage(ePdfPageInsertionPoint_InsertBeforeFirstPage, pPage) hope this helps. Regards, Dominik On Sat, Oct 22, 2011 at 12:10 AM, Palmer Zent <[email protected]> wrote: > Hello, > > I am trying to use PoDoFo to add a new empty page as page 1 in an existing > one-page PDF file. > I have looked at the tool called podofopages, and especially the > MoveOperation.cpp file but i can't make it work the way i understand it > should work : > > Here is what i do : > > PdfPagesTree* pTree = pdf.GetPagesTree(); > > // This successfully creates a new empty page at the last position in the > tree. The tree now looks like [ 9 0 R 72 0 R] > PdfPage* page = pTree->CreatePage(rect); > > // This gives me the new page's position in the 0-based tree, which is 1 > int pageFrom = page->GetPageNumber()-1; > > // This successfully inserts the page at the first position (if i save the > file at this point, my tree looks like [ 72 0 R 9 0 R 72 0 R ], which looks > right but > // doesn't make acrobat happy (i guess a page should only be referenced once) > pTree->InsertPage(ePdfPageInsertionPoint_InsertBeforeFirstPage, page); > > // Value of pageForm is 1, so item at index 2 should be deleted > // Instead, this deletes the first reference and leaves me with this tree: [ > 9 0 R 72 0 R] > pTree->DeletePage(pageFrom+1); > > In the end, the new page is still at the last position instead of the first > one like i would like it to be.. > > Could someone tell me if i am missing something or if it may be a bug ? > > Thanks in advance and thank you for providing such an powerful piece of > software. > > Best regards, > > Palmer > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > Podofo-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/podofo-users > ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
