Probably the easiest way to create a pdf with Python3

From the conclusion

  1. Install wkhtml2pdf
  2. Format the document with html + css
  3. Convert to pdf with wkhtml2pdf

that's all. Oh, it's not related to Python!

Anyway, the implementation of the pdf output function was completed in about 2 hours, so I think it's good when you don't have time.

Reference: http://tdoc.info/blog/2012/09/19/wkhtmltopdf.html

Good points and bad points

good

-It's super easy because you can create documents with html + css. -Especially, it has a good affinity when adding a pdf output function to a Web application. If you can see it in a browser, you can convert it to pdf, so all you have to do is create a "document page". Templates can be maintained in the same line as other general pages.

bad

-Since it is html + css, control is limited. Mainly in the vertical direction. It can be used only when the bottom margin of the document does not matter.

How to call wkhtml2pdf from Python

All you have to do is hit the command, but the Python wrapper Python-wkhtml2pdf was super convenient. Python2 only, but it can be handled in a few minutes. I forked and put the Python 3 compatible guy here https://github.com/yasunori/python-wkhtmltopdf/tree/myFeatureSpike The reason why I didn't publicize it is that it was originally targeted at Python 2.5, and I'm afraid. print or something. __future__ I can't use it, what should I do with this? Please tell me a great person.

capture

PDF creation in Python, other famous methods

Sphinx Speaking of duments in Python, but this time I wanted to do it more quickly, so I gave up. http://tk0miya.hatenablog.com/entry/20111208/p1

reportlab If you search with Python or pdf, you will find this, but since it is Python2, I will not do it this time. I thought it was compatible with Python3! http://www.reportlab.com/software/documentation/relnotes/30/ Let's try it next time ...

The end

Recommended Posts

Probably the easiest way to create a pdf with Python3
The easiest way to use OpenCV with python
Steps to create a Twitter bot with python
Introduction to Python with Atom (on the way)
What is the fastest way to create a reverse dictionary in python?
Create a directory with python
How to create a submenu with the [Blender] plugin
Convert the image in .zip to PDF with Python
[Python] How to create a 2D histogram with Matplotlib
Create folders from '01' to '12' with python
Create a Mastodon bot with a function to automatically reply with Python
Experiment to make a self-catering PDF for Kindle with Python
Create a virtual environment with Python!
Create a Twitter BOT with the GoogleAppEngine SDK for Python
The usual way to add a Kernel with Jupyter Notebook
[Python] The first step to making a game with Pyxel
Create a message corresponding to localization with python translation string
5 Ways to Create a Python Chatbot
Try to create a waveform (audio spectrum) that moves according to the sound with python
The easiest way to make Flask
The easiest way to try PyQtGraph
Explaining how to make LINE BOT in the world's easiest way (2) [Preparing a bot application in a local environment with Django in Python]
Easy way to round off to the nearest whole number with python3
[Introduction to Python] How to split a character string with the split function
Create a shell script to run the python file multiple times
Create a color picker for the color wheel with Python + Qt (PySide)
Try to create a python environment with Visual Studio Code & WSL
I tried to create a list of prime numbers with python
How to create a heatmap with an arbitrary domain in Python
I wanted to solve the ABC164 A ~ D problem with Python
How to send a request to the DMM (FANZA) API with python
Create a REST API to operate dynamodb with the Django REST Framework
The fastest way to get camera images regularly with python opencv
Create a compatibility judgment program with the random module of python.
Create a Python function decorator with Class
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Search the maze with the python A * algorithm
Create a word frequency counter with Python 3.4
A way to understand Python duck typing
The road to compiling to Python 3 with Thrift
[Python] Create a program to delete line breaks in the clipboard + Register as a shortcut with windows
[Cloudian # 3] Try to create a new object storage bucket with Python (boto3)
[Introduction to Udemy Python3 + Application] 47. Process the dictionary with a for statement
[Python] Explains how to use the range function with a concrete example
Create a tool to automatically furigana with html using Mecab from Python3
[Introduction to Python] How to sort the contents of a list efficiently with list sort
Steps to create a Python virtual environment with VS Code on Windows
[Introduction to Python] How to write a character string with the format function
[Outlook] I tried to automatically create a daily report email with Python
Create a record with attachments in KINTONE using the Python requests module
3. Natural language processing with Python 1-2. How to create a corpus: Aozora Bunko
[Python] List Comprehension Various ways to create a list
Edit Excel from Python to create a PivotTable
How to read a CSV file with Python 2/3
The fastest way for beginners to master Python
Send a message to LINE with Python (LINE Notify)
Library comparison summary to generate PDF with Python
[Python] Get the files in a folder with Python