Latest recipes tagged "pdfwriter"http://code.activestate.com/recipes/tags/pdfwriter/new/2016-12-06T20:37:30-08:00ActiveState Code RecipesConvert wildcard text files to PDF with xtopdf (e.g. report*.txt) (Python) 2016-12-06T20:37:30-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580727-convert-wildcard-text-files-to-pdf-with-xtopdf-eg-/ <p style="color: grey"> Python recipe 580727 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/globbing/">globbing</a>, <a href="/recipes/tags/patterns/">patterns</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/wildcard/">wildcard</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to convert all text files matching a filename wildcard to PDF, using the xtopdf PDF creation toolkit. For example, if you specify report<em>.txt as the wildcard, all files in the current directory that match report</em>.txt, will be converted to PDF, each in a separate PDF file. The original text files are not changed.</p> <p>Here is a guide to installing and using xtopdf:</p> <p><a href="http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html" rel="nofollow">http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html</a></p> <p>More details on running the program, and sample output, are available here:</p> <p><a href="http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html" rel="nofollow">http://jugad2.blogspot.in/2016/12/xtopdf-wildcard-text-files-to-pdf-with.html</a></p> Batch conversion of text files to PDF with fileinput and xtopdf (Python) 2016-11-07T20:28:01-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580715-batch-conversion-of-text-files-to-pdf-with-fileinp/ <p style="color: grey"> Python recipe 580715 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/batch/">batch</a>, <a href="/recipes/tags/batchmode/">batchmode</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/text_processing/">text_processing</a>, <a href="/recipes/tags/utilities/">utilities</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to do a batch conversion of the content of multiple text files into a single PDF file, with a) an automatic page break after the content of each text file (in the PDF output), b) page numbering, and c) a header and footer on each page.</p> <p>It uses the fileinput module (part of the Python standard library), and xtopdf, a Python library for conversion of other formats to PDF.</p> <p>xtopdf is available here: <a href="https://bitbucket.org/vasudevram/xtopdf" rel="nofollow">https://bitbucket.org/vasudevram/xtopdf</a></p> <p>and a guide to installing and using xtopdf is here:</p> <p><a href="http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html" rel="nofollow">http://jugad2.blogspot.in/2012/07/guide-to-installing-and-using-xtopdf.html</a></p> <p>Here is a sample run of the program:</p> <p>python BTTP123.pdf text1.txt text2.txt text3.txt</p> <p>This will read the content from the three text files specified and write it into the PDF file specified, neatly formatted.</p> Generate a PDF cheat sheet for converting 0 to 255 between bin / oct / dec / hex (Python) 2016-10-10T20:40:48-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580706-generate-a-pdf-cheat-sheet-for-converting-0-to-255/ <p style="color: grey"> Python recipe 580706 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/hexadecimal/">hexadecimal</a>, <a href="/recipes/tags/octal/">octal</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/utility/">utility</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to generate a PDF cheat sheet, that contains a table for conversion of the numbers 0 to 255 (the numbers that can fit in one byte) between binary, octal, decimal and hexadecimal representations. The table has four columns, one for each of those bases, and 256 rows, for the numbers 0 to 255.</p> <p>TO use the table, you can look for a number, say in decimal, in the Dec(imal) column (or use the search function of your PDF viewer), then when you find it in some row, just look at the other 3 columns in that row, to find the value of that number in binary, octal and hexadecimal. And use the same procedure if starting with a number in any of the other three bases.</p> Functional D plus Python pipeline to generate PDF (Text) 2016-09-22T15:32:17-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580701-functional-d-plus-python-pipeline-to-generate-pdf/ <p style="color: grey"> Text recipe 580701 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/pipeline/">pipeline</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe is a command pipeline. The first component of the pipeline is a D language program that makes use of simple functional programming and template / generic programming features of D, to transform some input into the desired output. Both input and output are text. The D program writes the output to standard output, which is then read by a Python program that reads that as input via standard input, and converts it to PDF.</p> Create PDF control break reports with itertools.groupby and xtopdf (Python) 2016-07-23T22:17:29-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580692-create-pdf-control-break-reports-with-itertoolsgro/ <p style="color: grey"> Python recipe 580692 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/control/">control</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/grouping/">grouping</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/reportgeneration/">reportgeneration</a>, <a href="/recipes/tags/reporting/">reporting</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to create the classic control break style of report (a staple of data processing) using Python along with the groupby function from the itertools module, and xtopdf, a Python toolkit for PDF creation.</p> Publish a Windows Process List to PDF with xtopdf (Batch) 2015-12-27T20:45:32-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579142-publish-a-windows-process-list-to-pdf-with-xtopdf/ <p style="color: grey"> Batch recipe 579142 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/processes/">processes</a>, <a href="/recipes/tags/process_management/">process_management</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/windows/">windows</a>). </p> <p>This recipe shows how you can generate a Windows process list or task list (basically, a list of running processes, with some information about each of them), to a PDF file, using the Windows TASKLIST command along with the xtopdf toolkit. The list is sorted in ascending order of memory usage of the processes, before writing it to PDF.</p> <p>It differs somewhat from other xtopdf recipes, in that no additional code needs to be written, over and above what is already in the xtopdf package. We just have to use the needed commands there, in a series of commands or a pipeline.</p> <p>However, one can still write additional code, by modifying the program used (StdinToPDF.py), if needed, to customize the PDF output.</p> Publish Firebird SQL data to PDF with xtopdf (Python) 2015-12-01T19:45:18-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579131-publish-firebird-sql-data-to-pdf-with-xtopdf/ <p style="color: grey"> Python recipe 579131 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/firebird/">firebird</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to publish data from the Firebird RDBMS to PDF, using the xtopdf toolkit and the fbd Python driver for Firebird. Firebird is a cross-platform, open source RDBMS based on the former Interbase RDBMS from Borland, which they used to bundle with some of their developmemt tools, such as Borland C++ and Borland Delphi.</p> <p>The recipe reads data from a Firebird table, using the fbd Python driver for Firebird, and writes it to PDF, using the xtopdf toolkit. See:</p> <p><a href="http://jugad2.blogspot.in/p/xtopdf-pdf-creation-library.html" rel="nofollow">http://jugad2.blogspot.in/p/xtopdf-pdf-creation-library.html</a></p> <p>for information on xtopdf.</p> <p>It assumes that a Firebird database called test.fdb exists under /temp/firebird (C:\temp\firebird, really - the test was done on Windows), and that it has a contacts table with the structure shown in the code of the recipe.</p> <p>More details and sample output are here:</p> <p><a href="http://jugad2.blogspot.in/2014/01/by-vasudev-ram-pdf-firebird-is-cross.html" rel="nofollow">http://jugad2.blogspot.in/2014/01/by-vasudev-ram-pdf-firebird-is-cross.html</a></p> Generate a PDF invoice with xtopdf and Python (Python) 2015-10-07T18:02:46-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579108-generate-a-pdf-invoice-with-xtopdf-and-python/ <p style="color: grey"> Python recipe 579108 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/pdf_generation/">pdf_generation</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows the basics of how to generate invoices as PDF documents, using xtopdf, a Python toolkit for PDF creation. An example of creating a simple invoice through Python and xtopdf code is shown. </p> <p>xtopdf is available on Bitbucket at:</p> <p><a href="https://bitbucket.org/vasudevram/xtopdf" rel="nofollow">https://bitbucket.org/vasudevram/xtopdf</a></p> <p>and you can find many links with examples of using xtopdf, how to install it, etc., from this Google search:</p> <p><a href="https://google.com/search?q=xtopdf" rel="nofollow">https://google.com/search?q=xtopdf</a></p> <p>This sub-feed of my blog:</p> <p><a href="http://jugad2.blogspot.com/search/label/xtopdf" rel="nofollow">http://jugad2.blogspot.com/search/label/xtopdf</a></p> <p>gives access to all my blog posts labelled xtopdf.</p> Publish SQLite data to PDF using named tuples (Python) 2015-02-24T22:08:11-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579027-publish-sqlite-data-to-pdf-using-named-tuples/ <p style="color: grey"> Python recipe 579027 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/conversion/">conversion</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/sql/">sql</a>, <a href="/recipes/tags/sqlite/">sqlite</a>, <a href="/recipes/tags/sqlite3/">sqlite3</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to publish SQLite data to PDF, using named tuples from the collections module of Python, the sqlite3 library, and the xtopdf library for PDF generation.</p> Convert Excel to PDF with xlwings and xtopdf (Python) 2015-02-22T10:42:18-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579026-convert-excel-to-pdf-with-xlwings-and-xtopdf/ <p style="color: grey"> Python recipe 579026 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/excel/">excel</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/reportlab/">reportlab</a>, <a href="/recipes/tags/xlwings/">xlwings</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to get the text content from an Excel file and convert it to PDF, using the xlwings and xtopdf Python libraries. It also shows how to create an Excel file programmatically using xlwings.</p> Convert HTML text to PDF with Beautiful Soup and xtopdf (Python) 2015-01-28T22:20:53-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/579014-convert-html-text-to-pdf-with-beautiful-soup-and-x/ <p style="color: grey"> Python recipe 579014 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/reportgeneration/">reportgeneration</a>, <a href="/recipes/tags/reporting/">reporting</a>, <a href="/recipes/tags/reportlab/">reportlab</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to convert the text in an HTML document to PDF. It uses the Beautiful Soup and xtopdf Python libraries. Beautiful Soup is a library for HTML parsing and content extraction. xtopdf is a library for PDF creation from other formats, including text and many others.</p> Convert JSON to PDF with Python and xtopdf (Python) 2014-12-10T18:02:14-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578979-convert-json-to-pdf-with-python-and-xtopdf/ <p style="color: grey"> Python recipe 578979 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/pdfwriter/">pdfwriter</a>, <a href="/recipes/tags/sys/">sys</a>). </p> <p>This recipe show the basic steps needed to convert JSON input to PDF output, using Python and xtopdf, a PDF creation toolkit. xtopdf is itself written in Pytho, and uses the ReportLab toolkit internally.</p> <p>We set up some needed values, such as the output PDF file name, the font name and size, the header and footer, and the input lines for the body of the PDF output; all these values are passed in JSON format (in a single dictionary) to a function that uses those values to generate a PDF file with the desired content.</p> <p>The code is intentionally kept simple so as to require the least amount of code needed to demonstrate the techniques involved. But it can be generalized or extended to more complex situations.</p>