Hello all,
I try to parse a pdf using gnupdf. I looked in the pdf_util how it is
done there. SO I did not expected any problems.
My program has a problem in the call pdf_stm_file_new. It SEGFAULTS
because the argument for the stream pointer (pdf_stm_t) is 0.
>From my understanding I don't see any problem at all.
If one could try to confirm an issue or tell me what goes wrong. I
attach the file I use. The problem is line 48: ret =
pdf_stm_file_new (file,0,cache_size,PDF_STM_READ, &fsys_stm);
My system is Ubuntu 8.10, gnupdf from bzr, gcc 4.3.2
Many thanks, Adib.
---
#include "pdflib_helper.h"
#include <pdf.h>
#include <string.h>
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;
}