problem saving to file

355 views
Skip to first unread message

Esteban Lorenzano

unread,
Jan 6, 2012, 10:36:44 AM1/6/12
to libHaru
Hi,

I'm creating a pdf and trying to save it to a file, executing:

HPDF_SaveToFile(ref, "/tmp/1234567.pdf")

and I'm getting a 0x1025 error (that's a code for I/O error, if I
understand well)

I'm with Ubuntu 11.04 32bits (inside a VMWare), libhpdf is the one who
comes with ubuntu: 2.1.0

Same code is working fine in Windows and Macs, and I'm not a linux
programmer, so I'm totally lost here.
Any help?

Thanks,
Esteban

Gautam

unread,
Jan 7, 2012, 2:37:17 AM1/7/12
to libHaru
Hi,
There is demo folder provided along the src of libHaru.
open that and copy arc_demo.c to ur desired location on ubuntu..
lets say /home/gautam/arc_demo.c
open the file

copy and paste below main .. (actually i am making minimum code for
making a pdf)

int
main (int argc, char **argv)
{
HPDF_Doc pdf;
HPDF_Page page;
char fname[256];
HPDF_Point pos;

strcpy (fname, argv[0]);
strcat (fname, ".pdf");

pdf = HPDF_New (error_handler, NULL);
if (!pdf) {
printf ("error: cannot create PdfDoc object\n");
return 1;
}

if (setjmp(env)) {
HPDF_Free (pdf);
return 1;
}

/* add a new page object. */
page = HPDF_AddPage (pdf);

HPDF_Page_SetHeight (page, 220);
HPDF_Page_SetWidth (page, 200);

HPDF_SaveToFile (pdf, fname);

/* clean up */
HPDF_Free (pdf);

return 0;
}

save and compile the file
$gcc arc_demo.c -L"/usr/local/lib" -lhpdf -o test (update lib
location as per ur).
$./test
this should give u a pdf.. if not check the file & folder permission
$ls -l (in GUI with right click).
hope this may solve ur.

Johan Van de Wauw

unread,
Jan 7, 2012, 5:04:53 AM1/7/12
to lib...@googlegroups.com
On Fri, Jan 6, 2012 at 4:36 PM, Esteban Lorenzano <este...@gmail.com> wrote:
> Hi,
>
> I'm creating a pdf and trying to save it to a file, executing:
>
> HPDF_SaveToFile(ref, "/tmp/1234567.pdf")
>
> and I'm getting a 0x1025 error (that's a code for I/O error, if I
> understand well)
No:
http://libharu.sourceforge.net/error_handling.html :
HPDF_INVALID_DOCUMENT 0x1025 An invalid document handle is set.

>
> I'm with Ubuntu 11.04 32bits (inside a VMWare), libhpdf is the one who
> comes with ubuntu: 2.1.0
>
> Same code is working fine in Windows and Macs, and I'm not a linux
> programmer, so I'm totally lost here.
> Any help?

Definitely provide more info. Building a minimal sample is often the
best way to find out what is going wrong.

>
> Thanks,
> Esteban
>
> --
> ---
> libHaru.org development mailing list
> To unsubscribe, send email to libharu-u...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages