scott1028 / pyfpdf

Automatically exported from code.google.com/p/pyfpdf
GNU Lesser General Public License v3.0
0 stars 0 forks source link

FPDF' object has no attribute 'y' #70

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.I try to make save as button in plugin QGIS Dufour 2.01 and want to save it 
as pdf file
2.when i try save my file ( open file destination and then click save ) i got a 
error message

What is the expected output? What do you see instead?
def _save(self, simpan):
        import fpdf
        # Portrait, millimeter units, A4 page size     
        pdf=fpdf.FPDF("P", "mm", "A4")
        # Set font: Times, normal, size 10
        pdf.set_font('Times','', 12)
        # Layout cell: 0 x 5 mm, text, no border, Left
        pdf.cell(0,5,'Input 1 : ' +  self.ui.lineInput1.text(),border=0,align="L")
        pdf.cell(0,5,'Input 2 : ' + self.ui.lineInput2.text(), border=0,align="L")
        pdf.cell(0,5,'Recomendation : ' + self.ui.textRec2.toPlainText(), border=0, align="L")
        pdf.cell(0,5,'Data 1 :' +  self.ui.lineCond1.text(), border=0, align="L" )
        pdf.cell(0,5,'Data 2 :' + self.ui.lineCond2.text(), border=0, align="L" )
        pdf.output( simpan+'.pdf','F')

Error message i get
  File "C:\PROGRA~1\QGISDU~1\apps\Python27\lib\site-packages\fpdf\fpdf.py", line 615, in cell
    if(self.y+h>self.page_break_trigger and not self.in_footer and self.accept_page_break()):
AttributeError: 'FPDF' object has no attribute 'y'
Python version:
2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)]

What version of the product are you using? On what operating system?
I use fpdf 1.7 and install it in windows 7 32bit with .msi installer and QGIS 
Dufour 2.01 

Please provide any additional information below.
I have python33 installed but its look like QGIS use python27 so i install it 
in C:\QGIS Dufour\apps\Python27\lib\site-packages\fpdf instead

Original issue reported on code.google.com by suryomil...@gmail.com on 6 Jan 2014 at 5:54

GoogleCodeExporter commented 8 years ago
You were missing pdf.add_page() after creating he pdf object
I've added a proper check, now it will raise an exception.
Thanks for reporting

Original comment by reingart@gmail.com on 5 Feb 2014 at 1:40

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 81f7f9d356e6.

Original comment by reingart@gmail.com on 5 Feb 2014 at 1:40