blob: 61d967fd77836404d3663f97d7930f36f0a30e16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
First Steps
===========
Installation
------------
The easiest way to use pydyf is to install it in a Python `virtual
environment`_. When your virtual environment is activated, you can then install
pydyf with pip_::
pip install pydyf
.. _virtual environment: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
.. _pip: https://pip.pypa.io/
Create a PDF
------------
.. code-block:: python
import pydyf
document = pydyf.PDF()
# Add an empty page
document.add_page(pydyf.Dictionary({
'Type': '/Page',
'Parent': document.pages.reference,
'MediaBox': pydyf.Array([0, 0, 200, 200]),
}))
# Write to document.pdf
with open('document.pdf', 'wb') as f:
document.write(f)
|