From 61801a7d9fac188af64f956887249cebd961aab2 Mon Sep 17 00:00:00 2001 From: Artur Barseghyan Date: Sun, 3 Dec 2023 01:13:52 +0100 Subject: [PATCH] Finish the PDF doc --- docs/conf.py | 2 ++ docs/creating_pdf.rst | 63 ++++++++++++++----------------------------- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0ca5ea9..a95a2e6 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -45,6 +45,8 @@ ".rst": "restructuredtext", } +pygments_style = "sphinx" + # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output diff --git a/docs/creating_pdf.rst b/docs/creating_pdf.rst index 87b712e..7723d3f 100644 --- a/docs/creating_pdf.rst +++ b/docs/creating_pdf.rst @@ -29,82 +29,72 @@ If you need bytes *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_bytes_1.py>` -The generated PDF will have 10,000 characters of text, which is about 2 pages. +The generated PDF will consist of a single page with little text on it. -If you want to provide texts to be used: +If you want to control number of pages created, you could: -- Increase the value of ``max_nb_chars`` accordingly. -- Set value of ``wrap_chars_after`` to 80 characters to force longer pages. -- Insert manual page breaks and other content. +- Pass the list of texts to be used in ``texts`` argument. +- Pass the number of pages to be created in ``nb_pages`` argument. ---- -See the example below for ``max_nb_chars`` tweak: +See the example below for ``texts`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/text_pdf_bytes_2.py :language: python - :lines: 11- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_bytes_2.py>` ---- -See the example below for ``wrap_chars_after`` tweak: +See the example below for ``nb_pages`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/text_pdf_bytes_3.py :language: python - :lines: 11- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_bytes_3.py>` If you need files ~~~~~~~~~~~~~~~~~ -There's a so called `graphic` PDF file provider available. Produced PDF files -would not contain text, so don't use it when you need text based content. -However, sometimes you just need a valid file in PDF format, without -caring much about the content. That's where a GraphicPdfFileProvider comes to -rescue: - .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/text_pdf_file_1.py :language: python - :lines: 2-3, 7- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_file_1.py>` -The generated file will contain a random graphic (consisting of lines and -shapes of different colours). - ---- -One of the most useful arguments supported is ``size``. +With ``texts`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/text_pdf_file_2.py :language: python - :lines: 7- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_file_2.py>` ---- -One of the most useful arguments supported is ``size``. +With ``nb_pages`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/text_pdf_file_3.py :language: python - :lines: 7- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/text_pdf_file_3.py>` @@ -122,56 +112,43 @@ If you need bytes *See the full example* :download:`here <_static/examples/creating_pdf/graphic_pdf_bytes_1.py>` -The generated PDF will have 10,000 characters of text, which is about 2 pages. - -If you want PDF with more pages, you could either: +The generated PDF will consist of a single page with a colored square on it. -- Increase the value of ``max_nb_chars`` accordingly. -- Set value of ``wrap_chars_after`` to 80 characters to force longer pages. -- Insert manual page breaks and other content. +If you want PDF with more pages, provide the ``nb_pages`` argument. ---- -See the example below for ``max_nb_chars`` tweak: +See the example below for ``nb_pages`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/graphic_pdf_bytes_2.py :language: python - :lines: 11- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/graphic_pdf_bytes_2.py>` If you need files ~~~~~~~~~~~~~~~~~ -There's a so called `graphic` PDF file provider available. Produced PDF files -would not contain text, so don't use it when you need text based content. -However, sometimes you just need a valid file in PDF format, without -caring much about the content. That's where a GraphicPdfFileProvider comes to -rescue: - .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/graphic_pdf_file_1.py :language: python - :lines: 2-3, 7- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/graphic_pdf_file_1.py>` -The generated file will contain a random graphic (consisting of lines and -shapes of different colours). - ---- -One of the most useful arguments supported is ``size``. +With ``nb_pages`` tweak: .. container:: jsphinx-download .. literalinclude:: _static/examples/creating_pdf/graphic_pdf_file_2.py :language: python - :lines: 7- + :lines: 3- *See the full example* :download:`here <_static/examples/creating_pdf/graphic_pdf_file_2.py>`