PDFlib使用(c++)

vc6.0使用pdflib操作pdf文件

PDFlib库下载

1.将pdflib.dll放到Debug文件中

2.将pdflib.hpp、pdflib.h、pdflib.lib放到项目文件夹中

3.引入头文件

#include "pdflib.hpp"
#pragma comment(lib,"pdflib.lib")
using namespace pdflib;

4.创建PDFlib对象

	PDFlib p;
    wostringstream buf;
    const wstring searchpath = L"../data";
    const wstring fontopt1 = L"fontname=宋体 fontsize=24";//设置字体

    p.set_option(L"errorpolicy=return");
    buf.str(L"");
    buf << L"searchpath={{" << searchpath << L"}}";
    p.set_option(buf.str());
	p.begin_document(L"xxx.pdf", L"");

5.创建一个新的页面

	p.begin_page_ext(0, 0, L"width=a4.width height=a4.height");

6.写入一行文字(要写入的文字,x坐标,y坐标,字体)

    p.fit_textline(L"  123    ", 20, 800, fontopt1);

7.画一条线

	p.setlinewidth(2);//设置线条粗细
	
    p.setcolor(L"stroke", L"rgb", 0.0f, 0.0f, 0.0f, 1.0f);//设置线条颜色
	
    p.moveto(10, 808);p.lineto(590, 808);p.stroke();//画线(10,808)-(590,808)

8.写入数字

	wstringstream str_date1;
    str_date1<<fixed<<setprecision(2)<<123;//数字123
    wchar_t date1[10];
    str_date1>>date1;
	p.fit_textline(date1, 200, 780, fontopt2);//(1,2)

9.结束

	p.end_page_ext(L"");
    p.end_document(L"");

PDFlib常用函数手册:

PDFlib常用函数手册


该博客意在记笔记,纯属为了以后使用方便!!! 

  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值