template 'regular' and MS Word generated HTML

88 views
Skip to first unread message

MaDeuce

unread,
Feb 26, 2012, 9:11:21 PM2/26/12
to Pisa XHTML2PDF Support
I am new to xhtml2pdf and hope to be able to use it for bulk
conversion of html to pdf. I have two newb questions...

1) After installing via pip in a virtualenv, I attempted to convert
pisa-en.html to pdf via: 'xhtml2pdf pisa-en.html'. Doing so produces
an exception:
"ValueError: can't find template('regular')".
The exception goes away and PDF is produced if I edit pisa-en.html and
remove the line containing '<pdf:nexttemplate name="regular"/>'.
What am I missing here?

2) My goal is to be able to convert HTML that was created by MS Word.
I know that's disgusting, but they are legacy files and have to be
converted. I get errors on these as well, I assume having to do with
font incompatibility. For example:
File "/Users/khe/.virtualenvs/pat/lib/python2.7/site-packages/
xhtml2pdf/context.py", line 170, in atFontFace
src = self.c.getFile(data["src"])
KeyError: 'src'

I don't mind spending the time to dig in and find out what's going
on. However, before doing so, I'd really appreciate it if someone
familiar with xhtml2pdf could weigh in and let me know the ultimate
goal is reasonable or not. I'd hate to spend a couple of days on it,
only to find out that the MS generated HTML is hopeless.

Thanks very much,
--Ma

Thiago Sousa Santos

unread,
Feb 4, 2014, 11:24:22 PM2/4/14
to xhtm...@googlegroups.com
Any updates here?

I'm having the same issue, it seems it fails because it appends:

@font-face {font-family:'Courier New'; panose-1:2 7 3 9 2 2 5 2 4 4;}@font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; font-size:11.0pt; font-family:Calibri;}@page WordSection1 {size:595.3pt 841.9pt; margin:70.85pt 3.0cm 70.85pt 3.0cm;}div.WordSection1 {page:WordSection1;} ol {margin-bottom:0cm;}ul {margin-bottom:0cm;}

To the end of my CSS and that fails as the @font-face have no src property.

--
Thiago
 

Thanks very much,
--Ma

Philippe Raoult

unread,
Feb 5, 2014, 3:42:50 PM2/5/14
to xhtm...@googlegroups.com
You need the src attribute because xhtmltopdf will load the fonts to
properly render the file.
> --
> You received this message because you are subscribed to the Google Groups
> "Pisa XHTML2PDF Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to xhtml2pdf+...@googlegroups.com.
>
> To post to this group, send email to xhtm...@googlegroups.com.
> Visit this group at http://groups.google.com/group/xhtml2pdf.
> For more options, visit https://groups.google.com/groups/opt_out.

Thiago Sousa Santos

unread,
Feb 5, 2014, 3:50:29 PM2/5/14
to xhtm...@googlegroups.com
even when using a default font?


You received this message because you are subscribed to a topic in the Google Groups "Pisa XHTML2PDF Support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xhtml2pdf/wlj3UNW_VPc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xhtml2pdf+...@googlegroups.com.

To post to this group, send email to xhtm...@googlegroups.com.
Visit this group at http://groups.google.com/group/xhtml2pdf.
For more options, visit https://groups.google.com/groups/opt_out.



--
Thiago Sousa Santos

Philippe Raoult

unread,
Feb 5, 2014, 3:52:37 PM2/5/14
to xhtm...@googlegroups.com
I don't think calibri is the default for anyone else that Word.

See https://github.com/chrisglass/xhtml2pdf/blob/master/doc/usage.rst#fonts
for a list of fonts supported out of the box.
Reply all
Reply to author
Forward
0 new messages