I am using Ubuntu 22.04 LTS
I wanted to convert .rtf files to PDFs using Python.
I found this on stackoverflow:
import pypandoc
def convert_rtf_to_pdf(input_rtf, output_pdf):
pypandoc.convert_file(input_rtf, 'pdf', outputfile=output_pdf)
if __name__ == "__main__":
input_rtf_path = "Path to your RTF File"
output_pdf_path = "path to your pdf file output with name /output.pdf"
convert_rtf_to_pdf(input_rtf_path, output_pdf_path)
But I get this error:
RuntimeError: Invalid input format! Got "rtf" but expected one of these: commonmark, creole, csv, docbook, docx, dokuwiki, epub, fb2, gfm, haddock, html, ipynb, jats, jira, json, latex, man, markdown, markdown_github, markdown_mmd, markdown_phpextra, markdown_strict, mediawiki, muse, native, odt, opml, org, rst, t2t, textile, tikiwiki, twiki, vimwiki
Can I somehow add .rtf files to Ubuntu pandoc, then convert them to PDF?
Looking further, I found this, which shows rtf is available:
print(pypandoc.get_pandoc_formats())
(['commonmark', 'creole', 'csv', 'docbook', 'docx', 'dokuwiki', 'epub', 'fb2', 'gfm', 'haddock', 'html', 'ipynb', 'jats', 'jira', 'json', 'latex', 'man', 'markdown', 'markdown_github', 'markdown_mmd', 'markdown_phpextra', 'markdown_strict', 'mediawiki', 'muse', 'native', 'odt', 'opml', 'org', 'rst', 't2t', 'textile', 'tikiwiki', 'twiki', 'vimwiki'], ['asciidoc', 'asciidoctor', 'beamer', 'commonmark', 'context', 'docbook', 'docbook4', 'docbook5', 'docx', 'dokuwiki', 'dzslides', 'epub', 'epub2', 'epub3', 'fb2', 'gfm', 'haddock', 'html', 'html4', 'html5', 'icml', 'ipynb', 'jats', 'jats_archiving', 'jats_articleauthoring', 'jats_publishing', 'jira', 'json', 'latex', 'man', 'markdown', 'markdown_github', 'markdown_mmd', 'markdown_phpextra', 'markdown_strict', 'mediawiki', 'ms', 'muse', 'native', 'odt', 'opendocument', 'opml', 'org', 'pdf', 'plain', 'pptx', 'revealjs', 'rst', 'rtf', 's5', 'slideous', 'slidy', 'tei', 'texinfo', 'textile', 'xwiki', 'zimwiki'])