Ejemplo n.º 1
0
def createPDFDocumentWithPath(path):
    return Quartz.CGPDFDocumentCreateWithURL(
        Quartz.CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
                                                       path, len(path), False))
Ejemplo n.º 2
0
def createOutputContextWithPath(path, dictarray):
    return Quartz.CGPDFContextCreateWithURL(
        Quartz.CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
                                                       path, len(path), False),
        None, dictarray)
Ejemplo n.º 3
0
                                                      Quartz.kCGPDFMediaBox)
                x = Quartz.CGRectGetWidth(mediaBox)
                y = Quartz.CGRectGetHeight(mediaBox)
                x *= scale
                y *= scale
                r = Quartz.CGRectMake(0, 0, x, y)
                # Create a Bitmap Context, draw a white background and add the PDF
                writeContext = Quartz.CGBitmapContextCreate(
                    None, int(x), int(y), 8, 0, cs, transparency)
                Quartz.CGContextSaveGState(writeContext)
                Quartz.CGContextScaleCTM(writeContext, scale, scale)
                Quartz.CGContextSetFillColorWithColor(writeContext, whiteColor)
                Quartz.CGContextFillRect(writeContext, r)
                Quartz.CGContextDrawPDFPage(writeContext, page)
                Quartz.CGContextRestoreGState(writeContext)
                # Convert to an "Image"
                image = Quartz.CGBitmapContextCreateImage(writeContext)
                # Create unique filename per page
                outFile = folderName + "/" + prefix + " %03d.png" % i
                url = Quartz.CFURLCreateFromFileSystemRepresentation(
                    kCFAllocatorDefault, outFile, len(outFile), False)
                # kUTTypeJPEG, kUTTypeTIFF, kUTTypePNG
                type = kUTTypePNG
                # See the full range of image properties on Apple's developer pages.
                options = {
                    Quartz.kCGImagePropertyDPIHeight: resolution,
                    Quartz.kCGImagePropertyDPIWidth: resolution
                }
                writeImage(image, url, type, options)
                del page