Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Tuesday, February 25, 2020

Did You K? PDF is an Open Standard! Manipulate PDFs with python - tutorial

https://realpython.com/courses/pdf-python/

pyPDF2 - that's hot stuff!
  1. Introduction
  2. pyPDF2 History, an Alternative and Installation
  3. Metadata Extraction and Rotating Pages
  4. Merging and Splitting PDFs
  5. Adding Watermarks and Encrypting PDFs
  6. Conclusion and Further Reading
Alternatives to pyPDF2 (Phasit) - pdfrw by Patrick Maupin (good with ReportLab, but no encryption).

Actually, this tutorial is members only :(

How would you add links in a PDF : https://stackoverflow.com/questions/28796832/add-links-in-pdf

But, Al Sweigart, on the advice of Alan Dershowitz, has made his Udemy companion (to the book) is free in March - just log out of Udemy, go to his website and then click on the link, and you'll see it's free.. click on buy and checkout, it's $0.

Friday, December 28, 2018

Hans Fangohr++ aka A Better Spyder Tutorial

Why not anticipate users' problems - especially when you give them advanced tips?

He says, set IPython Console to do symbolic math (Tools > Preferences) and then you'll see cuter stuff.

He doesn't say :

Start a new console.
What happens if you run into ..

These commands were executed:
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)

Warning: pylab (numpy and matplotlib) and symbolic math (sympy) are both
enabled at the same time. Some pylab functions are going to be overrided by
the sympy module (e.g. plot)


expr = (x + y) ** 3
Traceback (most recent call last):

  File "<ipython-input-1-530ade24fb9f>", line 1, in <module>
    expr = (x + y) ** 3

NameError: name 'x' is not defined

In short, what an ass!

Fortunately, we have some online angels :

https://github.com/spyder-ide/spyder/issues/3255
https://stackoverflow.com/questions/43915513/how-to-get-latex-style-output-from-sympy-in-spyder-ipython-console
https://github.com/nteract/hydrogen/issues/1119

I go to Start > Anaconda > Anaconda Prompt and then do

> conda install -c conda-forge miktex

Dat fix it? No!!

What did?

The commands that *IT* (see above) says *were* executed apparently weren't! So, you have to manually do :

x, y, z, t = symbols( 'x y z t') 
only to find that

NameError: name 'symbols' is not defined

And then,

from sympy import symbols

That gets

expr = (x + y)**3
To NOT complain.

Now, when you do expr, you get the Unicode formatted pretty thing with the 3 really looking like a superscript. Not what you want obviously :)

So, what does work :

from sympy import init_printing
init_printing()

Now, when you do

expr

You get