Support
unread,Oct 8, 2009, 2:53:26 PM10/8/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PDFTron PDFNet SDK
Q: Could you provide a simple sample in C (not C++) that does
something like open a PDF and save it? I am struggling to see how to
get the equivalent of PDDocOpen(filename) from C working with your
API
(although from C++ it is easy).
--------
A: I didn't find any ready-to-use C code snippet, however direct
translation/lookup from C++ sample gives the following calls:
#include <C/PDF/TRN_PDFNet.h>
#include <C/PDF/TRN_PDFDoc.h>
#include <stdio.h>
// Open a PDF and print out its page count
int main(int argc, char *argv[])
{
int ret = 0;
TRN_Exception ex=TRN_PDFNetInitialize(0);
TRN_PDFDoc doc;
ex=TRN_PDFDocCreateFromFilePath("c:\\my.pdf", &doc);
if(ex!=0) { assert(false); return 1; }
int page_count = 0;
ex=TRN_PDFDocGetPageCount(doc, &page_count);
printf("%d\n", page_count);
ex=TRN_PDFDocDestroy(doc);
if(ex!=0) { assert(false); return 1; }
TRN_PDFNetTerminate();
return 0;
}