9

sorry,.. i'am a noob in python..

I need to create a pdf file, without using an existing pdf files.. (pure create a new one)
i have googling, and lot of them is merge 2 pdf or create a new file copies from a particular page in another file... what i want to achieve is make a report page (in chart), but for first step or the simple one "how to insert a string into my pdf file ? (hello world mybe)"..

this is my code to make a new pdf file with a single blankpage

from pyPdf import PdfFileReader, PdfFileWriter
op = PdfFileWriter()  

# here to add blank page
op.addBlankPage(200,200)  

#how to add string here, and insert it to my blank page ?

ops = file("document-output.pdf", "wb")  
op.write(ops)  
ops.close() 

2 Answers 2

7

You want "pisa" or "reportlab" for generating arbitrary PDF documents, not "pypdf".

http://www.xhtml2pdf.com/doc/pisa-en.html

http://www.reportlab.org

1
  • thanks,.. it is what i looking for,.. i need a litle help again,.. i've followed the installation.. it works fine,.. then when i run the example python module,.. my pdf had made and works,.. and i can open it... but when i run the sample in IDLE, import ho.pisa as pisa return a warning.. the sets module is deprecated.. what's wrong with my pisa ? and pisa.showLogging() where can i find the log file ?? Commented May 25, 2011 at 6:53
2

Also check out the pyfpdf library. I've used the php port of this library for a few years and it's quite flexible, allowing you to work with flowable text, lines, rectangles, and images.

http://code.google.com/p/pyfpdf

Not the answer you're looking for? Browse other questions tagged or ask your own question.