Pdf creation using python
Click here to load reader
-
Upload
baabtracom-mentoring-partner-first-programming-school-in-india -
Category
Education
-
view
876 -
download
3
description
Transcript of Pdf creation using python
![Page 1: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/1.jpg)
![Page 2: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/2.jpg)
Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
![Page 3: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/3.jpg)
Week Target
Achieved
1 23 192 25 233 30 27
4 35
Typing Speed
![Page 4: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/4.jpg)
Jobs Applied# Company Designation Applied
DateCurrent Status
1 Skillsearch Limited
Junior software engineer
7/08/2013
2
3
![Page 5: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/5.jpg)
PDF CREATION IN PYTHON
● Shameena
● www.facebook.com/shameenalatheef
● twitter.com/shameena
● in.linkedin.com/in/shamean
● 9567135569
![Page 6: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/6.jpg)
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
![Page 7: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/7.jpg)
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
![Page 8: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/8.jpg)
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.
![Page 9: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/9.jpg)
A simple example program that uses a canvas follows.
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvasc = 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()
![Page 10: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/10.jpg)
output
![Page 11: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/11.jpg)
● 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
![Page 12: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/12.jpg)
● doc=SimpleDocTemplate("form_letter.pdf",pagesize=letter, rightMargin=72,leftMargin=72, topMargin=72,bottomMargin=18)
● styles=getSampleStyleSheet()● styles.add(ParagraphStyle(name='Justify',
alignment=TA_JUSTIFY))● Story.append(Paragraph(ptext,
styles["Normal"]))
![Page 13: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/13.jpg)
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
![Page 14: Pdf creation using python](https://reader037.fdocuments.in/reader037/viewer/2022100405/5479b708b479598a098b4823/html5/thumbnails/14.jpg)
Contact Us
Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
Start up VillageEranakulam,Kerala, India.
Email: [email protected]