/usr/share/doc/python-pyth/examples/writing/pdf.py is in python-pyth 0.5.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # -*- coding: utf-8 -*-
from pyth.plugins.rtf15.reader import Rtf15Reader
from pyth.plugins.pdf.writer import PDFWriter
doc = Rtf15Reader.read(open("../reading/sample.rtf"))
fontfile = "/usr/share/fonts/truetype/msttcorefonts/Times_New_Roman%s.ttf"
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.pdfbase.pdfmetrics import registerFont, registerFontFamily
from reportlab.pdfbase.ttfonts import TTFont
registerFont(TTFont('TimesTTF', fontfile % ""))
registerFont(TTFont('TimesTTF_B', fontfile % "_Bold"))
registerFont(TTFont('TimesTTF_I', fontfile % "_Italic"))
registerFont(TTFont('TimesTTF_BI', fontfile % "_Bold_Italic"))
registerFontFamily("TimesTTF", normal="TimesTTF", bold="TimesTTF_B", italic="TimesTTF_I", boldItalic="TimesTTF_BI")
stylesheet = getSampleStyleSheet()
paragraphStyle = stylesheet['Normal']
paragraphStyle.fontName = "TimesTTF"
PDFWriter.write(doc, open("output.pdf", "wb"), paragraphStyle)
|