使用PDFLib生成PDF文档,C代码实例--画图形
2008-03-12 16:18
881 查看
#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;
}
#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;
}
相关文章推荐
- 使用PDFLib生成PDF文档,C代码实例--画图形
- 使用PDFLib生成PDF文档,C代码实例--使用特色
- 使用PDFLib生成PDF文档,C代码实例--使用特色
- iTEXT生成PDF文件使用方法 实例 示例 Servlet输出PDF文档方法
- 使用PDFLib生成PDF文档教程
- 使用PDFLib生成PDF文档
- 使用PDFLib生成PDF文档(C语言版)
- 使用PDFLib生成PDF文档教程
- PHP中使用TCPDF生成PDF文档实例
- Java使用wkhtmltox实现HTML代码生成PDF文档或者图片
- Java使用Flying Saucer实现HTML代码生成PDF文档
- Java使用wkhtmltox实现HTML代码生成PDF文档或者图片
- PHP中使用TCPDF生成PDF文档实例
- PHP中使用TCPDF生成PDF文档实例
- 使用PDFLib生成PDF文档(C语言版)--使用指导
- 使用PHP生成PDF文档
- Java iText使用PDF模板生成PDF文档
- 不使用log4j.xml/log4j.properties在Java代码中生成Logger实例
- 使用java生成pdf文档
- vs2010代码注释自动生成api文档(Sandcastle帮助文档生成器使用介绍)