Reputation: 267
I am generating a PDF file using the pyPdf library in python.
After I generate the file and I try to open it I will receive the following error: File type plain text document (text/plain) is not supported
If I rename the file with .txt and I open it, it will work and display what I have written in the file.
This is the code:
from pyPdf import PdfFileWriter
output = PdfFileWriter()
outputStream = file("/home/documet_test.pdf","wb")
outputStream.write("Hello world")
outputStream.close()
What am I missing?
Upvotes: 1
Views: 1822
Reputation: 267
Using reportlab library will solve the problem:
from reportlab.pdfgen import canvas
c = canvas.Canvas("hello.pdf")
c.drawString(100,750,"Welcome to Reportlab!")
c.save()
Upvotes: 1