I'm trying to write a program to do page imposition, because the "podofoimpose" program supplied with the library does not, in fact, work.
http://sourceforge.net/apps/mantisbt/podofo/view.php?id=28 It seems that the way to do this is to create XObjects from the pages in the source files, and redraw these onto the destination pages with the appropriate geometric transforms. Having only limited knowledge of PoDoFo and PDF, I'm not quite clear on how to do this. The code below is supposed to create XObjects from the input files, and then just concatenate them together in the output, one per page, with no transforms applied. It does not work; the output has the correct number of pages, but all are blank. What else needs to be done to accomplish this very basic result, while still using XObjects? A related question: why is the PdfDictionary class referred to, but not documented, in the current PDF and HTML API documentation? -- Ian Bruce #include <vector> #include <podofo.h> using namespace std; using namespace PoDoFo; int impose (vector<const char *> &srcfiles, const char *dstfile) { vector<PdfMemDocument *> src; vector<PdfXObject *> xobjs; vector<PdfPage *> pages; PdfMemDocument *dst = new PdfMemDocument; for (vector<const char *>::iterator p = srcfiles.begin(); p != srcfiles.end(); ++p) { src.push_back (new PdfMemDocument (*p)); } for (vector<PdfMemDocument *>::iterator p = src.begin(); p != src.end(); ++p) { for (int i = 0; i < (*p)->GetPageCount (); ++i) { xobjs.push_back (new PdfXObject (**p, i, dst)); } } for (vector<PdfXObject *>::iterator p = xobjs.begin(); p != xobjs.end(); ++p) { PdfPage *page = dst->CreatePage(PdfRect (0, 0, 612, 792)); PdfStream *stream = page->GetContents()->GetStream(); PdfName *name = new PdfName((*p)->GetIdentifier()); // page->GetResources()->GetDictionary().AddKey(*name, **p); // page->GetObject()->GetDictionary().AddKey(*name, **p); string s = "/" + name->GetName() + " Do\n"; stream->Set(s.c_str ()); } dst->Write(dstfile); } main() { vector<const char *> srcfiles; const char *dstfile; srcfiles.push_back ("page1.pdf"); srcfiles.push_back ("page2.pdf"); dstfile = "out.pdf"; impose (srcfiles, dstfile); } ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
