cgpdfdocument

swift CGPDFDocument parsing

99封情书 提交于 2020-02-23 04:16:28
问题 I'm trying to use Swift to parse the contents of PDF documents, following Apple's programming guide (in which all the examples are ObjC...) let filepath = "/Users/ben/Desktop/Test.pdf" let localUrl = filepath as CFString if let pdfURL = CFURLCreateWithFileSystemPath(nil, localUrl, CFURLPathStyle.cfurlposixPathStyle, false) { if let pdf = CGPDFDocument(pdfURL) { if let inf = pdf.info { CGPDFDictionaryApplyFunction(inf, { (key, object, info) -> Void in print("\(key), \(object), \(info)") }, nil

iPhone/iPad draw pdf like iBooks?

这一生的挚爱 提交于 2020-01-01 18:05:10
问题 Does anyone know how to use core graphics to draw a pdf like in iBooks. I can already draw a pdf page using core graphics but was curious how iBooks shows a lower quality view of each page so it loads fast and then when you stay on a page longer it renders it a full quality. This makes it able to open the pdf without having to make the user wait like most magazine apps you see on ipad. Any ideas would help! 回答1: Apple have some "ZoomingPDFViewer" sample code: http://developer.apple.com

CGContextDrawPDFPage crashing without ever producing a memory warning

╄→尐↘猪︶ㄣ 提交于 2019-12-24 07:39:29
问题 I'm trying to render a PDF page with some annotations on it (to email), and most of the time this works fine. However, with this PDF in particular it seems to crash every time on the call to CGContextDrawPDFPage for the first page. I have added CGContextSetInterpolationQuality(context, kCGInterpolationHigh); CGContextSetRenderingIntent(context, kCGRenderingIntentDefault); as a recommendation from CGContextDrawPDFPage taking up large amounts of memory but that did not seem to solve my issue. I

In iOS, using CGPDFDocumentRef, why is my PDF showing big margins and not the whole page? [duplicate]

断了今生、忘了曾经 提交于 2019-12-24 04:53:25
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: how to fit pdf page in entire view I am showing with no problem a PDF, however, the original PDF does not have the big margins shown at the moment I compile the App. My code: In the H File: @interface viewPDF : UIView { CGPDFDocumentRef document; } In the M file: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:(CGRect)frame]; if (self) { self.backgroundColor = [UIColor clearColor]; NSString

How to display a PDF document that includes hyperlinks? (on iOS)

女生的网名这么多〃 提交于 2019-12-21 23:24:03
问题 The Situation: I have a pdf document that includes hyperlinks. I would like my iPhone app to display this pdf document, and enable clicking of the hyperlinks. Note: Currently, I am trying to do this with a UIWebView, which unfortunately seems unable to detect link taps. There is a family of classes & methods called CGPDF which I have read about in the documentation. The documentation talks all about parsing pdf documents and what not but is not specific on how to detect link taps and what not

Get CGPDFDocumentRef name of document

帅比萌擦擦* 提交于 2019-12-21 05:08:14
问题 Is it possible to retrieve the name of a document from a CGPDFDocumentRef 回答1: By "name of a document", do you mean the document filename or title? If the document "title" is included in the metadata it can be retrieved like this: char *titleKey = "Title"; CGPDFStringRef titleStringRef; CGPDFDictionaryRef info = CGPDFDocumentGetInfo(myDocumentRef); CGPDFDictionaryGetString(info, titleKey, &titleStringRef); const unsigned char *titleCstring = CGPDFStringGetBytePtr(titleStringRef); printf(

How to access hyperlinks in PDF documents (iPhone)?

天大地大妈咪最大 提交于 2019-12-18 15:40:10
问题 Is it possible to get access to "internal" links in PDF documents using CGPDFDocument , or other means? I'm building a simple reader app and would like to deliver my content in PDF form, but if I can't support links between pages in the doc this probably isn't going to work. This question is similar, but does not address the issue of how to support hyperlinks. 回答1: See my answer here. Basically, you'll need to get familiar with PDF link annotations. 回答2: see this sample code...pdf hyperlinks

Rendering a CGPDFPage into a UIImage

只谈情不闲聊 提交于 2019-12-17 17:59:19
问题 I'm trying to render a CGPDFPage (selected from a CGPDFDocument) into a UIImage to display on a view. I have the following code in MonoTouch which gets me part way there. RectangleF PDFRectangle = new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); public override void ViewDidLoad () { UIGraphics.BeginImageContext(new SizeF(PDFRectangle.Width, PDFRectangle.Height)); CGContext context = UIGraphics.GetCurrentContext(); context.SaveState(); CGPDFDocument

iOS CGPdf highlight text using CGrect

折月煮酒 提交于 2019-12-11 21:15:59
问题 I am trying to highlight text using rect but the code below: CGRect originalSize = CGPDFPageGetBoxRect(pagePDFRef, kCGPDFMediaBox); return me rect less then I expected or maybe less then I see. Is there any already made method that highlight text using scanner and CGRect 来源: https://stackoverflow.com/questions/23920377/ios-cgpdf-highlight-text-using-cgrect

iOS How to get all words coordinates in PDF page

随声附和 提交于 2019-12-11 20:59:18
问题 I have looked through many tutorials and usually stack users trow links to the pdfkitten, but as I've tested it I have not satisfied with result. So the search does not work with multiply word and etc. So what I am looking for I need to get all words from the pdf page and highlight it if the words cross some rectangle. 回答1: I used PDFKitten for the same. What I did was while scanning the PDF - Identify the words separated by spaces. Save the RenderingState(Model in PDFKitten code)word is