Bug 69965

Summary: Allow to save selected pages from documents
Product: poppler Reporter: Marek Kasik <mkasik>
Component: glib frontendAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: medium CC: ajohnson, bugzilla, mkasik, rishi.is
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: glib: Add poppler_documents_save_pages()
Add PDFBuilder class

Description Marek Kasik 2013-09-30 13:53:22 UTC
Created attachment 86849 [details] [review]
glib: Add poppler_documents_save_pages()

Attached is a patch which implements function poppler_documents_save_pages(). 

This function can be useful in situation when an application needs to save selected pages from a document or merge / split documents.

Its first parameter "documents" is array of PopplerDocument.
Second parameter "pages" is array of arrays of integers. Every 1st level array of "pages" corresponds to a PopplerDocument on the same position in "documents". Every second level array is terminated by -1.
Number of documents is specified in the third parameter "n_documents".
Fourth parameter is an uri to which the result will be saved.
Last parameter is return location for error.

The code is based on the "pdfunite" utility.

Regards

Marek
Comment 1 Albert Astals Cid 2013-09-30 14:03:57 UTC
Any chance you can share the code instead of copying it by moving it up to somewhere in poppler/* ?
Comment 2 Marek Kasik 2013-09-30 14:24:10 UTC
(In reply to comment #1)
> Any chance you can share the code instead of copying it by moving it up to
> somewhere in poppler/* ?

Sure, I'll look for a place where it fits well.
Comment 3 Carlos Garcia Campos 2013-09-30 16:03:36 UTC
Comment on attachment 86849 [details] [review]
glib: Add poppler_documents_save_pages()

This looks very complex API to me. I haven't looked at the patch in detail, but I would go with something more like:

poppler_document_writer_new ();
poppler_document_writer_add_page (writer, page, &error);
poppler_document_writer_add_page (writer, page, &error);
....
poppler_document_writer_write (writer, uri, &error);

Or something similar.
Comment 4 Marek Kasik 2013-10-03 13:22:08 UTC
Created attachment 87030 [details] [review]
Add PDFBuilder class

I've created a new class PDFBuilder for the creation of PDFs. It has two methods addPage() and saveAs(). The first one adds a "Page" to an internal list and the saveAs() saves all such pages to the given filename.
Comment 5 Carlos Garcia Campos 2013-11-11 09:49:06 UTC
This is quite similar to the PDFWritter class in bug #71213, maybe we could use a common code in the core, and use it both, for printing and for saving specific pages.
Comment 6 Adrian Johnson 2013-11-11 10:09:19 UTC
Looking at the PDFBuilder class the main difference is it allows pages from different documents. It should be easy to add this functionality to PDFWriter.
Comment 7 Marek Kasik 2013-11-14 11:26:10 UTC
(In reply to comment #5)
> This is quite similar to the PDFWritter class in bug #71213, maybe we could
> use a common code in the core, and use it both, for printing and for saving
> specific pages.

I'll try to look at this next week.

Thank you

Marek
Comment 8 Albert Astals Cid 2013-12-12 21:29:27 UTC
So should this be discarded in favour of https://bugs.freedesktop.org/show_bug.cgi?id=71213 ?
Comment 9 Marek Kasik 2013-12-13 09:02:23 UTC
(In reply to comment #8)
> So should this be discarded in favour of
> https://bugs.freedesktop.org/show_bug.cgi?id=71213 ?

Yes, you are right. I'm closing this as duplicate of the #71213.

Regards

Marek

*** This bug has been marked as a duplicate of bug 71213 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.