MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / DocumentWriter

Class DocumentWriter

src/__init__.py:8134–8175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8132
8133
8134class DocumentWriter:
8135
8136 def __enter__(self):
8137 return self
8138
8139 def __exit__(self, *args):
8140 self.close()
8141
8142 def __init__(self, path, options=''):
8143 if isinstance( path, str):
8144 pass
8145 elif hasattr( path, 'absolute'):
8146 path = str( path)
8147 elif hasattr( path, 'name'):
8148 path = path.name
8149 if isinstance( path, str):
8150 self.this = mupdf.FzDocumentWriter( path, options, mupdf.FzDocumentWriter.PathType_PDF)
8151 else:
8152 # Need to keep the Python JM_new_output_fileptr_Output instance
8153 # alive for the lifetime of this DocumentWriter, otherwise calls
8154 # to virtual methods implemented in Python fail. So we make it a
8155 # member of this DocumentWriter.
8156 #
8157 # Unrelated to this, mupdf.FzDocumentWriter will set
8158 # self._out.m_internal to null because ownership is passed in.
8159 #
8160 out = JM_new_output_fileptr( path)
8161 self.this = mupdf.FzDocumentWriter( out, options, mupdf.FzDocumentWriter.OutputType_PDF)
8162 assert out.m_internal_value() == 0
8163 assert hasattr( self.this, '_out')
8164
8165 def begin_page( self, mediabox):
8166 mediabox2 = JM_rect_from_py(mediabox)
8167 device = mupdf.fz_begin_page( self.this, mediabox2)
8168 device_wrapper = DeviceWrapper( device)
8169 return device_wrapper
8170
8171 def close( self):
8172 mupdf.fz_close_document_writer( self.this)
8173
8174 def end_page( self):
8175 mupdf.fz_end_page( self.this)
8176
8177
8178class Font:

Callers 2

write_with_linksMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…