PDFLib fails to create PDF file in pvf

220 Views Asked by At
mpdf.create_pvf(card, mpImgBytes, mlen, L"");
int inDoc = mpdf.open_pdi_document(card, L"");

I am using pdflib version 9.3.

open_pdi_document returns -1

create_pvf creates an empty file of size 0. Any idea on what could be wrong?

I am running pdflib on Windows 10, using C++.

2

There are 2 best solutions below

2
Rosh On BEST ANSWER

Not sure how relevant my answer is, but this could help someone.

Installing ghostscript on my machine, resolved the error.

2
Rainer On

I would recommend that you also retrieve the error reason in case of an error (open_pdi_document() returns -1) or work with the PDFlib errorpolicy "exception". Then you will get a first impression what the problem might be, then your code could looks like

        /* Open the input PDF */
        indoc = mpdf.open_pdi_document(card, L"");
        if (indoc == -1) {
            wcerr << L"Error: " << mpdf.get_errmsg() << endl;
            return 2;
        }

create_pvf creates an empty file of size 0.

how did you identify that?