#include <stdio.h>
#include <stdlib.h>
#include "pdflib.h"
#include <math.h>
#include <windows.h>
#include <WinBase.h>
#include <sys/stat.h>
Int main(void)
{
draw();
return 0;
}
int draw()
{
PDF *p;
int i, font;
int handle;
double result;
char str[100], *pStr;
int nSize;
char fontfile[1024];
char buf[1024];
if ((p = PDF_new()) == (PDF *) 0)
{
printf("Couldn't create PDFlib object (out of memory)!/n");
return(2);
}
PDF_TRY(p) {
PDF_set_parameter(p, "errorpolicy", "return");
if (PDF_begin_document(p, "d://hello.pdf", 0, "") == -1) {
printf("Error: %s/n", PDF_get_errmsg(p));
return(2);
}
PDF_set_parameter(p, "hypertextencoding", "host");
PDF_set_parameter(p, "fakebold", "true");
PDF_set_info(p, "Creator", "hello.c");
PDF_set_info(p, "Author", "Thomas Merz");
PDF_set_info(p, "Title", "Hello, world (C)!");
PDF_begin_page_ext(p, a4_width, a4_height, "");
PDF_setcolor(p, "stroke", "cmyk", 0, 0, 0, 1);
PDF_setlinewidth(p, 4);
PDF_moveto(p , 100, 100);
PDF_lineto(p , 500, 500);
PDF_stroke(p);
PDF_setcolor(p, "fill", "cmyk", 0, 0, 1, 0);
PDF_arc(p, 100, 500, 50, 0, 360);
PDF_moveto(p , 0, 0);
PDF_rect(p, 200, 500, 50, 10);
PDF_fill(p);
PDF_setcolor(p, "fill", "cmyk", 0, 1, 1, 0);
PDF_rect(p, 300, 500, 50, 10);
PDF_closepath(p);
PDF_fill(p);
PDF_end_page_ext(p, "");
PDF_end_document(p, "");
}
PDF_CATCH(p) {
printf("PDFlib exception occurred in hello sample:/n");
printf("[%d] %s: %s/n",
PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p));
PDF_delete(p);
getchar();
return(2);
}
PDF_delete(p);
execl("C://Program Files//Adobe//Acrobat 7.0//Acrobat//Acrobat.exe",
"_execl",
"d://hello.pdf", NULL, NULL);
return 0;
}