You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
5.1 KiB

2 years ago
2 years ago
4 years ago
1 year ago
4 years ago
3 years ago
4 years ago
3 years ago
1 year ago
4 years ago
2 years ago
4 years ago
1 year ago
4 years ago
2 years ago
1 year ago
  1. How To Create PDF (on macOS)
  2. ============================
  3. **PDF file can also be purchased here: https://transactions.sendowl.com/products/78175486/4422834F/view**
  4. Setup
  5. -----
  6. * Install Adobe Acrobat Pro DC.
  7. * Copy headers and footers from `pdf/acrobat/` folder to `/Users/<username>/Library/Preferences/Adobe/Acrobat/DC/HeaderFooter/`.
  8. * Run `./parse.js` and commit changes.
  9. Printing to PDF
  10. ---------------
  11. ### Normal PDF
  12. * Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
  13. * Then replace the index and footer with contents of `pdf/index_for_pdf.html` file and save.
  14. * Disable internet connection and open the file in Chromium version 108.0.5328.0 (later versions will render the site incorrectly after index is added) with 'Cache killer' extension enabled.
  15. * Right click on the border of the site and select inspect. Select `<body>` element under 'Elements' tab and change top margin from 16 to 5 in 'Styles' tab.
  16. * Change brightness of comments by right clicking on one of them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows. Change lightness (L) percentage to 77%.
  17. * Change the brightness of text to 13%.
  18. * Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty).
  19. * Check if plots were rendered correctly.
  20. ### PDF optimized for laser color printing
  21. * Run `./parse.js` again.
  22. * Change all links in text to normal text and add a page number in brackets like that: '(p. <page_num>)' by running './pdf/remove_links.py' (Links can be found with this regex: `<strong>.*a href.*</strong>`).
  23. * Open `index.html` in text editor and first remove element `<p><br></p>` before the `<h1>Libraries</h1>`.
  24. * Then replace the index and footer with contents of `pdf/index_for_pdf_print.html` file and save.
  25. * Disable internet connection and open the file in Chromium version 108.0.5328.0 (later versions will render the site incorrectly after index is added) with 'Cache killer' extension enabled.
  26. * Right click on the border of the site and select inspect. Select `<body>` element under 'Elements' tab and change top margin from 16 to 5 in 'Styles' tab.
  27. * Change brightness of elements by right clicking on them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows.
  28. * Change lightness (L) percentage to:
  29. * 0% for the text.
  30. * 87% for the gray line on the left side of the code.
  31. * 89% for the gray hash characters by the titles
  32. * 37% for the red text and function names (they use their own red).
  33. * 60% for the blue text and the text in the contents (it uses its own blue), but leave color of decorators and the `>>>` intact.
  34. * 58% for the comments.
  35. * Individually change brightness of every comment line that starts with: `# $ pip3 install` and of comments in basic script template to 57%, by adding `color: hsla(0, 0%, 57%, 1);` to their element.style.
  36. * Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty).
  37. * Check if plots were rendered correctly.
  38. Adding headers and footers to PDF (the same for both files)
  39. -----------------------------------------------------------
  40. * Open the PDF file in Adobe Acrobat Pro DC.
  41. * Select 'Organize Pages'.
  42. * Right click the second page and select 'Crop Pages...'.
  43. * Select units: 'Inches'.
  44. * In 'Change page size' section select 'A4' for 'Page Sizes' and set 'XOffset' to '0.1 in'. Then click on 'YOffset' input field, so the x offset gets registered. Select page range 'All' and click OK.
  45. * Select 'Edit PDF' tab and add headers and footers by clicking 'Header & Footer' button, selecting a preset from 'Saved Settings' dropdown menu and clicking ok. Repeat the process for each preset. (If presets get lost, the font and the margins are as follow: Borders: left-line: 0.6, left-text: 0.8, top-line: 11.4, bottom-text: 0.27, right-text-odd: 0.57, font-name: menlo, font-size: 8.)
  46. * Select 'Organize Pages' tab and remove last empty page.
  47. * Set title to 'Comprehensive Python Cheatsheet' and author to 'Jure Šorn' by selecting 'File/Properties...'.
  48. * Save the progress by running 'Save as' in Format: 'Adobe PDF Files'.
  49. * Run 'Save as' again, this time in 'Adobe PDF Files, Optimized', so that Menlo font error gets fixed.
  50. Compressing
  51. -----------
  52. * Compress the two files together with HOW_TO_PRINT.txt instruction file that contains the instructions from the next section using: `zip 'Comprehensive Python Cheatsheet.zip' 'Comprehensive Python Cheatsheet.pdf' 'Comprehensive Python Cheatsheet (optimized for printing).pdf' 'HOW_TO_PRINT.txt'`.
  53. Printing the PDF
  54. ----------------
  55. * Open the PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers.