psliwa / PHPPdf

Pdf and graphic files generator library written in php
http://ohey.pl
MIT License
339 stars 77 forks source link

Template usage #52

Closed aledeg closed 10 years ago

aledeg commented 10 years ago

I was struggling with the templates. I used the example given in the documentation but it wasn't working properly. The pdf was generated, the content was there but not the template.

This wasn't working for me:

<pdf>
    <dynamic-page document-template="path/to/file.pdf">
        <div>Some content</div>
    </dynamic-page>
</pdf>

neither did:

<pdf>
    <page document-template="path/to/file.pdf">
        <div>Some content</div>
    </page>
</pdf>

I finally succeeded adding an empty placeholders tag in the page. So the following codes are minimal working code:

<pdf>
    <page document-template="path/to/file.pdf">
        <placeholders></placeholders>
        <div>Some content</div>
    </page>
</pdf>

I also noticed that the content start outside the page giving the impression of truncated content. The workaround is to add the page-size parameter.

<pdf>
    <dynamic-page page-size="letter" document-template="path/to/file.pdf">
        <placeholders></placeholders>
        <div>Some content</div>
    </dynamic-page>
</pdf>

Is it normal? Is it a bug? Is it an undocumented behavior?

ivela-goorkers commented 10 years ago

I was also having the same troubles and thanks to you I get this working. I believe that this behaviour is a bug.

psliwa commented 10 years ago

This is a bug. I will fix it soon.

psliwa commented 10 years ago

Ok, master and 1.2.x branches are fixed.