CGContext - PDF边距

时间:2010-04-05 05:39:52

标签: iphone

我正在使用Quartz Sample:

使用此代码在视图上显示PDF内容
 // PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
 // before we start drawing.
 CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
 CGContextScaleCTM(context, 1.0, -1.0);

 // Grab the first PDF page
 CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNo);
 // We're about to modify the context CTM to draw the PDF page where we want it, so save the graphics state in case we want to do more drawing
 CGContextSaveGState(context);
 // CGPDFPageGetDrawingTransform provides an easy way to get the transform for a PDF page. It will scale down to fit, including any
 // base rotations necessary to display the PDF page correctly. 
 CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, self.bounds, 0, true);
 // And apply the transform.
 CGContextConcatCTM(context, pdfTransform);
 // Finally, we draw the page and restore the graphics state for further manipulations!
 CGContextDrawPDFPage(context, page);
 CGContextRestoreGState(context);

使用这一切都很好。我想设置PDF上下文的边距,默认情况下每边显示50 px的边距。我尝试过CGContext方法但没有得到合适的方法。有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

PDF并没有任何边距概念。如果您不是负责文档内容的人,那么您真正要做的就是缩小它。

答案 1 :(得分:0)

我在这里得到了答案

CGContext pdf page aspect fit