benweet / stackedit

In-browser Markdown editor
https://stackedit.io/
Apache License 2.0
21.66k stars 2.72k forks source link

BUG: Export to PDF creates corrupted files #778

Open technobly opened 9 years ago

technobly commented 9 years ago

Everything was working great yesterday. Now today files are being truncated at 720KB file sizes which leads to a corrupted file. If I export to PDF on a file that would generate a PDF smaller than 720KB it works ok. I'm not seeing any JS errors in my console. @benweet would you please check this out... I really need to update a document to keep production moving :) Thanks!!

technobly commented 9 years ago

I solved my issue... still not sure what part of this was the problem though.

I was trying to regenerate a file that I had generated yesterday no problem... somehow today it was different. I decided to try and scale up the Welcome document to over 720KB so that you could easily reproduce this... I concatenated the Welcome doc two more times (total of 3 copies) to generate an over 900KB file. The thing is, it worked ok.

So I went back to mine and it was still failing. I thought, how can I make it smaller? Reduce some of my image sizes. So two of my images were really large pixel wise, and one was even a 1.1MB png. I reduced the size of these from 3000px down to 1400 wide for one and 600px wide for the other. That also reduced the file sizes. Low and behold it worked, and generated a 1.4MB PDF.

Not sure if the backend service that generates PDFs changed recently and doesn't like larger images... but that's what it seems like. FWIW I was also scaling and positioning the images in my markdown file with HTML originally, something like this:

<div align=left><img src="https://lh5.googleusercontent.com/edited/my-file-1400.png" width=700></div>