JelteF / PyLaTeX

A Python library for creating LaTeX files
https://jeltef.github.io/PyLaTeX/
MIT License
2.24k stars 287 forks source link

PDF/A #344

Open artel1992 opened 2 years ago

artel1992 commented 2 years ago

Hello, i try create pdf using your cool library. But I get some problem with standart. I need add this string to preamble

\usepackage[a-2b,mathxmp]{pdfx}[2018/12/22]

but in generated tex file I get this:

\usepackage[a{-}2b,mathxmp]{pdfx}[2018/12/22]

What do I wrong? and I don't understand how to add filecontents like this:

\begin{filecontents*}[overwrite]{\jobname.xmpdata}
    \Title{Document’s title}
    \Author{Author’s name}
    \Language{en-GB}
    \Subject{The abstract or short description.}
    \Keywords{keyword1\sep keyword2\sep keyword3}
\end{filecontents*}

my code

 def generate_tex_document(self) -> Document:
        doc = Document(default_filepath=str(self.file_directory / self.file_name),
                       documentclass=Command('documentclass', options='a4paper', arguments='article'))
        doc.preamble.append(Command('usepackage', options='russian', arguments='babel'))
        doc.preamble.append(Command('usepackage', arguments='pdfx', options=['a-2b', 'mathxmp'])) 
        # or doc.preamble.append(NoEscape(r'\usepackage[a-2b,mathxmp]{pdfx}[2018/12/22]'))
        doc.preamble.append(Command('usepackage', arguments='digsig, blindtext, hhline, tabularx, array'))

        doc.preamble.append(NoEscape(r'\renewcommand{\rmdefault}{cmss}%'))
        if self.subject.type_id == 3 or self.subject.type_id == 5:
            doc.preamble.append(NoEscape(
                r'\usepackage[a4paper,landscape, total={25cm, 21cm},left=2cm,top=0.5cm,right=0.5cm,bottom=0.5cm]{geometry}%'))
        else:
            doc.preamble.append(NoEscape(
                r'\usepackage[a4paper, total={20cm, 28cm}, left=2cm,top=0.5cm,right=0.5cm,bottom=0.5cm]{geometry}%'))
        doc.preamble.append(Command('hypersetup', arguments='pdfstartview='))
        return doc
artel1992 commented 2 years ago

I'm sorry this work

 doc.preamble.append(NoEscape(r'\usepackage[a-2b,mathxmp]{pdfx}[2018/12/22]'))
artel1992 commented 2 years ago

How I can add filecontents ?