def render_shape_to_disk(self, shape): r = shape.getShapeRenderer() # Define custom options which control how the image is rendered. Render the shape to the JPEG raster format. imageOptions = ImageSaveOptions(SaveFormat.JPEG) imageOptions.setScale(1.5) # Save the rendered image to disk. r.save(self.dataDir + "TestFile.RenderToDisk Out.jpg", imageOptions) print "Shape rendered to disk successfully."
def render_shape_to_stream(self, shape): r = shape.getShapeRenderer() # Define custom options which control how the image is rendered. Render the shape to the png raster format. imageOptions = ImageSaveOptions(SaveFormat.PNG) # Output the image in gray scale imageOptions.setImageColorMode(ImageColorMode.GRAYSCALE) # Reduce the brightness a bit (default is 0.5f). imageOptions.setImageBrightness(0.45) stream = FileOutputStream(self.dataDir + "TestFile.RenderToStream Out.jpg") # Save the rendered image to the stream using different options. r.save(stream, imageOptions) print "Shape rendered to stream successfully."
def __init__(self): dataDir = Settings.dataDir + 'rendering_printing/' # Open the document. doc = Document(dataDir + "TestFile.doc") # Save the document as multipage TIFF. doc.save(dataDir + "TestFile Out.tiff") # Create an ImageSaveOptions object to pass to the Save method options = ImageSaveOptions(SaveFormat.TIFF) options.setPageIndex(0) options.setPageCount(2) options.setTiffCompression(TiffCompression.CCITT_4) options.setResolution(160) doc.save(dataDir + "TestFileWithOptions Out.tiff", options) "Document saved as multi page TIFF successfully."