Announcement

Collapse
No announcement yet.

Creating PDF Templates an easier way

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating PDF Templates an easier way

    Hi,
    as for me creating decent layouts with the PDF template editor is quite a pain in the ass, I have been experimenting a bit.

    For an entity with relationships and lots of fields I created an email template. Searching for solution of some minor problems during this I came across one post, where it says, that the email template as well as the PDF templates are using handlebars as template engine.
    So I thought, this could be compatible with each other. Email templating is a bit easier and leads faster to nice looking layouts.

    Well then, I did the following:

    When my email template was ready, I copied all the source code, put it in an editor and changed the single brackets to double brackets (as it is needed in the PDF editor). Furthermore I stripped all entity assignments of the fields (as in {entity_name.relationship_name.fieldname} (this way in email template) to {{relationship_name.field_name}} (this way in PDF editor)). I guess you do not need to assign the base entity, as the PDF template is made in relation to an entity by configuration.

    This modified source code I copied into the source code of the PDF Editor and it worked.

    It is the result of an experiment and I will have to investigate more, if this is really sustainable.

  • #2
    So basically the email template is use for layout "Formatting / Design it to look good"? And it can be copy to paste to the Print-to-PDF and the layout look as good as the email?

    Does that really work? How surprising.

    Comment


    • #3
      Yes, I think, it is easier to layout. The PDF editor often does not react, as you want, what causes lots of corrections the trial an error way, very exhausting. As I often create email templates and in parallel PDF documents with the same content, I gave this approach a try and it worked quite well, althoug, the editor - as said - often changes the layout.
      But in general it really was a bit surprising, that this works. I will examine further.

      Comment


      • #4
        Today I made thorough testing of Email and PDF templates. As said, create Email templates is a bit easier but also limited in relation to possible CSS and HTML. This is because of the limitations of TCPDF.
        I tested a lot of HTML and CSS templates, that I created in an editor. For Email it seems to work better, as the PDF still is quite difficult to use. Sometimes there appear tags, that I never put in, most of the CSS rules do not work as expected or not at all. You are able though to layout quite simple and old fashioned looking templates. Unfortunately in this case not adequate to the overall appearance of espoCRM.
        There are other PDF engines out there, which do a much better job (many of those you may test in the web, search for HTML to PDF converter. But there you cannot use placeholders, obviously.

        I saw, that sometimes it is even better, instead configuring a PDF template, to do that in the Email editor and send the mail to yourself. Then you might print that email, which often looks better, than the PDF made by TCPDF.

        Comment


        • #5
          Digging in the developer forum today, I found this: https://forum.espocrm.com/forum/gene...age2#post58704 post nr. #25 espcrm talking about this also.

          Comment

          Working...
          X