My problem was that text substituted in PDF document properties title
and author is not ASCII in my language.
template invoice.rml
... title={% trans "Store Invoice" %}
author={{ shopDetails.store_name }}
Code in trml2pdf for other tags in PDF body is not so sensitive as for
the tag <template ...> in the RML header. In my experience it works
well also with UTF-8 coding and it is not necessary restrict it to
ASCII. My PDF reader displays document properties correctly, although
they are in Latin-2 subset of UTF-8.
You can try this patch.
--- a/trml2pdf/utils.py 2004-02-24 15:18:46.000000000 +0100
+++ b/trml2pdf/utils.py 2011-01-19 02:44:39.000000000 +0100
for key in dict:
if node.hasAttribute(key):
if dict[key]=='str':
- res[key] = str(node.getAttribute(key))
+ val = node.getAttribute(key)
+ if not isinstance(val, unicode):
+ res[key] = str(val)
+ else:
+ res[key] = val.encode('utf-8')
elif dict[key]=='bool':
res[key] =
bool_get(node.getAttribute(key))
elif dict[key]=='int':
If you do not beleive my patch using UTF in properties, you can remove
"title" and "author" atributes from teplate header or replace them by
any ASCII text.
It is better not to support an old viewer prtly (not tested) than to
suppress anything to anybody.
---
For the next part you need freetype support.
I am from middle Europe (Česká republika - see the "Č" - encoding
Latin-2). "Helvetica" and "Times-Roman" are not enough for this "Č". I
copied several international fonts into .../site-packages/reportlab/
fonts directory and modified the default font assignment in the
template to display also the body correctly.
--- file invoice.rml ---
...
<document filename="{{ filename }}">
+ <docinit>
+ <registerFont fontName="Times-Roman"
fontFile="Times_New_Roman.ttf"/>
+ <registerFont fontName="Arial" fontFile="Arial.ttf"/>
+ <registerFont fontName="Arial-Bold" fontFile="Arial_Bold.ttf"/
>
+ <registerFont fontName="Arial-Italic"
fontFile="Arial_Italic.ttf"/>
+ <registerFont fontName="Arial-Bold-Italic"
fontFile="Arial_Bold_Italic.ttf"/>
+ </docinit>
- <template pageSize="(21.5cm, 28cm)" ... (reduced here)
+ <template pageSize="(21cm, 29.7cm)" ... (reduced here)
(changed from Letter to A4 format)
Times-Roman is the default font used for texts without explicitely
assigned font in the template.
and some examples
- <paraStyle name="name" fontName="Helvetica-Bold" fontSize="12"/>
+ <paraStyle name="name" fontName="Arial-Bold" fontSize="12"/>
- <blockFont name="Helvetica-BoldOblique" size="12" start="0,0"
stop="-1,0"/>
+ <blockFont name="Arial-Bold-Italic" size="12" start="0,0"
stop="-1,0"/>
Used characters glyphs are now automatically copied from font to PDF
and fonts need not to be installed on the end user's computer.
Copyright? My installed linux font pack has half smaller files and
probably simpler fonts than Windows.
I doubt that Microsoft has a copyright for the word "New" itself in
the name "Times New Roman".
This guide is alterable for different fonts with no MS names.
What was your problem? Sent pastebin link is outdated now and no other
info.
Hynek
On 12 pro 2010, 23:09, Peter Halliday <[email protected]>
wrote:
> Trying to print the PDF for Invoices, I'm getting the following error.
>
> http://pastebin.com/eUMALikJ
>
> I have DEFAULT_CHARSET equal to utf-8. I have PIL compiled also with both
> image support, but not freetype support. Not sure if that's it.
>
> Peter Halliday
> Excelsior Systems
> (Phone:) 607-428-2527 x101
> (Fax:) 888-265-5082
--
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en.