microsoft / TypeScript-Website

The Website and web infrastructure for learning TypeScript
https://www.typescriptlang.org
Creative Commons Attribution 4.0 International
2.21k stars 1.36k forks source link

PDFs: support PDFs for the website #3204

Open a0m0rajab opened 3 weeks ago

a0m0rajab commented 3 weeks ago

I did not find a better place to share this (would appreciate to point me to where should I publish it if it's not the correct place)

I was trying to find the PDF of the handbook for couple of reasons:

Yet I found that it was removed from the website for simplicity reasons. Is there any new decision about this?

Related issue: https://github.com/microsoft/TypeScript-Website/pull/2619#issuecomment-1331128079

a0m0rajab commented 3 weeks ago

Note in the comment it's suggested that the print function would be a good usage, yet it does not show the full text (which was the same issue with playwright)

Here is the related page: https://www.typescriptlang.org/docs/handbook/2/modules.html

The print generated from the CTRL + P (on chrome browser, Version 127.0.6533.120 (Official Build) (64-bit), windows)

image

The missing text: The JavaScript specification declares that any JavaScript files without an import declaration, export, or top-level await should be considered a script and not a module.

The docs:

image

I think that search docs and some other tags should not be visible on the print document.

a0m0rajab commented 3 weeks ago

Related issue: https://github.com/microsoft/TypeScript-Website/issues/620

a0m0rajab commented 3 weeks ago

Workaround: I did remove the navbar, and extra information from the page which helped to have a better look for the printing and get the text here is the result:

After: image image

Before: image image

a0m0rajab commented 3 weeks ago

Javascript code to remove the extra elements from the webpage:

document.querySelectorAll("header, #page-helpful-popup, #site-footer, .whitespace-tight.raised").forEach(e => {
    e.remove()
})
a0m0rajab commented 3 weeks ago

Using print query and break points would improve the experience:

Examples: https://stackoverflow.com/questions/1664049/can-i-force-a-page-break-in-html-printing https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Printing#using_media_queries_and_page_to_control_printed_content\ https://stackoverflow.com/questions/355313/how-do-i-hide-an-element-when-printing-a-web-page

a0m0rajab commented 3 weeks ago

Note: i tried to run the website and have a minimal working example as proof of concept but was not able to run the website locally, might visit this later.

a0m0rajab commented 3 weeks ago

The website worked on ubuntu but did not work on windows.