pdfio/pdfio-page.c

50 lines
1.1 KiB
C
Raw Permalink Normal View History

2021-04-10 14:00:52 +02:00
//
// PDF page functions for PDFio.
2021-04-10 14:00:52 +02:00
//
// Copyright © 2021 by Michael R Sweet.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
// information.
//
//
// Include necessary headers...
//
#include "pdfio-private.h"
2021-04-17 02:41:46 +02:00
//
2021-04-28 03:22:34 +02:00
// 'pdfioPageCopy()' - Copy a page to a PDF file.
2021-04-17 02:41:46 +02:00
//
bool // O - `true` on success, `false` on failure
2021-04-28 03:22:34 +02:00
pdfioPageCopy(pdfio_file_t *pdf, // I - PDF file
pdfio_obj_t *srcpage) // I - Source page
2021-04-17 02:41:46 +02:00
{
pdfio_obj_t *dstpage; // Destination page object
2021-04-28 03:22:34 +02:00
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));
2021-04-17 02:41:46 +02:00
}