# Theresa | Expense Report PDF Model

**URL:** <https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163>\
**Category:** Using my Dolibarr\
**Created:** [December 6, 2018, 10:37pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163 "2018-12-06T22:37:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 6, 2018, 10:37pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/1 "2018-12-06T22:37:17Z")

</div>

Theresa - An Alternative Expense Report PDF Document Model

WARNING:  
This information and code is presented to you in good faith. Using parts of this code or file is at your own risk. This feature has been tested on Dolibarr [tt] 7.0.4 [/tt] and [tt] 8.0.2 [/tt].

What this does  
Upto Dolibarr [tt] 8.0 [/tt] the ‘standard’ expense report PDF model followed the typical invoice-style layout. With Dolibarr [tt] 9.0 [/tt] a new improved layout was created for the ‘standard’ model which tackled reducing the columns and blank pages.

The ‘theresa’ model is focussed on a business expense usage, as opposed to a user expense usage. Model ‘theresa’ is based on the improved ‘standard’ model but with the following changes:

- Added payment table to PDF
- Amount paid/claimed/unpaid is only shown when unpaid
- Add PDF Description and Author \*
- Only show payments on PDF if there is a payment.
- Hidden config [tt] MAIN\_GENERATE\_NON\_SALES\_DOCUMENTS\_WITHOUT\_VAT [/tt] to make sales doc vat different from internal docs
- Page table titles in bold and aligned
- Changed the overall text color to black for paper printing
- Highlighted date (in bold) for easier reference
- Changed the status color to a paper-friendly green
- Changed the ‘Amount in’ to italics
- Aligned columns

\* Requires new translation string

What the PDF looks like

Here’s the general look…

 ![theresa-no-payment.png](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/8/811aa9402847e04b03e90cd4bdd0921ef2659711.png)

Here’s with the payment table…

 ![theresa-payment-table.png](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/a/ac940415199f82b07241f7324c8708bfd3480dd3.png)

Here’s the unpaid section…

 ![theresa-unpaid.png](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/d/ddff91fa47c09a3298b1ba475c168e3517c0a91b.png)

Upload the document model  
EXTRACT and upload to:

`
/core/modules/expensereport/doc/`

This file:  
[hide]

[pdf\_theresa.modules.zip](https://www.dolibarr.org/forum/uploads/short-url/hHhLxXu3LNYuzEb5Ku5AIj13W1c.zip) (10.5 KB)[/hide]

Add the translation text  
In file:

`
/langs/en_US/trips.lang`

Add: (around line 39)

`
PDFTheresaExpenseReports=Advanced template to generate a PDF document for Expense Reports more suitable for business expenses. <br>Shows the payment table if payments have been made. Amount paid/claimed/unpaid is only shown when unpaid.<br>Set <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">MAIN_GENERATE_NON_SALES_DOCUMENTS_WITHOUT_VAT</b> to <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">1</b> in <b style="background-color: rgba(27,31,35,.09); border-radius: 3px; padding: .2em .4em;">Setup > Other</b> to hide VAT details on the generated PDF.`

Activate the document model  
Finally in Dolibarr, go to: Home ► Setup ► Modules ► Expense Reports

 ![theresa-status.png](https://www.dolibarr.org/forum/uploads/dolibarrorg/original/2X/c/cfe33510e46daa8e8c69115f9d03fe3c2b249443.png)

---

<div class="post-metadata">

**Author:** ![n15c](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/n/a5b964/32.png) [@n15c](https://www.dolibarr.org/forum/u/n15c)\
**Post date:** [December 7, 2018, 3:32pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/2 "2018-12-07T15:32:45Z")

</div>

Hello, Thanks for your model. Unfortunately this isn’t working on my system. I have Dolibarr 8.0.1 but the report has the same problem.  
Maybe there is another problem?

> Pièces jointes :
> 
> - [Unbenannt-1.jpg](https://www.dolibarr.org/forum/uploads/short-url/sjmZ4MtFgzDdxHz0Q3D6HztEczN.jpeg) (168 KB)

---

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 7, 2018, 4:08pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/3 "2018-12-07T16:08:54Z")

</div>

Hello

There is no easy way to fix the line spacing from what I know as the pdf is created through “guessing” because of all the different bits that link to it to create a single document.

When I tested, I did notice that re-creating an expense report did improve one ‘silly empty page’ pdf but from 5 white pages i got 1 so I was happy. It may be too time consuming for you to re-create (not just generate the pdf) your expense reports.

At least you have two choices in expense report models now. Hopefully one is better system-generated than the other.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 10, 2018, 9:13pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/4 "2018-12-10T21:13:37Z")

</div>

Hello, I have just experienced (even in this new model) the problem similar to yours. I think it is to do with how many lines in the expense report.

Anyway, my new problem was 36 lines of expenses created 8 pages but only 3 or 4 of the pages had REAL lines on them. In the blank pages it was one value per page - not even a full row.

So I have just been playing around to try to get this ‘improved’ and I think I MAY have found the solution.

Try this code and see if it works. It has worked for me and reduced my 8 silly pages to a correct 3 pages.

Replace: (line 307)

`
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);`

With:

`
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?50:10);`  
[hr]  
I still have around 5 or 6 expense reports to do so I will keep testing it on my side in this report. Please check on your side and let me know if it improves or solves the problem.

---

<div class="post-metadata">

**Author:** ![n15c](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/n/a5b964/32.png) [@n15c](https://www.dolibarr.org/forum/u/n15c)\
**Post date:** [December 10, 2018, 9:23pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/5 "2018-12-10T21:23:54Z")

</div>

Hello,

Thank you for your response, i tried your lines of code but unfortunately the same thing happens.  
The model looks a bit nicer because there is less space between the header and the table but the problem still exists.

I tried to play with the numbers but it will only get worse :happy:

By the way, i just updated to 8.0.3.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 10, 2018, 11:06pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/6 "2018-12-10T23:06:14Z")

</div>

but you should have less pages now with ‘less space between the header and table’ ? What line number is your blank page problem starting from? mine was 31 or 32

---

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 10, 2018, 11:11pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/7 "2018-12-10T23:11:35Z")

</div>

Your image earlier shows your pdf breaks at line 12… hmmm

I just noticed, in your blurred part, you’re using two lines in your description

```auto
Your pdf:
date / type
line 1
line 2
```

try

```auto
date / type
line 1 | line 2
```

Maybe it’s that extra second line in the description which is the culprit. Worth a try.

---

<div class="post-metadata">

**Author:** ![aljawaid](https://www.dolibarr.org/forum/user_avatar/www.dolibarr.org/aljawaid/32/388_2.png) [@aljawaid](https://www.dolibarr.org/forum/u/aljawaid)\
**Post date:** [December 11, 2018, 9:18pm UTC](https://www.dolibarr.org/forum/t/theresa-expense-report-pdf-model/17163/8 "2018-12-11T21:18:42Z")

</div>

So today I had one report which was enough for one page but spread across two. I solved it. Still a few more reports to do but this could be useful for the blank page problem.

I will finalise the original theresa template model once I have finished all my reports (about 4 left).

Replace: line 264

`
$heightforinfotot = 40;	// Height reserved to output the info and total part `

With:

[code]  
$heightforinfotot = 35; // Height reserved to output the info and total part // old value 40[/code
