#include "pdflib_helper.h" #include #include int pdflib_init(void) { pdf_text_init (); return 1; } int pdflib_open(const char *filename) { //open_file (pdf_char_t * name, pdf_fsys_file_t * file, // enum pdf_fsys_file_mode_e mode) pdf_char_t * name; pdf_fsys_file_t file; enum pdf_fsys_file_mode_e mode = PDF_FSYS_OPEN_MODE_READ; pdf_status_t ret; pdf_text_t path; pdf_stm_t fsys_stm = NULL; // create a copy of the filename as pdf_string name = (pdf_char_t *)pdf_alloc (strlen(filename)+1); strcpy ((char *)name, filename); int len = strlen((char *)name); ret = pdf_text_new_from_unicode(name, len, PDF_TEXT_UTF8, &path); if (ret != PDF_OK) { pdf_error (ret, stderr, "while creating pdf text path"); return 0; } // open the file as pdf_sys_file ret = pdf_fsys_file_open (NULL, path, mode, &file); if (ret != PDF_OK) { pdf_error (ret, stderr, "while creating pdf file from path"); return 0; } // now create the reading strem on that file pdf_size_t cache_size = 0; //fsys_stm = pdf_stm_alloc (); // *read_pdf_fsys = PDF_TRUE; ret = pdf_stm_file_new (file,0,cache_size,PDF_STM_READ, &fsys_stm); if (ret != PDF_OK) { pdf_error (ret, stderr, "while creating the read stream"); return 0; } pdf_stm_destroy (fsys_stm); pdf_text_destroy(path); pdf_dealloc(name); return 1; }