Need help with Joomla? We are available for hire to help with Joomla customization, upgrades, maintenance, and custom development.
Explore our services

PDF Ticket formatting

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 6 days ago - 2 weeks 6 days ago #180132 by Seán Ó Séaghdha
PDF Ticket formatting was created by Seán Ó Séaghdha
 I’m trying to set up PDF tickets and having a few problems.

When I change the font in Configuration | PDF Settings it changes for the next e-mail, but then goes back to Times New Roman. I’m generating a lot of test e-mails at the moment so I noticed this doesn’t stick.

I can’t figure out how to get our logo to appear at a predictable size in the PDF either. I can get it looking right in the editor and the HTML/CSS is all correct, but in the PDF it either appears very, very small or so large that it pushes the QRCode off the page.

I started off using standard CSS ways of sizing it proportionally, using the PNG that we normally use in e-mail, but that produced a very tiny image in the PDF. Then I tried SVG which produced an image too large in the PDF (it’s nominal size, for what that’s worth in an SVG, is 90x90). Then I tried exporting a new PNG explicity 300x300 pixels and tried specifying a width of  3 cm, but the image in the PDF is ~1.8 cm.

I can’t find any logical relationship between how the image appears in the editor or how it’s sized and how it ends up in the PDF. Do you have any recommendations?

Example in Editor:

Result in PDF:
 
Last edit: 2 weeks 6 days ago by Seán Ó Séaghdha.

Please Log in or Create an account to join the conversation.

More
2 weeks 6 days ago #180133 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PDF Ticket formatting
Hi Seán

Sadly, working with PDF layout is much harder compare to HTML and honestly, I also do not have much experience with it

By default, Events Booking uses TCPDF for generating PDF and it does not have good support for HTML and css (only basic support). I would suggest you to try to use MPDF plugin, it uses MPDF library, and that has much better support for css. See docs.joomdonation.com/eventsbooking/plugins/mpdf

Regards,

Tuan
The following user(s) said Thank You: Seán Ó Séaghdha

Please Log in or Create an account to join the conversation.

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 5 days ago #180139 by Seán Ó Séaghdha
Replied by Seán Ó Séaghdha on topic PDF Ticket formatting
Thanks Tuan.

I kept working on it yesterday and I’ll share in case it’s of use to someone else.

I used a table for layout since that’s what the example did. The two main problems I found are
  • Normally if you set the proportion of part of the table, e.g. the first cell, the other cells will size appropriately. This is not true when the PDF is generated. You must explicitly specify the widths of all ‘ columns (i.e. first row of cells). You can do this in percentages though (e.g. style="width: 20%")
  • The PDF generation handles the colspan attribute fine, but seems to ignore rowspan. If you need a cell to span multiple rows you can’t. Instead you need to put another table in the next cell to contain the ‘spanned’ rows.
I will give MPDF a try.
The following user(s) said Thank You: Tuan Pham Ngoc

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago #180140 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PDF Ticket formatting
Thanks Seán for sharing you experience. If you only need simple layout, use TCPDF is fine. For more complicated layout requires better css support, MPDF is a better choice

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 5 days ago #180141 by Seán Ó Séaghdha
Replied by Seán Ó Séaghdha on topic PDF Ticket formatting
With MPDF I still have the problem of the font reverting. I have body {font-family: FreeSans} in the PDF Settings, so it should work for everything. The first time after that that I choose my test registrations and choose Resend Email it’s FreeSans, but the next time I try it it has reverted to DejaVuSerifCondensed (I’m guessing the default for MPDF).

I only got it to stick by editing /plugins/eventbooking/mpdf/css/pdf.css

MPDF also does not correctly interpret table cell widths.

It’s also really hard to understand how it chooses font sizes. They don’t seem to relate to what you’d expect and specifying everything in pdf.css (e.g. html {13px} h1 {2.75rem}) does not seem to affect the font sizes in the PDF!

It’s also VERY time consuming to test this by sending e-mails to yourself. Is there no way to test the PDF output without sending e-mails?

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago #180142 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PDF Ticket formatting
You do not need to resend email. You can access to Registrants Management screen, then download tickets from there and check the result

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 5 days ago - 2 weeks 5 days ago #180143 by Seán Ó Séaghdha
Replied by Seán Ó Séaghdha on topic PDF Ticket formatting
MPDF Documentation:

Note: Support for rem was added in mPDF 5.7. Unlike the CSS3 specification, the basic size used for rem in the document is based on the font-size set on the <body> element (rather than the <html> element).

So, not the actual CSS standard. Doh!
Last edit: 2 weeks 5 days ago by Seán Ó Séaghdha.

Please Log in or Create an account to join the conversation.

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 5 days ago #180144 by Seán Ó Séaghdha
Replied by Seán Ó Séaghdha on topic PDF Ticket formatting
I think I’ll just have to accept that PDF Tickets are not very reliable.

Every second try, something is different. One time it’s vertical-align not working, next it’s the wrong date format.

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago #180146 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic PDF Ticket formatting
Hi Seán

Why I am not having much experience with PDF styling, if you have issue with it, feel free to submit a support ticket so that I can ask my developer to look at it and give you a hand

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Seán Ó Séaghdha
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 weeks 4 days ago #180150 by Seán Ó Séaghdha
Replied by Seán Ó Séaghdha on topic PDF Ticket formatting
I think I have it sorted out now. Maybe some of there was some caching going on that complicated things, but MPDF is definitely better once you realise the font sizes are based on the body tag not the html tag.

Sizing is still not 100% logical—some text inside <td> and <div> tags is smaller than text inside just <td> for no obvious reason (they’re both set to 1rem so should be the same size)—but I can live with that.

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc