How to properly layout and size for PDF

I’m struggling for like week or so, with invoice look and feel, especially when need to generate PDF because it is preferred way of getting output as stated multiple times here. So I must ask couple of things. I’m not asking for programming help, just best ways of doing things? @lubos

  1. Is it must to use

    as container elements for output. I see all build in themes are based on tables. Will all
    style codding work, no tables (maybe tables in line item and totals, but no allover)? , also ? Or we are stuck with tables, and using thead,tfoot for reason of getting multiple page invoices work with heading and bottom on every sheet?
  2. What is best method of positioning stuff inside tables? Obviously Manager set sizes of columns on his own, so using colspan or width is not giving consistent output all the time.

  3. What is proper, or better say checked method of sizing columns, tables, divs, lines, or any element. For ex. I wand let say, on top before main table of items, a two cell table, floated right, taking exactly 10cm, so I could put there recipient company name , address, an output it always there, because we use windowed envelopes. So I cannot get any consistent sizing method to work (tried px, %, cm, etc, tried width, float, colspan, margins, padding) and always if it work on screen on PDF is disaster. So what to use for PDF.

  4. For now I am sticking to plain theme, and make changes on it. I could post some code examples if needed, or pictures what I am trying to accomplish. I may have other layout questions I could not remember now, so maybe additional asked.

1 Like
  1. The layout needs to be table-based but why is that a problem?
  2. You can insert table within a table.
  3. Percentages and pixels are supported. Although you can see that is an issue because of mismatch between pixels and centimeters.

And what are your best practices.

Tables are hard to layout, hard to float. How many cells is main Table have, so to use colspan. Is the columns in table generally defined bu invoice items table as it contains most cells. Why you use colspan=‘99’ very often. Is there any technical reason for PDF generation or is your preference.

Here for example, how to manage this “I want on top before main table of items, a two cell table, floated right, taking exactly 10cm, so I could put there recipient company name , address, an output it always there, because we use windowed envelopes.”

This is to indicate cell should span across entire row. It’s just a trick if you don’t know how many columns table will have, you make colspan high enough to ensure cell with span across entire row regardless number of columns.

In the cell which contains business address, you can add padding-left: 20px to move the business address more to the left. Here is a guide explaining it:

As for the complain over difficulty of customizing themes, I’m aware of it. I was thinking to perhaps have 3 fields instead of 1 to define theme. If there are three fields

  • Header
  • Body
  • Footer

Then complexity of markup could be greatly reduced and you wouldn’t see anywhere colspan=99.

Please do.
I need to make a theme for my parents business also and their layout is such that their business details like address, bankaccount, chamber of commerce, etc are on the bottom left of the page.
When i make a template and the invoice contains 1 or 2 rows the company details are not in the bottom left but somewhere halfway. This means I have to create a workaround to get it in the bottom left on a position that is relative to everything that is above it.

Now i did find posts of people using css in 2014 but that doesn’t seem to work anymore. Using css would fix this problem for me.

I hope there is a simple way for me to set certain elements of a theme to a fixed position on a A4 or PDF print.

I am trying to get this. Borders are just for demo purposes to see my layout. I am having a really hard time to achieve this. On screen is great, but PDF, no way. Column widths are generetad in some mysterious ways :slight_smile:

1 Like

What does the screenshot represent? What you see on the screen or what is shown in PDF?

Above image is our current Invoice in Excel, and look I am trying to duplicate as close as possible.
I finally manage to make something that is sutisfing using nested -nested tables and trial-error paddings (divs don’t work as expected in this scenario, span also, margin also) all talking about PDF, using previous gives great screen results but messy PDFs.

So here is my current Screen

My current Print window

And generated PDF

It is still work in progress, so dummy data is used. Also did some custom codding for things we spoke in other thread, about line tax, order of columns, tax in amount per line, and more to come :slight_smile: . Or I should wait for soon to have native line item tax values, and tax basis subtotals, as we spoke in other thread ?

@MarV is it possible to share this theme ? i was looking for a long time for something like this but was told this cant be done
thanks in advance

The theme is quite a big to post it here. Also highly customized for direct use. See PP I will explain.

1 Like