qrdm.encode_qr_pdf¶
- qrdm.encode_qr_pdf(document_content: str, *, path: None = None, header_text: str = '', metadata: JsonValue | None = None, document_name: str | None = None, encode_ec_codes: bool = True, error_tolerance: str | ECSettingValues = None, include_text: bool = False, include_timestamp: bool = True) bytes[source]¶
- qrdm.encode_qr_pdf(document_content: str, *, path: str | Path | BufferedIOBase = None, header_text: str = '', metadata: JsonValue | None = None, document_name: str | None = None, encode_ec_codes: bool = True, error_tolerance: str | ECSettingValues = None, include_text: bool = False, include_timestamp: bool = True) None
Convert a plaintext document to a PDF containing the document encoded as QR codes.
- Parameters:
document_content (str) – Document to be QR-encoded, as a python string.
path (str, path object, file-like object, or
None, optional) – String, path object (implementing os.PathLike[str]), or file-like object implementing a binary write() function. If None, the result is returned as bytes. Defaults toNone.header_text (str, optional) – Text to include as header & footer of QR PDF. Defaults to
"".metadata (JsonValue, optional) – JSON-encodable data that is encoded alongside the document contents in the QR PDF. (I.e. may be a JSON-scalar
[str|bool|int|float]or adict[str, JsonValue])document_name (str, optional) – Name of the original file or document, to label output PDF.
encode_ec_codes (bool, optional) – Whether to include additional error-correcting QR codes. These are useful when individual QR codes fail to scan.
error_tolerance (One of
"LOW", "MEDIUM", "QUARTILE", "HIGH", optional) – Error correction level of the individual QR codes. Defaults to"MEDIUM".include_text (bool, optional) – Whether to print the plaintext document content underneath the QR codes. Defaults to
False(opt-in) to preserve privacy.include_timestamp (bool, optional) – Whether to include the UTC render timestamp in the page footer. Set to
Falsefor deterministic PDF output. Defaults toTrue.minimal_mode (bool, optional) – When
True, print only filename, hash, and page numbers — no footer text or caption. Forcesinclude_text=Falseandinclude_timestamp=False. Defaults toFalse.
- Return type:
File data as bytes if the
pathargument is not provided, otherwiseNone.
Examples
>>> file_data = qrdm.encode_qr_pdf("This returns bytes directly", path=None) >>> qrdm.encode_qr_pdf("This is being written directly to a file", path="qr.pdf") >>> with open("stream.pdf", "wb") as f: ... qrdm.encode_qr_pdf("This is being written to a file-like stream", path=f)