michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
199 stars 44 forks source link

Add multiple page content stream APIs #30

Open michaelrsweet opened 2 years ago

michaelrsweet commented 2 years ago

Currently the PDF write API only supports a single page content stream, while the read API supports an arbitrary number of streams, as supported by the PDF format.

Proposed API:

extern pdfio_obj_t *pdfioFileCreatePageObj(pdfio_file_t *pdf, pdfio_dict_t *dict) _PDFIO_PUBLIC;

extern pdfio_stream_t *pdfioPageCreateStream(pdfio_obj_t *page, pdfio_filter_t compression) _PDFIO_PUBLIC;

Usage:

pdfio_file_t *pdf; // PDF file
pdfio_obj_t *page; // Page object
pdfio_dict_t *dict; // Page dictionary

page = pdfioFileCreatePageObj(pdf, dict);

pdfio_stream_t *st1, *st2;

st1 = pdfioPageCreateStream(page, PDFIO_FILTER_FLATE);
// write some page content commands to the stream
pdfioStreamClose(st1);

st2 = pdfioPageCreateStream(page, PDFIO_FILTER_NONE);
// write some page content commands to the stream
pdfioStreamClose(st2);

// Close the page object to write it out...
pdfioObjClose(page);
michaelrsweet commented 11 months ago

Moving this to the "future" milestone - not critical to support.

michaelrsweet commented 5 months ago

Also lowered the priority because you can merge multiple streams when writing anyways...