Pdf creation using python

724 views
580 views

Published on

baabtra mentoring partner

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
724
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Pdf creation using python

  1. 1. 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
  2. 2. Week Targ et Achieve d 1 23 19 2 25 23 3 30 27 4 35 Typing Speed
  3. 3. Jobs Applied # Company Designation Applied Date Current Status 1 Skillsearch Limited Junior software engineer 7/08/2013 2 3
  4. 4. PDF CREATION IN PYTHON ● Shameena ● shameenavayoli@gmail.com ● www.facebook.com/shameenalatheef ● twitter.com/shameena ● in.linkedin.com/in/shamean ● 9567135569
  5. 5. 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
  6. 6. 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
  7. 7. 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.
  8. 8. 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()
  9. 9. output
  10. 10. ● 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
  11. 11. ● doc=SimpleDocTemplate("form_letter.pdf",p agesize=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"]))
  12. 12. 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
  13. 13. 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

×