Implement pdfioObjCopy and pdfioPageCopy, with tests.

This commit is contained in:
Michael R Sweet
2021-05-29 20:00:48 -04:00
parent 37842066c6
commit 35d22705fa
11 changed files with 244 additions and 68 deletions

View File

@@ -18,13 +18,32 @@
// 'pdfioPageCopy()' - Copy a page to a PDF file.
//
pdfio_obj_t * // O - Destination page
bool // O - `true` on success, `false` on failure
pdfioPageCopy(pdfio_file_t *pdf, // I - PDF file
pdfio_obj_t *src) // I - Source page
pdfio_obj_t *srcpage) // I - Source page
{
// TODO: Implement pdfioPageCopy
(void)pdf;
(void)src;
pdfio_obj_t *dstpage; // Destination page object
return (NULL);
PDFIO_DEBUG("pdfioPageCopy(pdf=%p, srcpage=%p(%p))\n", pdf, srcpage, srcpage ? srcpage->pdf : NULL);
// Range check input
if (!pdf || !srcpage || srcpage->value.type != PDFIO_VALTYPE_DICT)
{
if (pdf)
{
if (!srcpage)
_pdfioFileError(pdf, "NULL page object specified.");
else
_pdfioFileError(pdf, "Object is not a page.");
}
return (false);
}
// Copy the page object and add it to the pages array...
if ((dstpage = pdfioObjCopy(pdf, srcpage)) == NULL)
return (false);
else
return (_pdfioFileAddPage(pdf, dstpage));
}