-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6c17e4
commit e2e719b
Showing
23 changed files
with
1,595 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,3 +135,4 @@ Temporary Items | |
.envrc | ||
*.csv | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
User guide | ||
========== | ||
|
||
Documents and pages | ||
------------------- | ||
|
||
PDF documents consist of pages, which may have graphical context (e.g. text). | ||
Below shows an example of creating a document and writing it to a file. | ||
|
||
.. code-block:: python | ||
>>> from pdfje import Document, Page, Text | ||
>>> Document([ | ||
... Page([Text("Hello", at=(200, 700)), Text("World", at=(300, 670))]), | ||
... Page(), # empty page | ||
... Page([Text("This is the last page!", at=(300, 600))]), | ||
... ]).to_path('hello.pdf') | ||
Fonts and unicode | ||
----------------- | ||
|
||
There are two types of fonts: | ||
|
||
1. **Standard fonts** are included in all PDF readers. | ||
The downside is that these fonts only support a very | ||
limited set of unicode characters. | ||
The standard fonts are: | ||
|
||
- Helvetica | ||
- Times Roman | ||
- Courier | ||
- Symbol | ||
- ZapfDingBats | ||
|
||
Below is an example of using different standard fonts: | ||
|
||
.. code-block:: python | ||
>>> from pdfje import Text, courier, helvetica | ||
>>> Text("Hello Helvetica", font=helvetica) | ||
>>> Text("Ciao, Courier", font=courier) | ||
.. warning:: | ||
|
||
The standard fonts only support characters within the ``cp1252`` encoding | ||
(i.e. ASCII plus some common western european characters). | ||
This is a limitation of the PDF format, not ``pdfje``. | ||
Characters outside this set will be displayed as ``?``. | ||
If you need broader unicode support, | ||
you will need to use :ref:`an embedded font<embedded-fonts>`. | ||
|
||
.. _embedded-fonts: | ||
|
||
2. **Embedded fonts** are included in the PDF file itself. | ||
To use an embedded font, you will need to download its TrueType | ||
(``.ttf``) font file and tell ``pdfje`` where to find it. | ||
|
||
Here is an example of using the DejaVu font | ||
|
||
.. code-block:: python | ||
>>> from pdfje import Text, Font | ||
>>> dejavu = Font.from_path("path/to/DejaVuSansCondensed.ttf") | ||
>>> Text("We meet again, DejaVu!", font=dejavu) | ||
.. note:: | ||
|
||
To save space, only the parts of the font that are actually used will | ||
be embedded in the document. | ||
This standard practice is called "subsetting". | ||
|
||
.. note:: | ||
|
||
Any unicode characters for which a font has no representation | ||
will be displayed as a 'missing character' box. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ Contents | |
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
guide.rst | ||
api.rst | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.