Start fleshing out writing/copying interfaces.

This commit is contained in:
Michael R Sweet 2021-05-15 09:29:37 -04:00
parent 17f2cc213e
commit 4bb81417a8
No known key found for this signature in database
GPG Key ID: 999559A027815955
3 changed files with 31 additions and 3 deletions

View File

@ -29,6 +29,22 @@ pdfioObjClose(pdfio_obj_t *obj) // I - Object
}
//
// 'pdfioObjCopy()' - Copy an object to another PDF file.
//
pdfio_obj_t * // O - New object or `NULL` on error
pdfioObjCopy(pdfio_file_t *pdf, // I - PDF file
pdfio_obj_t *srcobj) // I - Object to copy
{
// TODO: Implement pdfioObjCopy
(void)pdf;
(void)srcobj;
return (NULL);
}
//
// 'pdfioObjCreateStream()' - Create an object (data) stream for writing.
//

View File

@ -24,6 +24,9 @@ _pdfioValueCopy(pdfio_file_t *pdfdst, // I - Destination PDF file
pdfio_file_t *pdfsrc, // I - Source PDF file
_pdfio_value_t *vsrc) // I - Source value
{
pdfio_obj_t *obj; // Object reference
if (pdfdst == pdfsrc && vsrc->type != PDFIO_VALTYPE_BINARY)
{
// For the same document we can copy the values without any other effort
@ -36,9 +39,17 @@ _pdfioValueCopy(pdfio_file_t *pdfdst, // I - Destination PDF file
switch (vsrc->type)
{
case PDFIO_VALTYPE_INDIRECT :
// Object references don't copy to other documents
_pdfioFileError(pdfdst, "Unable to copy indirect object reference between PDF files.");
return (NULL);
if ((obj = _pdfioFileFindMappedObject(pdfdst, pdfsrc, vsrc->value.indirect.number)) == NULL)
{
obj = pdfioObjCopy(pdfdst, pdfioFileFindObject(pdfsrc, vsrc->value.indirect.number));
}
if (!obj)
return (NULL);
vdst->value.indirect.number = obj->number;
vdst->value.indirect.generation = obj->generation;
break;
default :
return (NULL);

View File

@ -161,6 +161,7 @@ extern const char *pdfioFileGetVersion(pdfio_file_t *pdf) PDFIO_PUBLIC;
extern pdfio_file_t *pdfioFileOpen(const char *filename, pdfio_error_cb_t error_cb, void *error_data) PDFIO_PUBLIC;
extern bool pdfioObjClose(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioObjCopy(pdfio_file_t *pdf, pdfio_obj_t *srcobj) PDFIO_PUBLIC;
extern pdfio_stream_t *pdfioObjCreateStream(pdfio_obj_t *obj, pdfio_filter_t compression) PDFIO_PUBLIC;
extern pdfio_array_t *pdfioObjGetArray(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern pdfio_dict_t *pdfioObjGetDict(pdfio_obj_t *obj) PDFIO_PUBLIC;