[poppler] Patch: let Poppler::PDFConverter export also a selected number of pages
Albert Astals Cid
aacid at kde.org
Fri Nov 11 04:15:17 PST 2011
A Divendres, 7 d'octubre de 2011, Glad Deschrijver vàreu escriure:
> On Thursday 06 October 2011, Albert Astals Cid wrote:
> > A Dimarts, 4 d'octubre de 2011, Glad Deschrijver vàreu escriure:
> > > Following your request, I implemented setPageList(...) in
> > > PDFConverter.
> > > In order to have a similar behavior as in PSConverter (i.e. saving
> > > the
> > > selected pages to one file, and not to a file per page), I also
> > > added a
> > > function savePagesAs(OutStream *outStr, std::vector<int> pagesList);
> > > to
> > > PDFDoc. Since I have no PDF-hacking experience, I copied the code
> > > from
> > > pdfunite.cc and adapted it to the new situation. So I hope that the
> > > code is decent. At least it works perfectly on my PDF files.
> >
> > I see there is quite a bit of code "copied" from the pdfunite sources,
> > do
> > you think you can make it a bit more generic so we only have one source
> > and both functions use that same code?
>
> I tried (see attachment). I noticed that there was also quite some code
> shared with PDFDoc::savePageAs() so I put the shared code in two function
> PDFDoc::fetchPage() and PDFDoc::writePagesAndTrailer().
Hi Glad, sorry for the late reply. I've had a look at the patch and it looks
ok (though it does not seem to cleanly apply to master).
My concern is on the qt4 frontend side, when if there is a pagelist set you
"ignore" the WithChanges flag. The thing is that on savePagesAs you end up
calling writePageObjects that does getXRef()->fetch() that will
unconditionally return the "changed/updated" object
e = getEntry(num);
if(!e->obj.isNull ()) { //check for updated object
What it would be cool is that using a pagelist still honours the save with
changes or not flag, what i am thinking is adding a setter to XRef so you can
say "from now on, do not give me the updated objects", so in
PDFDoc::savePagesAs we would do something like
GBool oldValue = xref->amIGivingTheUpdatedObjects();
xref->setGiveMeTheUpdatedObejcts(flags == saveWithChanges);
// do all the write to file work
xref->setGiveMeTheUpdatedObejcts(oldValue);
This obviously needs better names :D
What do you think? Or should we just document that using a pagelist in the qt4
pdf converter means using also the WithChanges flag?
Albert
>
> Best regards,
> Glad
>
> --
> The only way to abolish war is to make peace heroic.
> -- John Dewey, American philosopher and educator (1859-1952)
More information about the poppler
mailing list