Images in .pdf Invoice

53 views
Skip to first unread message

Joseph Mohan

unread,
Jun 24, 2016, 6:13:05 AM6/24/16
to Mezzanine Users
Any other things i'm missing with regards to getting an image into the .pdf invoices?

Set the url to a full path

Tried .png/.jpg 

Nothing...

Any ideas?

Eduardo Rivas

unread,
Jun 24, 2016, 11:03:41 AM6/24/16
to mezzani...@googlegroups.com
Well, Cartridge uses Pisa to create the PDFs. Apparently you can pass a "link_callback" arg to CreatePDF(). This callback should handle the conversion of the relative path of the image in the HTML to the complete filesystem path to be embedded in the document.

The xhtml2pdf docs provide a full example. You'll need to override the invoice view to pass the callback to CreatePDF().

Ag Stephens

unread,
Jun 24, 2016, 12:45:44 PM6/24/16
to mezzani...@googlegroups.com
Hi,

Have you tried different browsers? I had a strange anomaly with pdfs in mezzanine that turned out to be browser specific.

Cheers,

Ag

From: Joseph Mohan
Sent: ‎24/‎06/‎2016 11:13
To: Mezzanine Users
Subject: [mezzanine-users] Images in .pdf Invoice

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joseph Mohan

unread,
Jun 28, 2016, 8:24:23 AM6/28/16
to Mezzanine Users
Thanks for your help. 

I've spent the last 2 days pulling xhtml2pdf apart and still cannot get this to work. It seems to just not recognize any src attribute on an img tag, even tried brute forcing it but 

xhtml2pdf also seems to now be abandoned and their python3 support is shaky.. hense why i'm struggling so much.

Had a quick look at weazyprint but having trouble installing it on my dev machine let alone my production shared servers....  

Anyone had any luck using an alternative to xhtml2pdf? 

Ken Bolton

unread,
Jun 28, 2016, 11:46:59 AM6/28/16
to mezzanine-users
Outside the scope of Mezzanine/Cartridge, I am getting amazing results using athenapdf to convert HTML to PDF. I manage a sprawling Python application that had a homebrew and long-in-the-tooth webkit integration in c++ and Python to generate PDF. I replaced it with http calls to the athenapdf microservice. The performance and quality have been astounding.

-ken

--

Sam Kingston

unread,
Jun 28, 2016, 9:22:16 PM6/28/16
to Mezzanine Users
I'm not sure if this will help you or not, but I developed a replacement library for xhtml2pdf (though not a drop-in):

Eduardo Rivas

unread,
Jun 28, 2016, 9:47:53 PM6/28/16
to mezzani...@googlegroups.com

I've also used wkhtmltopdf but with the Django bindings. It's available on Pypi as django-wkhtmltopdf (that's off the top of my head, you should check) and provides a class based view and PDF response type.

Stephen McDonald

unread,
Jun 28, 2016, 11:41:11 PM6/28/16
to Mezzanine Users
Cool Sam!

Do you think we should use your library in Cartridge instead of whatever's being used now?

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Stephen McDonald
http://jupo.org

Sam Kingston

unread,
Jun 29, 2016, 1:49:29 AM6/29/16
to mezzani...@googlegroups.com
I'd say probably use the one Eduardo suggests: https://github.com/incuna/django-wkhtmltopdf since it is has more seamless support for Django and does the same thing as mine (calls out to the wkhtmltopdf static binary).

Mine is for more low level, generic Python usage, though I do use it for a large Cartridge site successfully.

Would you like me to raise an issue and investigate if one would work better for Cartridge?

--
You received this message because you are subscribed to a topic in the Google Groups "Mezzanine Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mezzanine-users/AicXbbQzd7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mezzanine-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Sam Kingston                   Mobile: 0439 074 638
SJK Web Industries          Web: www.sjkingston.com
Brisbane, Qld, Australia    Email: s...@sjkwi.com.au

Stephen McDonald

unread,
Jun 29, 2016, 2:00:41 AM6/29/16
to Mezzanine Users
On Wed, Jun 29, 2016 at 3:49 PM, Sam Kingston <s...@sjkwi.com.au> wrote:
I'd say probably use the one Eduardo suggests: https://github.com/incuna/django-wkhtmltopdf since it is has more seamless support for Django and does the same thing as mine (calls out to the wkhtmltopdf static binary).

Mine is for more low level, generic Python usage, though I do use it for a large Cartridge site successfully.

That actually sounds more suited to what Cartridge needs - the PDF integration is just a couple of lines. 

I also think that you both owning the library, and also being a long-time Mezzanine contributor, is worth a lot, if the difference between the two libraries is negligible in what we're doing.
 

Would you like me to raise an issue and investigate if one would work better for Cartridge?

That'd be awesome, thanks!

Sam Kingston

unread,
Jun 29, 2016, 4:05:38 AM6/29/16
to mezzani...@googlegroups.com
Thanks Stephen - I've opened an issue to track this: https://github.com/stephenmcd/cartridge/issues/298

Joseph Mohan

unread,
Jun 29, 2016, 7:49:37 AM6/29/16
to Mezzanine Users
Sam you are an absolute gent!

Works an absolute treat, images work fine, and formatting is spot on. 

Thank you
Reply all
Reply to author
Forward
0 new messages