The export module¶
Export Pages to different file formats.
-
class
AbstractExporter
(page, rect=None)[source]¶ Bases:
object
Base class to export a rectangular area of a Page to a file.
Specialized subclasses implement each format.
You instantiate a subclass with a Page and a rectangle. The rectangle may be None, to specify the full page. After instantiation, you can set attributes to configure the export. The following attributes are supported:
resolution = 300 autocrop = False oversample = 1 grayscale = False paperColor = None forceVector = True # force the render backend to be Arthur for # exporting PDF pages to vector-based formats
After setting the attributes, you call one or more of save(), copyData(), copyFile(), mimeData() or tempFileMimeData(), which will trigger the export because they internally call data(), which caches its return value until setPage() is called again.
Not all exporters support all attributes, the supportXXX attributes specify whether an attribute is supported or not.
-
resolution
= 300¶
-
antialiasing
= True¶
-
autocrop
= False¶
-
oversample
= 1¶
-
grayscale
= False¶
-
paperColor
= None¶
-
forceVector
= True¶
-
wantsVector
= True¶
-
supportsResolution
= True¶
-
supportsAntialiasing
= True¶
-
supportsAutocrop
= True¶
-
supportsOversample
= True¶
-
supportsGrayscale
= True¶
-
supportsPaperColor
= True¶
-
mimeType
= 'application/octet-stream'¶
-
filename
= ''¶
-
defaultBasename
= 'document'¶
-
defaultExt
= ''¶
-
document
()[source]¶ Return a one-page Document to display the image to export.
Internally calls createDocument(), and caches the result, setting the papercolor to the papercolor attribute if the exporter supports papercolor.
-
suggestedFilename
()[source]¶ Return a suggested file name for the file to export.
The name is based on the filename (if set) and also contains the directory path. But the name will never be the same as the filename set in the filename attribute.
-
-
class
ImageExporter
(page, rect=None)[source]¶ Bases:
qpageview.export.AbstractExporter
Export a rectangular area of a Page (or the whole page) to an image.
-
wantsVector
= False¶
-
defaultBasename
= 'image'¶
-
defaultExt
= '.png'¶
-
-
class
SvgExporter
(page, rect=None)[source]¶ Bases:
qpageview.export.AbstractExporter
Export a rectangular area of a Page (or the whole page) to a SVG file.
-
mimeType
= 'image/svg'¶
-
supportsGrayscale
= False¶
-
supportsOversample
= False¶
-
defaultBasename
= 'image'¶
-
defaultExt
= '.svg'¶
-
-
class
PdfExporter
(page, rect=None)[source]¶ Bases:
qpageview.export.AbstractExporter
Export a rectangular area of a Page (or the whole page) to a PDF file.
-
mimeType
= 'application/pdf'¶
-
supportsGrayscale
= False¶
-
supportsOversample
= False¶
-
defaultExt
= '.pdf'¶
-
-
class
EpsExporter
(page, rect=None)[source]¶ Bases:
qpageview.export.AbstractExporter
Export a rectangular area of a Page (or the whole page) to an EPS file.
-
mimeType
= 'application/postscript'¶
-
supportsGrayscale
= False¶
-
supportsOversample
= False¶
-
defaultExt
= '.eps'¶
-
-
pdf
(filename, pageList, resolution=72, paperColor=None)[source]¶ Export the pages in pageList to a PDF document.
filename can be a string or any QIODevice. The pageList is a list of the Page objects to export.
Normally vector graphics are rendered, but in cases where that is not possible, the resolution will be used to determine the DPI for the generated rendering.
The computedRotation attribute of the pages is used to determine the rotation.
Make copies of the pages if you run this function in a background thread.