NOTE: this will not be deployed with the first version of the new PDF renderer
Currently the chromium-render-service renders PDFs in A4 and Letter sizes without mobile print styles. In order to test the service against mobile styles we need to make the following to changes:
1. Allow the service to render PDFs in Legal size (per @Nirzar at T181513#3793601);
2. Add an option in the service to load mobile print styles before rendering.
== Design requirement
{F12389611}
We have two intents for producing PDFs and we have two platforms for doing so. That can be put into a 2x2 for number of styles we need.
out of the 4 required styles,
- We can safely dismiss the use case to create hard copies from small screens
- We can use the same styles for soft and hard copy on large screens, as the visual scale of large screen matches printing on paper. i.e. font size equivalent to 10pt, and 10-15 words per line
- for soft copy on small screens, we need larger visual scale. i.e. font size equivalent of 16pt and around ~5 words per line. this will mimic the regular article view
== Developer notes
The below are suggestions. Maybe you'll find a better way of accomplishing the task while working on it.
== Acceptance criteria
[] Nirzar to explain the different types of PDF
[] Before coding anything having a meeting to discuss and agree what the change will look like. Meeting creator should be driving the change and have a strawman proposal of what to do. Should discuss how clients will determine what PDF mode to use.
[] Should be possible to generate 2 types of PDFs via 2 different URLs
=== Adding a new page size:
1. Allow the PDF end point to accept `legal` [[ https://phabricator.wikimedia.org/diffusion/MSCR/browse/master/routes/html2pdf-v1.js;1aaabe2bcfbd8ad3c6793c0ff0ec7d2274363133$21 | here ]].
=== Applying mobile print styles
1. puppeteer [[ https://github.com/GoogleChrome/puppeteer/blob/v0.13.0/docs/api.md#pageaddstyletagoptions | allows adding style tags ]] to the page that's being rendered. Use it to add the mobile print styles to the [[ https://phabricator.wikimedia.org/diffusion/MSCR/browse/master/lib/renderer.js;1aaabe2bcfbd8ad3c6793c0ff0ec7d2274363133$51 | the page object ]] before rendering the PDF;
2. The mobile print styles is part of the [[ https://phabricator.wikimedia.org/diffusion/SMIN/browse/master/skin.json;03ca369776371131cb4961def5cec8eae658eb34$112 | "skins.minerva.base.styles" module ]] and can be seen [[ https://en.wikipedia.org/w/load.php?debug=true&lang=en&modules=skins.minerva.base.styles&only=styles&skin=minerva | here ]].
3. Since we don't want to hard-code URLs, we'll have to create a config variable that points to the module URL. Something similar to [[ https://phabricator.wikimedia.org/diffusion/MSCR/browse/master/config.dev.yaml;1aaabe2bcfbd8ad3c6793c0ff0ec7d2274363133$65 | this ]].