How to store a single page as binary data?

12 views
Skip to first unread message

Ryan

unread,
May 21, 2020, 6:46:48 PM5/21/20
to PDFTron PDFNet SDK
Question:

How to store a single page as byte[] to store in a database?

Answer:

Assuming the PDFDoc object contains other pages, then something like the following would isolate that one page and give you back the bytes for it.

// given x is the page you want to store (index starts at one)
// given source is PDFDoc containing page x
PDFDoc sink = new PDFDoc();
ArrayList importList = new ArrayList();
importList
.Add(souce.GetPage(x));
ArrayList imported = sink.ImportPages(importList, importBookmarks); // where importBookmarks is a boolean. Set to true if you care about preserving bookmarks
sink
.PagePushBack(imported[0] as Page);
byte[] pdfPageData = sink.Save(SDFDoc.SaveOptions.e_remove_unused);


Reply all
Reply to author
Forward
0 new messages