0

I am showing PDF content on a view using this code using Quartz Sample:

 // 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);

Using this all works fine. I want to set the margin for the PDF context, by default it showing 50 px margin in every side. I have tried CGContext methods but not got the appropriate one. Can anybody help me with this?

speeder
  • 6,197
  • 5
  • 34
  • 51
Amit Battan
  • 305
  • 3
  • 12

2 Answers2

0

PDFs don't really have any concept of margins. If you're not the one responsible for the document's content then all you can really do is scale it down.

Azeem.Butt
  • 5,855
  • 1
  • 26
  • 22
0

I got an answer for this here

CGContext pdf page aspect fit

Community
  • 1
  • 1
Anil Sivadas
  • 1,658
  • 3
  • 16
  • 26