Skip to content

comicbox.formats.pdf.schema

Mimic comicbox.Comicbox functions for PDFs.

MuPDFSchema

Bases: JsonSchema

muPDFSchema.

Source code in comicbox/formats/pdf/schema.py
39
40
41
42
43
44
45
class MuPDFSchema(JsonSchema):
    """muPDFSchema."""

    ROOT_TAG: str = "MuPDF"
    ROOT_KEYPATH: str = ROOT_TAG

    MuPDF = Nested(MuPDFSubSchema)

MuPDFSubSchema

Bases: JsonSubSchema

muPDF Sub Schema.

Source code in comicbox/formats/pdf/schema.py
25
26
27
28
29
30
31
32
33
34
35
36
class MuPDFSubSchema(JsonSubSchema):
    """muPDF Sub Schema."""

    # https://pymupdf.readthedocs.io/en/latest/document.html#Document.metadata

    author = StringSetField(as_string=True)
    creator = StringField()
    keywords = StringSetField(as_string=True)
    modDate = PdfDateTimeField()  # noqa: N815
    producer = StringField()
    subject = StringSetField(as_string=True)
    title = StringField()

PDFRDFDescriptionSchema

Bases: XmlSubSchema

PDF RDF Description Schema.

Source code in comicbox/formats/pdf/schema.py
68
69
70
71
72
73
74
75
76
77
78
79
class PDFRDFDescriptionSchema(XmlSubSchema):
    """PDF RDF Description Schema."""

    class Meta(XmlSubSchema.Meta):
        """Schema options."""

        include = MappingProxyType(
            {
                "@xmlns:rdf": Constant("http://www.w3.org/1999/02/22-rdf-syntax-ns"),
                "rdf:Description": Nested(PDFSubSchema),
            },
        )

Meta

Bases: Meta

Schema options.

Source code in comicbox/formats/pdf/schema.py
71
72
73
74
75
76
77
78
79
class Meta(XmlSubSchema.Meta):
    """Schema options."""

    include = MappingProxyType(
        {
            "@xmlns:rdf": Constant("http://www.w3.org/1999/02/22-rdf-syntax-ns"),
            "rdf:Description": Nested(PDFSubSchema),
        },
    )

PDFSubSchema

Bases: BaseSubSchema

PDF Data Sub Schema.

Source code in comicbox/formats/pdf/schema.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class PDFSubSchema(BaseSubSchema):
    """PDF Data Sub Schema."""

    class Meta(BaseSubSchema.Meta):
        """Schema options."""

        include = MappingProxyType(
            {
                "@xmlns:pdf": Constant("http://ns.adobe.com/pdf/1.3/"),
                "pdf:Author": XmlStringSetField(as_string=True),
                "pdf:Creator": XmlStringField(),
                "pdf:Keywords": XmlStringSetField(as_string=True),
                "pdf:ModDate": XmlPdfDateTimeField(),
                "pdf:Producer": XmlStringField(),
                "pdf:Subject": XmlStringSetField(as_string=True),
                "pdf:Title": XmlStringField(),
            }
        )

Meta

Bases: Meta

Schema options.

Source code in comicbox/formats/pdf/schema.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class Meta(BaseSubSchema.Meta):
    """Schema options."""

    include = MappingProxyType(
        {
            "@xmlns:pdf": Constant("http://ns.adobe.com/pdf/1.3/"),
            "pdf:Author": XmlStringSetField(as_string=True),
            "pdf:Creator": XmlStringField(),
            "pdf:Keywords": XmlStringSetField(as_string=True),
            "pdf:ModDate": XmlPdfDateTimeField(),
            "pdf:Producer": XmlStringField(),
            "pdf:Subject": XmlStringSetField(as_string=True),
            "pdf:Title": XmlStringField(),
        }
    )

PDFXMPMetaSchema

Bases: XmlSubHeadSchema

PDF XMP Meta Schema.

Source code in comicbox/formats/pdf/schema.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class PDFXMPMetaSchema(XmlSubHeadSchema):
    """PDF XMP Meta Schema."""

    class Meta(XmlSubHeadSchema.Meta):
        """Schema options."""

        NS = "x"
        NS_URI = "adobe:ns:meta/"
        XSD_URI = "http://ns.adobe.com/pdf/1.3/"

        include = MappingProxyType(
            {
                **create_xml_headers(NS, NS_URI, XSD_URI),
                "@x:xmptk": Constant(
                    "Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21"
                ),
                "rdf:RDF": Nested(PDFRDFDescriptionSchema),
            }
        )

Meta

Bases: Meta

Schema options.

Source code in comicbox/formats/pdf/schema.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class Meta(XmlSubHeadSchema.Meta):
    """Schema options."""

    NS = "x"
    NS_URI = "adobe:ns:meta/"
    XSD_URI = "http://ns.adobe.com/pdf/1.3/"

    include = MappingProxyType(
        {
            **create_xml_headers(NS, NS_URI, XSD_URI),
            "@x:xmptk": Constant(
                "Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21"
            ),
            "rdf:RDF": Nested(PDFRDFDescriptionSchema),
        }
    )

PDFXmlSchema

Bases: XmlSchema

PDF Schema.

Source code in comicbox/formats/pdf/schema.py
103
104
105
106
107
108
109
110
111
112
class PDFXmlSchema(XmlSchema):
    """PDF Schema."""

    ROOT_TAG: str = "x:xmpmeta"
    ROOT_KEYPATH: str = f"{ROOT_TAG}.rdf:RDF.rdf:Description"

    class Meta(XmlSchema.Meta):
        """Schema options."""

        include = MappingProxyType({"x:xmpmeta": Nested(PDFXMPMetaSchema)})

Meta

Bases: Meta

Schema options.

Source code in comicbox/formats/pdf/schema.py
109
110
111
112
class Meta(XmlSchema.Meta):
    """Schema options."""

    include = MappingProxyType({"x:xmpmeta": Nested(PDFXMPMetaSchema)})