Announcement

Collapse
No announcement yet.

Template for Printing multiple records of entity

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

  • Template for Printing multiple records of entity

    Hello,

    i am new in developing templates for Espo CRM.
    I want to print some records of an entity to a PDF file.
    When i check the checkmarks in the list view every time i want to export the PDF Espo creates one PDF for one record.
    It is possible that i create a template that makes a list of the records i selected? SO that i have 30 records on one PDF page.

    Best regards,
    Sascha

  • #2
    Maximus is this something that ESPO can do? I also want to know how this is possible.

    Comment


    • #3
      Hello,
      you can select more than one .. and print to pdf..
      but not "selectAll" .. .you have a limit to 50 record to print-pdf in viewList.

      Comment


      • #4
        Hi pixility, PhotoMommie,
        As far as I know, there is no such an ability to print to PDF a few records on one page. Such a thing may be achieved by utilizing the 'each' iterator for Item List, Related records or records in Array https://github.com/espocrm/documenta...#each-iterator.

        Comment


        • #5
          Hello, this is something I also would like to achieve. I tried with the each iterator, but whenever I use this tag, the output of the templatecode following (in my case a table of some fields) would not appear at all. I get a blank page and one page for each record.
          I tried everything, followed the instructions of the manual and also the related instructions of handlebars js. Can it be, that ESPOCRM is not able to print a list of records on one page of PDF?

          Comment


          • #6
            hi shalmaxb
            I can confirm that #each PDF printing work fine.

            What are you trying to do? I have a couple of thread where I post my result, my trial and error and my insight if you want to have a look at it to see it if help.

            Here is one code I use to get all my Contact email to be printed in PDF:

            {{#each emailAddress}}
            {{./this}}
            {{/each}}

            https://forum.espocrm.com/forum/gene...nt-type-entity
            https://forum.espocrm.com/forum/gene...8700#post58700
            https://forum.espocrm.com/forum/gene...8704#post58704
            https://forum.espocrm.com/forum/gene...crm-and-design

            It shouldn't go into next page unless the page is at an end (or your page margin is too high?), or if you forcefully use the pagebreak code (see: docs.espocrm.com/ ), thirdly your paragraph spacing might be too high?

            Sometime it better to use "Shift+Enter" for to create new lines then pressing Enter (create paragraph).

            Comment


            • #7
              Hi espcrm,

              thank you for all the hints. I read already a lot of them, followed the manual, but no success. What am I trying to do?
              I use the Real Estate Property extension, modificated to make something like an inventory for artists (works, galleries, clients and so on), what really works quite well. I would like to provide from within this the possibility to print out lists (e.g. for exhibitions and alike), labels for labeling the works in the exhibition and other stuff.
              I have a list view and would like to be able to print out this list, or a certain, marked number of the shown records.
              This is my code:

              <table>
              <tbody>
              <!--{{#each Werk}}-->
              <tr>
              <td>{{werknummer}}</td>
              <td><img src="{{imageTag bildId}} width=100 height=auto"></td>
              <td>{{name}}</td>
              <td>Höhe: {{hhe}} cm</td>
              <td>Breite: {{breite}} cm</td>
              <td>{{jahr}}</td>
              <td>{{verkaufspreis}}</td>
              </tr>
              <!--{{/each}}-->
              </tbody>
              </table>

              My list view in the attachment.

              All I get is three blank pages (when choosing three records).

              Comment


              • item
                item commented
                Editing a comment
                hello
                maybe fault here : <td><img src="{{imageTag bildId}} width=100 height=auto"></td>
                must like this : <td><img src="{{imageTag bildId}}" width="100px" height="auto"></td>

            • #8
              Ah I see, if you want 3 of those different record in 1 page then i don't think it possible. However it should be possible to print out all those details thanks to some of the latest enhancement. I paste you my Print2PDF code to see if it help.

              This code I use to print out the map. Make sure you copy/paste these in the code view (click <>). The first part print Address & Map, the second part will print all my Attachment with the images field.
              Code:
              <p><b>Property Map</b><br></p><p>{{_googleMapsImage field='address' size='600x225' zoom='18'}}<br><b>Suburb Profile<br></b></p><table class="table table-bordered"><tbody><tr><td align="center">{{_googleMapsImage city=addressCity state=addressState postalCode=addressPostalCode country=addressCountry zoom='13' size='250x200'}}</td><td align="center">{{_googleMapsImage city=addressCity state=addressState
              postalCode=addressPostalCode country=addressCountry zoom='8'
              size='250x200'}}</td></tr></tbody></table>
              <p><br></p><p>{{#each imagesIds}}
              {{#ifMultipleOf @key 4}}<br>{{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}}
              {{/each}}</p><span style="font-family:courier new"></span>
              <p></p>
              This code is when I want full data of a property in Normal view. See next code for <> code view
              Code:
               [TABLE="class: table table-bordered, border: 0, cellpadding: 2"]
              [TR]
              [TD="width: 25%"] [/TD]
               			[TD="width: 50%"] [/TD]
               			[TD="width: 25%"] [/TD]
               		[/TR]
              [/TABLE]
              [B]Contact Information[/B]
              
              {{#tableTag width="100%" border="0.1pt" cellpadding="2"}} {{#each contacts}} {{#trTag}} {{#tdTag width="40%"}}{{name}}{{/tdTag}} {{#tdTag width="20%"}}{{propertyRole}}{{/tdTag}} {{#tdTag width="15%" align="right"}}{{phoneNumber}}{{/tdTag}} {{/trTag}} {{/each}} {{/tableTag}}
              
              {{#each historyEvents}}
              {{name}}
              {{/each}}
              
              {{#each meetings}}
              {{name}}
              {{/each}}
              
              {{#each parents}}
              {{name}}
              {{/each}}
              
              {{#each parent}}
              {{name}}
              {{/each}}
              
              [B]Property History[/B]
              
              {{name}} {{status}}
              It seem the particular part you really want is the {{/each}} part, the example in: docs.espocrm.com/ is faulty, I have post the correct one but I'm not sure if it been fixed yet. Here the code I use for:

              Code:
              {{#tableTag width="100%" border="0.1pt" cellpadding="2"}}
              {{#each contacts}}
              {{#trTag}}
              {{#tdTag width="40%"}}{{name}}{{/tdTag}}
              {{#tdTag width="20%"}}{{propertyRole}}{{/tdTag}}
              {{#tdTag width="15%" align="right"}}{{phoneNumber}}{{/tdTag}}
              {{/trTag}}
              {{/each}}
              See if you can get these type of code to work first before trying more complex field. The goal in these Print2PDF Template is to see if the setup is right, as long as one field work you can adapt it for all field.


              PS: Make sure you on latest version too, some of these code is only available in newer version.

              Not sure of your field name but I give your label name a try to get all those image:

              Code:
              {{#each bildID}}
              {{#ifMultipleOf @key 4}}<br>{{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}}
              {{/each}}</p><span style="font-family:courier new"></span>
              Code:
              {{#tableTag width="100%" border="0.1pt" cellpadding="2"}}
              {{#each werk}}
              {{#trTag}}
              {{#tdTag width="40%"}}{{name}}{{/tdTag}}
              {{#tdTag width="20%"}}{{werknummer}}{{/tdTag}}
              {{#tdTag width="15%" align="right"}}{{hhe}}{{/tdTag}}
              {{/trTag}}
              {{/each}}
              Last edited by esforim; 07-01-2020, 04:17 AM.

              Comment


              • #9
                Hello,
                thank you for your efforts. I tested everything as mentioned, but no luck. It will not output any parts with code. Plain text is printed. I tried everything and will give up now. The manual is not clear and I won`t get it to work in reasonable time. Very frustrating.
                I don`t know, why this has to be so complicated. I use other scripts, where PDF-output is integrated and it always works without problems.

                Comment


                • #10
                  That doesn't sound good, somewhere one of us went wrong then.

                  Whether it be a copy and paste or incorrect instruction, misread or server & system issue.

                  Have you tried to reproduce anything simple yet? Using only default field and default entity? That always my first step, get something to work first then modified it afterward. For example with my post above, I would do a "demo test" using the very simply code:

                  See if you can firstly do it on your system. Then if that fail you need to test it on the demo system ( https://demo.espocrm.com/?lang=en_US#Template/ )


                  Click image for larger version  Name:	Print2PDF Each Field.png Views:	0 Size:	185.3 KB ID:	60145

                  Comment


                  • #11
                    Originally posted by espcrm View Post
                    hi shalmaxb
                    I can confirm that #each PDF printing work fine.

                    What are you trying to do? I have a couple of thread where I post my result, my trial and error and my insight if you want to have a look at it to see it if help.

                    Here is one code I use to get all my Contact email to be printed in PDF:

                    {{#each emailAddress}}
                    {{./this}}
                    {{/each}}

                    https://forum.espocrm.com/forum/gene...nt-type-entity
                    https://forum.espocrm.com/forum/gene...8700#post58700
                    https://forum.espocrm.com/forum/gene...8704#post58704
                    https://forum.espocrm.com/forum/gene...crm-and-design

                    It shouldn't go into next page unless the page is at an end (or your page margin is too high?), or if you forcefully use the pagebreak code (see: docs.espocrm.com/ ), thirdly your paragraph spacing might be too high?

                    Sometime it better to use "Shift+Enter" for to create new lines then pressing Enter (create paragraph).
                    ARe you able to print checked records of entity to PDF ? And i don't mean one record per page, i want to print checked records from entity to table which will visible on one page.

                    Comment


                    • #12
                      I never succeded in printing a list of choosen records to one page, always one page for each record. I think, it is not possible by default in espoCRM. Because I sometimes need lists of records, I am doing this so far by printing a PDF from the website view, import it into a design program and adapt, how I need it. I know, not the best way, but at least I have a result.

                      Comment


                      • #13
                        shalmaxb i'll create feature request for that, maybe espo devs will consider, because it should not be hard to achieve. Also i'll try to achieve this by myself. I asked because i thought that item already did that

                        Comment


                        • #14
                          You mean me emillod? Cause I read item post and doesn't seem related.

                          If you want it like this

                          Page 1 (style 1)
                          Contact1 John Smith - Phone: 123
                          Contact2 Jane Smith - Phone: 234
                          ...
                          Contact100 Joe Smith

                          instead of (style 2)
                          Page 1
                          Contact1 John Smith - Phone: 123
                          Page 2
                          Contact2 Jane Smith - Phone: 234
                          ...
                          Page 100
                          Contact100 Joe Smith

                          ---

                          Then no, I haven't been able to do that (or test that out in practice).

                          Personally if you want it to be print out in one single Table/page (style), my workaround method is to create a Relationship and field, then use the "#each" to print it out table-like. Sorta like a "Target List"; for me I use my "Case" like that.

                          I got a Relationship between contact and cases. This Field is a Many-to-Many and I use Multiple Selects. With Print to PDF template I print out multiple contact with frequently information that I need for certain thing so I end up with these type of layout (screenshot) as a single page.

                          That also mean I misread the thread topic.

                          Speaking of Target List, can you make use of that...?
                          Attached Files
                          Last edited by esforim; 09-10-2020, 07:22 AM.

                          Comment


                          • #15
                            esforim you're right, sorry. I was talking about your post
                            In our company we register all expenses and i want be able to export pdf file with list of all expenses in specific month. Yes, i know, i could prepare workaround with relations or even i could prepare report through advanced pack. But i think that this is so important function that it should be built in.

                            It would be great to use something like #each mechanism.

                            Comment


                            • esforim
                              esforim commented
                              Editing a comment
                              Yep, saw your post in feature request. I think it might be possible to see it after v6.0.0 and not v6 as old post stated "feature frozen".
                          Working...
                          X