mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-02-26 13:52:49 +01:00
Lay the groundwork for object streams.
This commit is contained in:
parent
f09105dd3f
commit
aa6a20c042
34
pdfio-file.c
34
pdfio-file.c
@ -26,6 +26,7 @@ static bool load_obj_stream(pdfio_obj_t *obj);
|
|||||||
static bool load_pages(pdfio_file_t *pdf, pdfio_obj_t *obj, size_t depth);
|
static bool load_pages(pdfio_file_t *pdf, pdfio_obj_t *obj, size_t depth);
|
||||||
static bool load_xref(pdfio_file_t *pdf, off_t xref_offset, pdfio_password_cb_t password_cb, void *password_data);
|
static bool load_xref(pdfio_file_t *pdf, off_t xref_offset, pdfio_password_cb_t password_cb, void *password_data);
|
||||||
static bool repair_xref(pdfio_file_t *pdf, pdfio_password_cb_t password_cb, void *password_data);
|
static bool repair_xref(pdfio_file_t *pdf, pdfio_password_cb_t password_cb, void *password_data);
|
||||||
|
static bool write_obj_streams(pdfio_file_t *pdf);
|
||||||
static bool write_pages(pdfio_file_t *pdf);
|
static bool write_pages(pdfio_file_t *pdf);
|
||||||
static bool write_trailer(pdfio_file_t *pdf);
|
static bool write_trailer(pdfio_file_t *pdf);
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ pdfioFileClose(pdfio_file_t *pdf) // I - PDF file
|
|||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
||||||
if (pdfioObjClose(pdf->info_obj) && write_pages(pdf) && pdfioObjClose(pdf->root_obj) && write_trailer(pdf))
|
if (pdfioObjClose(pdf->info_obj) && write_pages(pdf) && write_obj_streams(pdf) && pdfioObjClose(pdf->root_obj) && write_trailer(pdf))
|
||||||
ret = _pdfioFileFlush(pdf);
|
ret = _pdfioFileFlush(pdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2343,6 +2344,37 @@ repair_xref(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 'write_obj_streams()' - Write object streams...
|
||||||
|
//
|
||||||
|
|
||||||
|
static bool // O - `true` on success, `false` on error
|
||||||
|
write_obj_streams(pdfio_file_t *pdf) // I - PDF file
|
||||||
|
{
|
||||||
|
size_t i; // Looping var
|
||||||
|
pdfio_obj_t *obj; // Current object
|
||||||
|
|
||||||
|
|
||||||
|
// Object streams are part of PDF 1.5 and later...
|
||||||
|
if (strcmp(pdf->version, "1.5") < 0)
|
||||||
|
return (true);
|
||||||
|
|
||||||
|
// Loop through the file objects and write any to an object stream...
|
||||||
|
for (i = 0; i < pdf->num_objs; i ++)
|
||||||
|
{
|
||||||
|
obj = pdf->objs[i];
|
||||||
|
|
||||||
|
if (obj->offset > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!_pdfioObjWriteHeader(obj) || !_pdfioFilePuts(pdf, "endobj\n"))
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 'write_pages()' - Write the PDF pages objects.
|
// 'write_pages()' - Write the PDF pages objects.
|
||||||
//
|
//
|
||||||
|
@ -34,6 +34,11 @@ pdfioObjClose(pdfio_obj_t *obj) // I - Object
|
|||||||
// Write what remains for the object...
|
// Write what remains for the object...
|
||||||
if (!obj->offset)
|
if (!obj->offset)
|
||||||
{
|
{
|
||||||
|
// If we are writing a PDF 1.5 or later object, put all value-only objects
|
||||||
|
// in object streams...
|
||||||
|
if (obj != obj->pdf->encrypt_obj && obj != obj->pdf->info_obj && obj != obj->pdf->root_obj && strcmp(obj->pdf->version, "1.5") >= 0)
|
||||||
|
return (true);
|
||||||
|
|
||||||
// Write the object value
|
// Write the object value
|
||||||
if (!_pdfioObjWriteHeader(obj))
|
if (!_pdfioObjWriteHeader(obj))
|
||||||
return (false);
|
return (false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user