ebook img

ReportLab: PDF Processing with Python PDF

562 Pages·4.397 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview ReportLab: PDF Processing with Python

ReportLab - PDF Processing with Python Michael Driscoll This book is for sale at http://leanpub.com/reportlab This version was published on 2018-06-05 * * * * * This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do. * * * * * © 2017 - 2018 Michael Driscoll Table of Contents Introduction About the Author Conventions Setting up & Activating a Virtual Environment Dependencies Installation Configuration Reader Feedback Errata Code Examples Part I - The ReportLab Toolkit Chapter 1 - Getting Started with Reportlab The Canvas Object Canvas Methods Using Colors in ReportLab Adding a Photo The textobject Create a Page Break Canvas Orientation (Portrait vs. Landscape) Other methods A Simple Sample Application Wrapping Up Chapter 2 - ReportLab and Fonts Unicode / UTF8 is the Default The Standard Fonts Other Type-1 Fonts TrueType Fonts Asian Fonts Switching Between Fonts Wrapping Up Chapter 3 - Intro to Page Layout The Basics of PLATYPUS Changing Fixed Elements Across Pages Flowable Methods Frame Basics Templates Flowable Orientation (Portrait vs. Landscape) Wrapping Up Chapter 4 - Paragraphs Paragraph Styles Paragraph Markup Tags The Outermost Markup Tags Using Intra-Paragraph Markup Working with Fonts Superscripts & Subscripts Inserting Inline Images Numbering Paragraphs / Sections Bullets Wrapping Up Chapter 5 - Tables The Table’s Methods Applying Style to Your Table Cell Formatting Changing Fonts in Tables Line Commands Cell Alignment Alternating Background Colors Putting Paragraphs in Your Cells Adding Images to Cells Spanning Wrapping Up Chapter 6 - Other Flowables Preformatted XPreformatted The Image Flowable The Spacer Flowable PageBreak CondPageBreak KeepTogether How to Add a Table of Contents SimpleIndex ListFlowable / ListItem Wrapping Up Chapter 7 - Creating Your Own Flowables Creating a Line Flowable Creating a Bordered Textbox + Line Flowable Modifying a Pre-Existing Flowable Wrapping Up Chapter 8 - Intro to Graphics and Charts What is a Drawing? ReportLab’s Renderers The Coordinate System A Simple Drawing Supported Outputs Verifying Attributes Naming Shapes Charts and Graphs Labels Axes Bar Charts Line Charts Line Plots Pie Charts Adding Titles and Legends Odds and Ends Wrapping Up Chapter 9 - Other Graphics Shapes Widgets Bar Codes Wrapping Up Chapter 10 - Creating Special Features in Your PDF File Annotations Bookmarks Page Transitions Encryption Interactive Forms Wrapping Up Part II - Tutorials and How-Tos Chapter 11 - Turning Data into PDFs Getting Started Creating the Base Template Class Refactoring the EOB Class Creating a Multipage Document Using Real Data Consuming XML Wrapping Up Chapter 12 - Custom Headers and Footers A Naive Header Putting the Header on Every Page Adding a Logo Configurable Logos Adding Page Numbers Adding a Page Number of Total Headers + Footers Wrapping Up Chapter 13 - Creating a PDF Library Accepting Different Data Formats Multipage Data Files Custom Stylesheets Configuring Your Application Adding a Graphical User Interface Finishing the User Interface Wrapping Up Chapter 14 - The PyPDF2 Package Installation Extracting Metadata from PDFs Extracting Text from PDFs Splitting PDFs Merging Multiple PDFs Together Rotating Pages Overlaying / Watermarking Pages PDF Encryption Wrapping Up Chapter 15 - The pdfrw Package Extracting Information from PDF Splitting Merging / Concatenating Rotating Overlaying / Watermarking Pages Scaling Combining pdfrw and ReportLab Wrapping Up Chapter 16 - Extracting and Exporting Data from PDFs Extracting Text with PDFMiner Exporting Text via pdf2txt.py Extracting Text with Slate Exporting Your Data Exporting to XML Exporting to JSON Exporting to CSV Extracting Images Wrapping Up Chapter 17 - Filling in PDF Forms Creating a Simple Form Merging Overlays Other Ways to Fill Forms Using the pdfforms Package Wrapping Up Chapter 18 - Converting Markup to PDF rst2pdf WeasyPrint Pandoc LaTeX Wrapping Up Chapter 19 - The PyFPDF Package Installation Basic Usage Working with Fonts Drawing Adding Images Multipage Documents Headers and Footers Tables Transform HTML to PDF Web2Py Templates Wrapping Up Appendix A - Adding SVG Files in ReportLab Dependencies Installation Usage Drawing on the Canvas Adding an SVG to a Flowable Scaling SVGs in ReportLab Using SVG Plots from matplotlib in ReportLab Using svg2pdf Wrapping Up Appendix B - Getting System Fonts The fontTools Package Getting the System’s Fonts Wrapping Up Appendix C - Creating a Color Demo Getting the Colors Wrapping Up Afterword and Thanks Introduction The Reportlab PDF Toolkit started life in the year 2000 by a company called “Reportlab Inc.”. Reportlab is now owned by “ReportLab Europe Ltd”. They produce the open source version of Reportlab. The Reportlab toolkit is actually the foundation of their commercial product, Report Markup Language which is available in their Reportlab PLUS package. This book is focused on the open source version of Reportlab. The Reportlab PDF Toolkit allows you to create in Adobe’s Portable Document Format (PDF) quickly and efficiently in the Python programming language. Reportlab is the defacto method of generating PDFs in Python. You can also use Reportlab to create charts and graphics in bimap and vector formats in addition to PDF. Reportlab is known for its ability to generate a PDF fast. In fact, Wikipedia chose Reportlab as their tool of choice for generating PDFs of their content. Anytime you click the “Download as PDF” link on the left side of a Wikipedia page, it uses Python and Reportlab to create the PDF! In this book, you will learn how to use Reportlab to create PDFs too. This book will be split into three sections. We will be covering the following topics in the first section: The canvas Drawing Working with fonts PLATYPUS Paragraphs Tables Other Flowables Graphics and More! In the second section, we will learn about data processing. The idea here is to take in several different data formats and turn them into PDFs. For example, it is quite common to receive data in XML or JSON. But learning how to take that information and turn it into a report is something that isn’t covered very often.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.