Closed djplaner closed 3 years ago
StackOverflow post suggestion works
Doing it safely across browser might be the main difficulty.
Not only can you add CSS, but you should be able to run Javascript on the HTML from the div to do all the changes currently done in Python.
Takes title and HTML and does the following changes
Working on style images. They can't be printed because they are background images. Implying that the STYLE_PREPEND stuff doens't need to happen normally, could be moved just to the print stage
Apparently printing to PDF (printer) is the same as printing on a printer. The PDF is flattened, i.e. links are visually displayed, but don't actually work as links. This is from Acrobat.
Appears that Firefox does the same. Chrome generates clickable links, however, styles appear to break.
Currently code adds a "print" css to the main document, that works in chrome. But not in Firefox.
Remove it and it works in Firefox but not in Chrome
Both screen and print work in Firefox Chrome
But only in the pop-up window. Load that same HTML page into a proper window (the original that works in Firefox) and it all works.
Suggestion Is it having a print css in the original that makes the difference? Yes. Chrome needs the print css in the original. Firefox doesn't. But have it and a screen one in the popup and both are happy.
This page has some details on
STYLE_PREPEND has to happen for all of these because Mammoth can't do it alone. Thus move away from using background images
For some reason, Chrome doesn't like displaying the Film Watch Options icon, but it can be iconsisstent.
Fixed. Problem with my code
Appears fine elsewhere. Fixed my code.
=== COM14 issues
Week 13 of COM14 isn't printing?? Forms embed?
Week 1 embed stream isn't being converted
Also some issues with activity icons
Maybe even a web component that can be easily added?
jsPDF
As per StackOverflow in theory it's possible with jsPDF and including
BUT It you lose all the style information.
jsPDF and html2canvas
html2canvas apparently uses the browser to generate a canvas image. Possibly keeping the styles, but probably generating a PDF with images, not text?
PDFReactor
An API based service. Have to pay to get a real licence. But seems very full features.
PDFMake which is based on PDFKit
PDFKit is very low level for PDF generation - Browser or server (node)
PDFMake takes a doc definition as JSON array - not as html.
Some early work on HTML to PDF, and someone wrote a html-to-pdf module.
BUT