Create pixmap of page. Keyword args: matrix: Matrix for transformation (default: Identity). dpi: desired dots per inch. If given, matrix is ignored. colorspace: (str/Colorspace) cmyk, rgb, gray - case ignored, default csRGB. clip: (irect-like)
(
page: 'Page',
*,
matrix: matrix_like=Identity,
dpi=None,
colorspace: Colorspace=None,
clip: rect_like=None,
alpha: bool=False,
annots: bool=True,
)
| 11814 | return links |
| 11815 | |
| 11816 | def get_pixmap( |
| 11817 | page: 'Page', |
| 11818 | *, |
| 11819 | matrix: matrix_like=Identity, |
| 11820 | dpi=None, |
| 11821 | colorspace: Colorspace=None, |
| 11822 | clip: rect_like=None, |
| 11823 | alpha: bool=False, |
| 11824 | annots: bool=True, |
| 11825 | ) -> 'Pixmap': |
| 11826 | """Create pixmap of page. |
| 11827 | |
| 11828 | Keyword args: |
| 11829 | matrix: Matrix for transformation (default: Identity). |
| 11830 | dpi: desired dots per inch. If given, matrix is ignored. |
| 11831 | colorspace: (str/Colorspace) cmyk, rgb, gray - case ignored, default csRGB. |
| 11832 | clip: (irect-like) restrict rendering to this area. |
| 11833 | alpha: (bool) whether to include alpha channel |
| 11834 | annots: (bool) whether to also render annotations |
| 11835 | """ |
| 11836 | if colorspace is None: |
| 11837 | colorspace = csRGB |
| 11838 | if dpi: |
| 11839 | zoom = dpi / 72 |
| 11840 | matrix = Matrix(zoom, zoom) |
| 11841 | |
| 11842 | if type(colorspace) is str: |
| 11843 | if colorspace.upper() == "GRAY": |
| 11844 | colorspace = csGRAY |
| 11845 | elif colorspace.upper() == "CMYK": |
| 11846 | colorspace = csCMYK |
| 11847 | else: |
| 11848 | colorspace = csRGB |
| 11849 | if colorspace.n not in (1, 3, 4): |
| 11850 | raise ValueError("unsupported colorspace") |
| 11851 | |
| 11852 | dl = page.get_displaylist(annots=annots) |
| 11853 | pix = dl.get_pixmap(matrix=matrix, colorspace=colorspace, alpha=alpha, clip=clip) |
| 11854 | dl = None |
| 11855 | if dpi: |
| 11856 | pix.set_dpi(dpi, dpi) |
| 11857 | return pix |
| 11858 | |
| 11859 | def remove_rotation(self): |
| 11860 | """Set page rotation to 0 while maintaining visual appearance.""" |