Closed Reggino closed 8 years ago
I'll fix the linting issues and change the request method to POST when sending HTML
Raw HTML can now be POST-ed to retrieve a PDF's and images.
I tried to keep the existing structure in tact, so i change the request-method to GET after the tmp-file is created. Maybe you prefer the GET-handler to be a separate method and be called instead... See https://github.com/kingsquare/electron-render-service/blob/send-html/src/server.js#L54
I've added transparent: true
to the BrowserWindow. This prevents a white rectangle being drawn behind the actual output. This way it is possible to add your own background or watermark (with external software)
The missing white background rectangle causes a binary difference in the test-results, they look the same though... I think the compare-files should be updated...
Hey,
Looks great, first question - why saving to a tempfile instead of loading the posted HTML as a data URI?
Such as:
data:text/html;charset=utf-8,<!DOCTYPE%20html><html%20lang%3D"en"><head><title>Embedded%20Window<%2Ftitle><%2Fhead><body><h1>42<%2Fh1><%2Fbody><%2Fhtml>
with HTML being encoded with encodeURIComponent
.
Of course there might be some unknown issues with this approach :)
👍 for transparency support, test themselves are quite brittle (in a sense that test code is comparing bytes), but I couldn't figure out how to make them more robust. Testing is done inside the docker image, so any test fixtures have to be generated with that (as each platform has subtle rendering differences).
I didn't really test it, but i'm afraid there are limits to the length of an url . To prevent that kind of issues, streaming the request into a tempfile seems a more solid approach and causes a minimal amount of performance impact...
Yup, URLs with protocol are usually limited around 2k characters, datauri is a different thing, but looks like Chrome limits it at 2MB - https://bugs.chromium.org/p/chromium/issues/detail?id=44820#c16. So still out of question.
This should allow HTML to be POSTED, as discussed #14