第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

iOS SDK-以編程方式生成PDF文件

iOS SDK-以編程方式生成PDF文件

iOS
Qyouu 2019-10-24 10:13:08
坦白地說(shuō),在以編程方式繪制PDF文件時(shí),使用CoreGraphics框架是一項(xiàng)繁瑣的工作。我想以編程方式創(chuàng)建PDF,使用整個(gè)應(yīng)用程序視圖中的各種對(duì)象。我很想知道iOS SDK是否有不錯(cuò)的PDF教程,也許是庫(kù)中的一個(gè)。我看過(guò)本教程PDF Creation Tutorial,但是它主要是用C編寫的。尋找更多的Objective-C風(fēng)格。這似乎是寫入PDF文件的一種荒謬方法,必須計(jì)算線和其他對(duì)象的放置位置。void CreatePDFFile (CGRect pageRect, const char *filename) {       // This code block sets up our PDF Context so that we can draw to it    CGContextRef pdfContext;    CFStringRef path;    CFURLRef url;    CFMutableDictionaryRef myDictionary = NULL;    // Create a CFString from the filename we provide to this method when we call it    path = CFStringCreateWithCString (NULL, filename,                                      kCFStringEncodingUTF8);    // Create a CFURL using the CFString we just defined    url = CFURLCreateWithFileSystemPath (NULL, path,                                         kCFURLPOSIXPathStyle, 0);    CFRelease (path);    // This dictionary contains extra options mostly for 'signing' the PDF    myDictionary = CFDictionaryCreateMutable(NULL, 0,                                             &kCFTypeDictionaryKeyCallBacks,                                             &kCFTypeDictionaryValueCallBacks);    CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("My PDF File"));    CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("My Name"));    // Create our PDF Context with the CFURL, the CGRect we provide, and the above defined dictionary    pdfContext = CGPDFContextCreateWithURL (url, &pageRect, myDictionary);    // Cleanup our mess    CFRelease(myDictionary);    CFRelease(url);    // Done creating our PDF Context, now it's time to draw to it    // Starts our first page    CGContextBeginPage (pdfContext, &pageRect);    // Draws a black rectangle around the page inset by 50 on all sides    CGContextStrokeRect(pdfContext, CGRectMake(50, 50, pageRect.size.width - 100, pageRect.size.height - 100));
查看完整描述

3 回答

?
大話西游666

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊

iOS上的PDF函數(shù)都是基于CoreGraphics的,這是有道理的,因?yàn)閕OS中的繪制基元也是基于CoreGraphics的。如果要直接將2D基本體渲染到PDF中,則必須使用CoreGraphics。


UIKit中也存在一些對(duì)象的快捷方式,例如圖像。將PNG繪制到PDF上下文仍然需要調(diào)用CGContextDrawImage,但是您可以使用可以從UIImage獲取的CGImage來(lái)實(shí)現(xiàn),例如:


UIImage * myPNG = [UIImage imageNamed:@"mypng.png"];

CGContextDrawImage (pdfContext, CGRectMake(200, 200, 207, 385), [myPNG CGImage]);

如果您需要有關(guān)總體設(shè)計(jì)的更多指導(dǎo),請(qǐng)更明確地說(shuō)明“整個(gè)應(yīng)用程序中的各種對(duì)象”的含義以及您要實(shí)現(xiàn)的目標(biāo)。


查看完整回答
反對(duì) 回復(fù) 2019-10-24
  • 3 回答
  • 0 關(guān)注
  • 782 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)