Skip to content

Commit

Permalink
More on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Dec 3, 2023
1 parent 8795fd4 commit 568100a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/creating_docx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ See the example below for ``nb_pages`` tweak:
:lines: 3-

*See the full example*
:download:`here <_static/examples/creating_pdf/text_bytes_3.py>`
:download:`here <_static/examples/creating_docx/docx_bytes_3.py>`

If you need files
-----------------
Expand Down
45 changes: 30 additions & 15 deletions docs/creating_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,60 @@ Currently, 4 image formats are supported:

Generating images as bytes
--------------------------
See the following full functional snippet for generating images using `imgkit`_.
See the following full functional snippet for generating a ``PNG`` image.

.. container:: jsphinx-download

.. literalinclude:: _static/examples/creating_images/imgkit_1.py
.. literalinclude:: _static/examples/creating_images/png_bytes_1.py
:language: python

*See the full example*
:download:`here <_static/examples/creating_images/imgkit_1.py>`
:download:`here <_static/examples/creating_images/png_bytes_1.py>`

The generated PNG image will have 10,000 characters of text. The generated image
will be as wide as needed to fit those 10,000 characters, but newlines are
respected.
The generated ``PNG`` image will be an image filled with a given color of a
size 100x100 px.

----

If you want image to be less wide, set value of ``wrap_chars_after`` to 80
characters (or any other number that fits your needs). See the example below:
If you want image of a different size or color, provide ``size``
(``Tuple[int, int]``) and color (``Tuple[int, int, int]``) arguments along.
See the example below:

.. container:: jsphinx-download

.. literalinclude:: _static/examples/creating_images/imgkit_2.py
.. literalinclude:: _static/examples/creating_images/png_bytes_2.py
:language: python
:lines: 8-
:lines: 3-

*See the full example*
:download:`here <_static/examples/creating_images/imgkit_2.py>`
:download:`here <_static/examples/creating_images/png_bytes_2.py>`

Generating files
----------------
Generate a ``PNG`` image.

To have a longer text, increase the value of ``max_nb_chars`` accordingly.
See the example below:
.. container:: jsphinx-download

.. literalinclude:: _static/examples/creating_images/png_file_1.py
:language: python
:lines: 8-

*See the full example*
:download:`here <_static/examples/creating_images/png_file_1.py>`

----

With ``size`` and ``color`` tweaks:

.. container:: jsphinx-download

.. literalinclude:: _static/examples/creating_images/imgkit_3.py
.. literalinclude:: _static/examples/creating_images/png_file_2.py
:language: python
:lines: 8-

*See the full example*
:download:`here <_static/examples/creating_images/imgkit_3.py>`
:download:`here <_static/examples/creating_images/png_file_2.py>`

---

All other formats (``SVG``, ``BMP`` and ``GIF``) work in exact same way.
4 changes: 4 additions & 0 deletions docs/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ Contents:
creating_images
creating_pdf
creating_docx
factories
security
contributor_guidelines
code_of_conduct
changelog
package

0 comments on commit 568100a

Please sign in to comment.