create pdfs from markup with python
play

Create PDFs from Markup with Python Lorna Mitchell Meet rst2pdf - PowerPoint PPT Presentation

Create PDFs from Markup with Python Lorna Mitchell Meet rst2pdf https://rst2pdf.org Open source, Python project Accepts ReStructured Text format, outputs PDF Useful for: reports, slide decks, ... all sorts @lornajane ReStructured


  1. Create PDFs from Markup with Python Lorna Mitchell

  2. Meet rst2pdf • https://rst2pdf.org • Open source, Python project • Accepts ReStructured Text format, outputs PDF • Useful for: reports, slide decks, ... all sorts @lornajane

  3. ReStructured Text @lornajane

  4. ReStructured Text A text-based markup format (like markdown, but better). Use your favourite text editor! Use source control. @lornajane

  5. A note on source control Source control is for people who: • don't like losing work • sometimes make mistakes • might want to collaborate with others some day @lornajane

  6. ReStructured Text Examples Slide with bullets: Meet ``rst2pdf`` ============== * http://rst2pdf.github.io * Open source, Python project * Accepts ReStructured Text format, outputs PDF * Useful for: reports, slide decks, ... all sorts .. raw:: pdf PageBreak titlePage @lornajane

  7. ReStructured Text Examples Code block: .. code-block:: python def inbound_sms(): if request.is_json: pprint(request.get_json()) Image: .. image:: images/postman.png :width: 26cm @lornajane

  8. Portable Document Format @lornajane

  9. Portable Document Format PDF is my preferred file format for things that: • should be well presented • need not be edited It is a self-contained, open format, fonts can be embedded, and there are loads of tools that work with it. @lornajane

  10. PDF Tools The best thing about PDF? The tools! • pdftk for manipulating PDFs (including the surprise later in this slide deck) • pdfjam for utterly painless handouts • pdfpc for presenting from PDF including speaker notes, timer etc @lornajane

  11. Meet rst2pdf ReStructured Text Create PDFs from A text-based markup format (like markdown, but better). • https://rst2pdf.org • Open source, Python project ReStructured Text Markup with Python Use your favourite text editor! • Accepts ReStructured Text format, outputs PDF • Useful for: reports, slide decks, ... all sorts Use source control. Lorna Mitchell @lornajane @lornajane @lornajane A note on source control ReStructured Text Examples ReStructured Text Examples Source control is for people who: Slide with bullets: Code block: • don't like losing work Meet ``rst2pdf`` .. code-block:: python Portable Document Format ============== • sometimes make mistakes def inbound_sms(): * http://rst2pdf.github.io if request.is_json: • might want to collaborate with others some day * Open source, Python project pprint(request.get_json()) * Accepts ReStructured Text format, outputs PDF * Useful for: reports, slide decks, ... all sorts Image: .. raw:: pdf .. image:: images/postman.png :width: 26cm PageBreak titlePage @lornajane @lornajane @lornajane @lornajane Portable Document Format PDF Tools How to rst2pdf PDF is my preferred file format for things that: The best thing about PDF? The tools! Everything you need is here: https://rst2pdf.org/ • should be well presented • pdftk for manipulating PDFs (including the surprise later in rst2pdf this slide deck) • need not be edited pip install rst2pdf • pdfjam for utterly painless handouts Or on GitHub https://github.com/rst2pdf/rst2pdf • pdfpc for presenting from PDF including speaker notes, It is a self-contained, open format, fonts can be embedded, and timer etc there are loads of tools that work with it. @lornajane @lornajane @lornajane @lornajane

  12. rst2pdf @lornajane

  13. How to rst2pdf Everything you need is here: https://rst2pdf.org/ pip install rst2pdf Or on GitHub https://github.com/rst2pdf/rst2pdf @lornajane

  14. How to rst2pdf Everything you need is here: https://rst2pdf.org/ pip install rst2pdf Or on GitHub https://github.com/rst2pdf/rst2pdf @lornajane

  15. How to rst2pdf Use rst2pdf like this: rst2pdf awesomeness.rst You can supply styles, layouts, output file name but ... this is basically it @lornajane

  16. Separate Content and Style I love this approach! • Style is always consistent throughout document. • Styles can be re-used between documents. • Content can be re-used between documents. • Documents can VERY easily be re-styled (is my contrast OK?). • You can grep for content. Extra bonus: tool itself is also separate @lornajane

  17. Code Samples It's python, and uses pygments: def inbound_sms(): if request.is_json: pprint(request.get_json()) else: data = dict(request.form) or dict(request.args) pprint(data) return ('', 204) https://github.com/nexmo-community/nexmo-python-quickstart @lornajane

  18. The rst2pdf Project @lornajane

  19. The rst2pdf Project Current version: 0.94 Released: 24th January 2019 Previous version: 0.93 Released: 19th December 2012 @lornajane

  20. Project Status • Python 2 only at this moment • Working test suite and decent test coverage • Good documentation, new website • includes examples, open an issue if you have a question @lornajane

  21. How do you test a PDF? 1. Generate a PDF that is "right" 2. Create a hash of that file 3. All future tests generate and hash the PDF for this test and compare it • it's a selection of hashes; different tools make different outputs @lornajane

  22. rst2pdf Use a text editor. Make a PDF. https://rst2pdf.org @lornajane

  23. Resources rst2pdf • https://rst2pdf.org • https://github.com/rst2pdf/rst2pdf • https://github.com/ralsina/rst-cheatsheet Me • https://lornajane.net • @lornajane @lornajane

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend