PDF Document Creation, Viewing
2024-08-25 13:58:08
【PDF Document Creation, Viewing, and Transforming】
Quartz provides the data type CGPDFDocumentRef to represent a PDF document. You create a CGPDFDocument object using either the function CGPDFDocumentCreateWithProvider or the function CGPDFDocumentCreateWithURL. After you create a CGPDFDocument object, you can draw it to a graphics context.
Following code shows how to create a CGPDFDocument object and obtain the number of pages in the document. by
CGPDFDocumentGetNumberOfPages function. A detailed explanation for each numbered line of code appears following the listing.
CGPDFDocumentRef MyGetPDFDocumentRef (const char *filename)
{
CFStringRef path;
CFURLRef url;
CGPDFDocumentRef document;
size_t count; path = CFStringCreateWithCString (NULL, filename,
kCFStringEncodingUTF8);
url = CFURLCreateWithFileSystemPath (NULL, path, //
kCFURLPOSIXPathStyle, );
CFRelease (path);
document = CGPDFDocumentCreateWithURL (url);//
CFRelease(url);
count = CGPDFDocumentGetNumberOfPages (document);//
if (count == ) {
printf("`%s' needs at least one page!", filename);
return NULL;
}
return document;
}
Drawing a PDF page:
void MyDisplayPDFPage (CGContextRef myContext,
size_t pageNumber,
const char *filename)
{
CGPDFDocumentRef document;
CGPDFPageRef page; document = MyGetPDFDocumentRef (filename);//
page = CGPDFDocumentGetPage (document, pageNumber);//
CGContextDrawPDFPage (myContext, page);//
CGPDFDocumentRelease (document);//
}
最新文章
- Linux网路编程系列-网络I/O模型
- 移动端基于HTML模板和JSON数据的JavaScript交互
- 关于sql 的convert 格式设置
- D - Charm Bracelet 背包问题
- O-C相关-06:对象与对象的关系
- Understanding JavaScript Function Invocation and ";this";
- sizeof与strlen的区别 浅谈
- CentOS系统中出现错误--SSH:connect to host centos-py port 22: Connection refused
- --------------Hibernate学习(四) 多对一映射 和 一对多映射
- 更好的小票打印体验,huanent.printer2.0发布
- Python reverse()方法--list
- Win10系统如何安装Linux Mint
- poj2279——Mr. Young's Picture Permutations
- Autowired byType 与 byName 策略
- 20170706wdVBA正则表达式提取题目
- 题目1003:A+B
- M端计算rem方法
- 搞清tomcat中的编解码
- Ssm框架常见报错
- 10-10Linux的文件操作函数以及所需头文件
热门文章
- 阿里云 搭建Git服务器
- CentOS6.5 下Haproxy服务的安装与配置
- GNU Radio: Multiple USRP configurations 配置多个USRP设备
- C#使用OpcNetApi.dll和OpcNetApi.Com.dll操作OPC
- 1021 docker搭建mysql、网络模式、grid
- JavaScript(二)-精简
- pythonNet day03
- js 取元素相对页面的高度和宽度
- 2.spring整合ehcache 注解实现查询缓存,并实现实时缓存更新或删除
- 【python 】装饰器 (多个参数的函数,带参数的装饰器)【转】