2. Завантажити і встановити https://github.com/roadhead/trml2pdf
3. Завантажити шрифти http://dejavu-fonts.org/wiki/Download
4. Вивчити мову розмітки документів http://www.reportlab.com/docs/rml-for-idiots.pdf, http://www.reportlab.com/docs/rml2pdf-userguide.pdf
5. Зразки готових бугалтерських документів в rml http://bazaar.launchpad.net/~openerp-russian/openerp-russian/openerp-l10n-ru/files/head:/openerp_russia/report/?file_id=openerp_russia-20110224092448-memzsvkru6fipv4y-1
болванка документа
<?xml version="1.0" encoding="utf-8" standalone="no" ?><!DOCTYPE document SYSTEM "rml_1_0.dtd"><document filename="example_4.pdf"><template><pageTemplate id="main"><pageGraphics><image file="pict/1.png" x="0" y="0" width="550"/><setFont name="DejaVuSans" size="16"/><drawString x="100" y="700">Using RML with a templating system.</drawString></pageGraphics><fill color="black"/><frame id="first" x1="110mm" y1="190mm" width="80mm" height="80mm"/><frame id="second" x1="27mm" y1="139mm" width="163mm" height="42mm"/><frame id="trois" x1="27mm" y1="37mm" width="75mm" height="90mm"/><frame id="quatre" x1="112mm" y1="96mm" width="82mm" height="34mm"/><frame id="cinq" x1="112mm" y1="36mm" width="82mm" height="37mm"/></pageTemplate></template><stylesheet><paraStyle name="bigurl" fontName="DejaVuSans" fontSize="12" spaceBefore="0.5cm" textColor="red"/></stylesheet><story><para style="bigurl">тест тест тест</para></story></document>скріпт конвертації
import trml2pdffrom reportlab.pdfbase import pdfmetricsfrom reportlab.pdfbase.ttfonts import TTFontenc = 'UTF-8'pdfmetrics.registerFont(TTFont('DejaVuSans', 'DejaVuSans.ttf',enc))pdfmetrics.registerFont(TTFont('DejaVuSans-Bold', 'DejaVuSans-Bold.ttf',enc))open('/opt/kasta/test.pdf', 'w').write(trml2pdf.parseString(file('doc.rml','r').read()))
No comments:
Post a Comment