how to create and save a pdf file using pdfium?

2,585 views
Skip to first unread message

guofeng....@gmail.com

unread,
Aug 28, 2017, 5:33:02 AM8/28/17
to pdfium
 Hi, the coding as following: 
 // 初始化库

    FPDF_InitLibrary();



    //

    FPDF_DOCUMENT pdf_doc;

    pdf_doc = FPDF_CreateNewDocument();



    FPDF_PAGE pdf_page = FPDFPage_New(pdf_doc, 0, 900, 1200);



    FPDF_PAGEOBJECT page_obj = FPDFPageObj_CreateNewRect(0, 0, 300, 200);



    FPDFPage_InsertObject(pdf_page, page_obj);



    FPDFPage_GenerateContent(pdf_page);



How to save the document to a pdf file?

Dan Sinclair

unread,
Aug 28, 2017, 9:17:25 AM8/28/17
to guofeng....@gmail.com, pdfium
Take a look at FPDF_SaveAsCopy and FPDF_SaveWithVersion in fpdf_save.h.

dan
> --
> You received this message because you are subscribed to the Google Groups
> "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pdfium+un...@googlegroups.com.
> To post to this group, send email to pdf...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pdfium/97f31127-cffb-4e72-8600-f9e6d27e7df4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

guofeng....@gmail.com

unread,
Aug 28, 2017, 9:36:00 PM8/28/17
to pdfium, guofeng....@gmail.com
I have seen FPDF_SaveAsCopy and FPDF_SaveWithVersion,  and both have a pointer of FPDF_FILEWRITE.
I don't know how to pass the name of the file I want to create and save.
Can you give me some assitance or examples?

在 2017年8月28日星期一 UTC+8下午9:17:25,Dan Sinclair写道:

Lei Zhang

unread,
Aug 28, 2017, 9:52:03 PM8/28/17
to guofeng....@gmail.com, pdfium
PDFium has many tests that call FPDF_SaveAsCopy(). Some of them use
EmbedderTest::WriteBlockCallback() as part of their WriteBlock
callback. Is that a sufficient example?

Please also note there are several bugs related to FPDF_SaveAsCopy()
on our bug tracker.
> https://groups.google.com/d/msgid/pdfium/a9284eea-6bad-4de8-a085-2b9ddc6012b7%40googlegroups.com.

guofeng....@gmail.com

unread,
Aug 28, 2017, 10:34:49 PM8/28/17
to pdfium, guofeng....@gmail.com
ok, i got it, thanks a lot.

在 2017年8月29日星期二 UTC+8上午9:52:03,Lei Zhang写道:
Reply all
Reply to author
Forward
0 new messages