Popular recipes tagged "meta:license=gpl3" but not "cbz"http://code.activestate.com/recipes/tags/meta:license=gpl3-cbz/2017-06-18T17:43:47-07:00ActiveState Code RecipesCreate Calendars on PDF with a few lines (Python) 2017-06-13T10:57:34-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580805-create-calendars-on-pdf-with-a-few-lines/ <p style="color: grey"> Python recipe 580805 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/calendar/">calendar</a>, <a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>). Revision 2. </p> <p>PyMuPDF (fitz) provides easy to use ways to create PDF documents out of simple texts.</p> <p>An example is the text output of Python's calendar module. Here we take a starting year as script parameter and output a 3-page (A4 landscape) document with calendars for this and the following two years - in less than 20 lines of code.</p> How to Create a PDF with a Caustic Drawing (Python) 2017-06-18T17:43:47-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580806-how-to-create-a-pdf-with-a-caustic-drawing/ <p style="color: grey"> Python recipe 580806 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>). </p> <p>Just a little demo on how to create simple drawings with PyMuPDF.</p> <p>This script simulates what you see looking into your coffee mug, early in the morning after a long night of programming ...</p> Rotate a PDF page in 3 lines (Python) 2016-11-06T11:33:59-08:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580713-rotate-a-pdf-page-in-3-lines/ <p style="color: grey"> Python recipe 580713 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>). Revision 2. </p> <p>PyMuPDF v1.9.3 now supports several new features for manipulating PDFs.</p> <p>Here is an example to rotate a page with just a few lines of Python code.</p> Extract images of a PDF - optionally by page using PyMuPDF / fitz (Python) 2016-09-28T12:03:59-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580703-extract-images-of-a-pdf-optionally-by-page-using-p/ <p style="color: grey"> Python recipe 580703 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/png/">png</a>). </p> <p>Two small scripts to extract images contained in a PDF document as PNG files. (1) Script 1 extracts <strong>all</strong> images (2) Script 2 extracts only images that are referenced by a page</p> PDF wrapper for FileOptimizer (Python) 2016-10-29T20:22:27-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580711-pdf-wrapper-for-fileoptimizer/ <p style="color: grey"> Python recipe 580711 by <a href="/recipes/users/4191581/">Harald Lieder</a> (<a href="/recipes/tags/fileoptimizer/">fileoptimizer</a>, <a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/optimization/">optimization</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>). </p> <p>Among dozens of other filetypes, FileOptimizer also compresses PDFs - often significantly. The issue is that the used plugin <em>smpdf</em> is free for non-commercial use only and it annoyingly <strong>also overwrites metadata</strong> information to state this.</p> <p>The following tool remedies these metadata changes (but not the license situation!).</p> Decrypt a PDF using fitz / MuPDF (PyMuPDF) (Python) 2016-03-17T12:22:10-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580627-decrypt-a-pdf-using-fitz-mupdf-pymupdf/ <p style="color: grey"> Python recipe 580627 by <a href="/recipes/users/4191581/">Harald Lieder</a> (<a href="/recipes/tags/decompression/">decompression</a>, <a href="/recipes/tags/decryption/">decryption</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/repair/">repair</a>). </p> <p>It's more a code snippet. Shows how to dynamically check whether a PDF is password protected. If it is, decrypt it and save it back to disk un-encrypted.</p> Create Tiles of Images with fitz / MuPDF (PyMuPDF) (Python) 2016-04-26T19:54:31-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580629-create-tiles-of-images-with-fitz-mupdf-pymupdf/ <p style="color: grey"> Python recipe 580629 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/png/">png</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>, <a href="/recipes/tags/tiles/">tiles</a>). Revision 4. </p> <p>Take an image file (like PNG) and create a new one consisting of arbitrary tiles of the original (or overlay an existing image with selective tiles of another).</p> PyOOCalc - Python Libre/Open Office Calc Interface API (UNO) (Python) 2016-01-10T13:12:53-08:00Yuriihttp://code.activestate.com/recipes/users/4193384/http://code.activestate.com/recipes/579147-pyoocalc-python-libreopen-office-calc-interface-ap/ <p style="color: grey"> Python recipe 579147 by <a href="/recipes/users/4193384/">Yurii</a> (<a href="/recipes/tags/openoffice/">openoffice</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python3/">python3</a>). </p> <p>Create Libre/Open Office Calc documents, reports on Python</p> New Version: GUI PDF Table of Contents Editor using fitz / MuPDF, wxPython (Python) 2016-06-22T11:34:20-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580623-new-version-gui-pdf-table-of-contents-editor-using/ <p style="color: grey"> Python recipe 580623 by <a href="/recipes/users/4191581/">Harald Lieder</a> (<a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/toc/">toc</a>). Revision 2. </p> <p>Create or modify the bookmarks list of a PDF (ToC - table of contents). Supports arbitrary hierarchy levels. Display PDF while editing to control bookmark targets. PDF meta data are maintainable. Save PDF under the same or a different name.</p> PDF Joiner / Splitter using wxPython, PyMuPDF (fitz / MuPDF) (Python) 2016-03-15T19:07:35-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580622-pdf-joiner-splitter-using-wxpython-pymupdf-fitz-mu/ <p style="color: grey"> Python recipe 580622 by <a href="/recipes/users/4191581/">Harald Lieder</a> (<a href="/recipes/tags/join/">join</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/split/">split</a>). </p> <p>Full featured PDF joiner. Join several PDF files into one output PDF. Page ranges can be specified as well as page orientation for each output page range. Tables of contents are intelligently preserved for each page range (can also be switched off). Output PDF metadata editable.</p> nbitarray (Python) 2016-04-21T14:12:33-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/580649-nbitarray/ <p style="color: grey"> Python recipe 580649 by <a href="/recipes/users/4184815/">yota</a> . </p> <p>library to store n bits data (n &gt; 0) in a python array</p> Create Sierpinski Carpet (Fractal) FAST (Python) 2016-03-16T08:56:08-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580624-create-sierpinski-carpet-fractal-fast/ <p style="color: grey"> Python recipe 580624 by <a href="/recipes/users/4193772/">Jorj X. McKie</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/sierpinski/">sierpinski</a>). </p> <p>Create a Sierpinski carpet using MuPDF's graphics library fitz (binding PyMuPDF) at high speed.</p> Add function to Python's __builtin__ module through C API (C) 2015-10-16T12:11:58-07:00airweenhttp://code.activestate.com/recipes/users/4192997/http://code.activestate.com/recipes/579110-add-function-to-pythons-__builtin__-module-through/ <p style="color: grey"> C recipe 579110 by <a href="/recipes/users/4192997/">airween</a> (<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/builtins/">builtins</a>, <a href="/recipes/tags/c/">c</a>, <a href="/recipes/tags/exten/">exten</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Add function to __builtin__ module through C API</p> <p>Sometimes it need to embedding a Python script to a C code, and it references to a function, which also provided by the same C code. Then you have to import the module, as you defined in your C code.</p> <p>But this import would be skipped, if you add your function to your __builtin__ module. In Python3 (3.5), there is the PyModule_AddFunctions() function, but in the previous versions, you can make it like this snippet.</p> <p>See these recipes:</p> <p>Makefile: <a href="https://code.activestate.com/recipes/579111-add-function-to-__builtin__-module-through-c-api-c/" rel="nofollow">https://code.activestate.com/recipes/579111-add-function-to-__builtin__-module-through-c-api-c/</a></p> <p>Python script: <a href="https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/" rel="nofollow">https://code.activestate.com/recipes/579112-add-function-to-__builtin__-module-through-c-api-c/</a></p> ed25519 (Python) 2015-09-21T12:58:34-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/579102-ed25519/ <p style="color: grey"> Python recipe 579102 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/cryptography/">cryptography</a>). Revision 2. </p> <p>This is a re-implementation of the ed25519 signature algorithm as proposed on this page : <a href="http://ed25519.cr.yp.to/python/ed25519.py." rel="nofollow">http://ed25519.cr.yp.to/python/ed25519.py.</a></p> <p>Do not use for production, only for the eyes o_O</p> <p>Code is tab indented, space indentation kills kitten...</p> least square fitting (Python) 2015-10-03T15:32:28-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/579106-least-square-fitting/ <p style="color: grey"> Python recipe 579106 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/fitting/">fitting</a>). Revision 2. </p> <p>a generic python code to fit points to a given curve, was made for a paraboloid, but can be easily expanded to many kind of curves</p> pick all combinations of items in buckets (Python) 2015-09-05T07:39:42-07:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/579098-pick-all-combinations-of-items-in-buckets/ <p style="color: grey"> Python recipe 579098 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/combinatorics/">combinatorics</a>). </p> <p>Let be a number of buckets, containing each, a variable number of items. This function return all combinations possible of one item picked out of each bucket</p> <p>example, with three buckets {ba, be, bi}, {ka, ko, ku, ke} and {to, ty}, the function enumerate as such: </p> <pre class="prettyprint"><code> 0. ba-ka-to 1. ba-ka-ty 2. ba-ko-to 3. ba-ko-ty 4. ba-ku-to 5. ba-ku-ty 6. ba-ke-to 7. ba-ke-ty 8. be-ka-to 9. be-ka-ty 10. be-ko-to 11. be-ko-ty 12. be-ku-to 13. be-ku-ty 14. be-ke-to 15. be-ke-ty 16. bi-ka-to 17. bi-ka-ty 18. bi-ko-to 19. bi-ko-ty 20. bi-ku-to 21. bi-ku-ty 22. bi-ke-to 23. bi-ke-ty </code></pre> Simple video with ctypes and Xvid (Tkinter,pygame,...) (Python) 2015-06-29T13:59:38-07:00Jiri Justrahttp://code.activestate.com/recipes/users/4192188/http://code.activestate.com/recipes/579073-simple-video-with-ctypes-and-xvid-tkinterpygame/ <p style="color: grey"> Python recipe 579073 by <a href="/recipes/users/4192188/">Jiri Justra</a> (<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/video/">video</a>, <a href="/recipes/tags/xvid/">xvid</a>). </p> <p>This is simple library for playing avi video clips. Videos must be SOUNDLESS (and maybe Xvid encoded wont hurt), to work it properly. I am using it to play intro. It suites good to this purpose, since it can play one clip at a time only.</p> smart copy (Python) 2015-02-06T09:45:12-08:00yotahttp://code.activestate.com/recipes/users/4184815/http://code.activestate.com/recipes/579020-smart-copy/ <p style="color: grey"> Python recipe 579020 by <a href="/recipes/users/4184815/">yota</a> (<a href="/recipes/tags/shutil/">shutil</a>). </p> <p>take a glob expression, a source directory and a destination directory to copy each files matching the glob in the appropriate directory</p> <pre class="prettyprint"><code>glob = */*.txt src_dir = ./a/b dst_dir = /z/x/y </code></pre> <p>if the glob match a file <code>./a/b/c/foo.txt</code>, it will copy it in <code>/z/x/y/c/foo.txt</code> (and create the missing directory if needed)</p> <p>Require Python3.4, code tab indented</p> asskick.py (Python) 2014-09-20T08:16:57-07:00p@ntut$http://code.activestate.com/recipes/users/4183895/http://code.activestate.com/recipes/578940-asskickpy/ <p style="color: grey"> Python recipe 578940 by <a href="/recipes/users/4183895/">p@ntut$</a> (<a href="/recipes/tags/kickass/">kickass</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/torrents/">torrents</a>). </p> <p>URL: <a href="http://pantuts.com/2014/09/20/asskick-py-python-script-search-download-torrents-kickass/" rel="nofollow">http://pantuts.com/2014/09/20/asskick-py-python-script-search-download-torrents-kickass/</a></p> <p>Python script to search and download torrents from KickAss torrents.</p> Pasting python data into a spread sheet (Python) 2014-09-16T15:49:07-07:00Tomas Nordinhttp://code.activestate.com/recipes/users/4189558/http://code.activestate.com/recipes/578933-pasting-python-data-into-a-spread-sheet/ <p style="color: grey"> Python recipe 578933 by <a href="/recipes/users/4189558/">Tomas Nordin</a> (<a href="/recipes/tags/clipboard/">clipboard</a>, <a href="/recipes/tags/spreadsheet/">spreadsheet</a>). Revision 3. </p> <p>A smooth way to paste data you are working with in python into a spreadsheet. Put into the system clipboard, select a cell and do ctrl-v (at least with ms office and libre-office).</p>