PDF Document Creation, Viewing
【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);//
}
PDF Document Creation, Viewing的更多相关文章
- POJ 3654 & ZOJ 2936 & HDU 2723 Electronic Document Security(模拟)
		
题目链接: PKU:http://poj.org/problem?id=3654 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...
 - HDU——2723Electronic Document Security(STL map嵌套set做法)
		
Electronic Document Security Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
 - Delphi资源大全
		
A curated list of awesome Delphi frameworks, libraries, resources, and shiny things. Inspired by awe ...
 - Awesome Delphi
		
Awesome Delphi A curated list of awesome Delphi frameworks, libraries, resources, and shiny things. ...
 - Core Graphics 定制UIVIew 处理图片
		
许多UIView的子类,如UIButton或UILabel,它们的形状都是系统固定的.但是,对于一些特殊的情况,我们需要绘制产品狗想要的图形.那么等待我们的只有两个选择:第一,可以使用UIImageV ...
 - pdf 中内容的坐标系
		
PDF Page Coordinates (page size, field placement, etc.) AcroForm, Basics, Automation Page coordinate ...
 - 在.NET中使用iTextSharp创建/读取PDF报告: Part I [翻译]
		
原文地址:Create/Read Advance PDF Report using iTextSharp in C# .NET: Part I By Debopam Pal, 27 Nov 20 ...
 - itextsharp c# asp.net 生成 pdf 文件
		
一切的开始必须要有2个dll, 可以通过nuget 包xiazai, 关键字是itextsharp. using iTextSharp.text; using iTextSharp.text.pdf; ...
 - Pdf File Writer 中文应用(PDF文件编写器C#类库)
		
该文由小居工作室(QQ:2482052910) 翻译并提供解答支持,原文地址:Pdf File Writer 中文应用(PDF文件编写器C#类库):http://www.cnblogs.com/ ...
 
随机推荐
- (经典) K&R的名著<<C程序设计语言>>二分查找
			
#include<stdio.h> //查找成功则返回所在下标否则返回-1 int binsearch(int A[], int n,int a) { int low, high, mid ...
 - nexus yum 私服集成
			
nexus 集成了 yum 私服使用起来还是比较简单的 配置 yum proxy 实际使用我们可能需要配置centos 以及epel 的源 centos可以用http://mirror.cento ...
 - LogHelp 日记分天记录,只记30天日记
			
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Tex ...
 - linux系统报错日志学习
			
linux本身会自动记录系统报错日志:/var/log/messages 这个日志记录,我是在什么时候发现其强大的作用的呢?它有点像我们使用php脚本开发接口的时候技术员在重要地方打日志的效果,方便技 ...
 - [转]无网络环境,在Windows Server 2008 R2和SQL Server 2008R2环境安装SharePoint2013 RT
			
无网络环境,在Windows Server 2008 R2和SQL Server 2008R2环境安装SharePoint2013 RT,这个还有点麻烦,所以记录一下,下次遇到省得绕弯路.进入正题: ...
 - Erlang tool -- recon
			
遇见recon 以来, 每次定位系统瓶颈, 总是能让我眼前一亮. 比如说, 定位非尾递归导致的内存暴涨, 定位引发CPU满载的进程.得心应手,每每额手称庆. recon 是ferd 大神 释出的一个 ...
 - Some index files failed to download. They have …… or old ones used instead
			
问题: 平台:Ubuntu12.04 W: Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/precise/universe/bin ...
 - 关于memcache分布式一致性hash
			
consistent hashing 算法早在 1997 年就在论文 Consistent hashing and random trees 中被提出,目前在 cache 系统中应用越来越广泛: 1 ...
 - asp.net 不用控件,自动登录(用于和其他系统对接的时候,自动登录系统,用户体验好)
			
if (System.Web.Security.Membership.ValidateUser("admin", "123456")) { //这句话很重要,他 ...
 - GridEh Lookup
			
Flexible adjustment of a lookup inplace editor 没有输入拼音码搜索功能. Drop-Down Forms 这个比较符合中国人的习惯,搜索框,不错,点下来箭 ...