pyfpdf
pyfpdf copied to clipboard
Custom size document fails to render properly
Using the following code on a Letter sized page works almost as expected...
ptr=Printer('LAB')
doc=ptr.canvas
doc.set_font("Arial", size=12)
doc.set_margins(.0625,.0625)
for l in labels:
doc.add_page()
doc.ln(.25)
for line in [(''+line) for line in l.split('\n')]:
doc.cell(0,.25,txt=line,ln=1,border = 1)
doc.output('/tmp/labels.pdf')
Note: the top margin seems to be set at 1cm and not .0625 (per the set_margins) (inches is the UOM of both examples below)
Produces:
However switching to: Custom size label 2.25"x1.25" (wxh) produces
The only difference in the two is the switch from Letter to Custom size. And I did force settings for FPDF('L','in',(1.25,2.25)) per docs.
Can't seem to tell why it is forcing a new page when only one line of text is drawn. No header or footer is defined.
closer...
doc.cell(0,.15,txt=line.strip(),ln=1,border = 1)
causes the following output
So it appears as if a default footer or bottom margin is forcing the page advance. I also removed the doc.ln() since I want it to advance the height based on text(cell) draw. This eliminated the blank page 1 though I don't understand why it caused that issue.
PR #149 fixes this
