michaelrsweet / pdfio

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

The document contains no pages #72

Closed raphael10-collab closed 4 months ago

raphael10-collab commented 4 months ago

Code :

        pdfio_rect_t media_box = { 0.0, 0.0, 612.0, 792.0 };  // US Letter
        pdfio_rect_t crop_box = { 36.0, 36.0, 576.0, 756.0 }; // w/0.5" margins
        pdfio_output_cb_t output_cb;
        void *output_cbdata;
        pdfio_error_cb_t error_cb;

        void  *error_cb_data;
        int outfd;
        bool error = false;
        // https://github.com/michaelrsweet/pdfio/blob/master/pdfio-file.c
        pdfio_file_t *pdf = pdfioFileCreate(completePathToPdfFile.c_str(), NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error);
        static int num_pages = pdfioFileGetNumPages(pdf);
        std::cout << " static int num_pages = pdfioFileGetNumPages(pdf) : " << num_pages << std::endl;
        pdfio_file_t *inputpdf = pdfioFileOpen("/home/raphy/GraspAppData/PdfCreated/output.pdf", NULL, NULL, (pdfio_error_cb_t)error_cb, &error);
        pdfio_obj_t *img = pdfioFileCreateImageObjFromFile(pdf, "/home/raphy/GraspAppData/PdfCreated/pdfio-color.png", false);
        pdfioFileClose(pdf);

Output :

image

What am I missing? How to add an image, and therefore a page, to the pdf file?