2. Disclaimer: This presentation is prepared
by trainees of baabtra as a part of
mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System
Technologies Pvt . Ltd
6. PDF- Portable Document Format
ReportLab :
---Open source python libraries for pdf creation.
---ReportLab is fast ,flexible, and fully cross platform
---The ReportLab library directly creates PDF based on
your graphics commands
7. Installing syntax:
---sudo apt-get install python-pip
---pip install reportlab
The pdfgen package is the lowest level interface for
generating PDF documents.
A pdfgen program is essentially a sequence of instructions for
"painting" a document onto a sequence of pages
8. The interface object which provides the painting
operations is the pdfgen canvas.
The canvas should be thought of as a sheet of
white paper with points on the sheet identified using
Cartesian (X,Y) coordinates
--default have the (0,0) origin point at the lower
bottom left corner of the page.
9. A simple example program that uses a canvas follows.
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("form.pdf", pagesize=letter)
c.setFont('Helvetica', 12)
c.drawString(30,750,'OFFICIAL COMMUNIQUE')
c.drawString(30,735,'OF ACME INDUSTRIES')
c.drawString(500,750,"12/12/2010")
c.line(480,747,580,747)
c.drawString(275,725,'AMOUNT OWED:')
c.drawString(500,725,"$1,000.00")
c.line(378,723,580,723)
c.drawString(30,703,'RECEIVED BY:')
c.line(120,700,580,700)
c.drawString(120,703,"JOHN DOE")
c.save()
11. ● If you’re in advertising or do any kind of work with form
letters
● For that we want to import the following module
from reportlab.lib.enums import TA_JUSTIFYfrom reportlab.lib.enums import TA_JUSTIFY
from reportlab.platypus import SimpleDocTemplate,from reportlab.platypus import SimpleDocTemplate,
Paragraph, Spacer, ImageParagraph, Spacer, Image
from reportlab.lib.styles import getSampleStyleSheet,from reportlab.lib.styles import getSampleStyleSheet,
ParagraphStyleParagraphStyle
from reportlab.lib.units import inchfrom reportlab.lib.units import inch
13. If this presentation helped you, please
visit our page facebook.com/baabtra and
like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |
www.baabte.com
14. Contact Us
Emarald Mall (Big
Bazar Building)
Mavoor Road,
Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25
550
NC Complex,
Near Bus
Stand
Mukkam,
Kozhikode,
Kerala, India.
Ph: + 91 –
495 40 25
550
Start up Village
Eranakulam,
Kerala, India.
Email:
info@baabtra.com