-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PDF format #307
Comments
For more background see: #52 In looking at pdfkit again, it looks like it now has client side functionality (not sure if that was always there or not). Not sure if the atmosphere package is exporting to client, but we'd probably want to include the pdfkit npm as a core library and export to client as well. One of my wish lists was to not have to have special pdf templates, reusing meteor templates. We'll need to see if this is possible (html -> pdf), or how difficult this would be for people to make customization if we use pdfkit. |
I built a test package to that installs pdfkit, with the same format as ongowork:pdf and tested that way. the problem with pdfkit, and the reason I didn't choose it the first time around... is that to support html-> pdf conversion you need http://wkhtmltopdf.org/ installed (and also true with a whole bunch other npm modules). General requirements:
For the umpteenth time, I wonder if PDF is something that is really required, VS a browser print screen or email. |
I've updated the formatting and given the pdf it's own layout. At least it now prints the info and is sort of useable as an invoice. It's still ugly, and the jsPDF formatting is impossibly broken / malfunctioning. I don't think this is the long term answer. I tried html2canvas to jsPDF as well: ie
(had to add the html2canvas files for this) This does render a fairly decent image of the invoice, and insert into a pdf, but I wasn't able to stream direct from Blaze to this - it had to be injected into an element, and then pass the element to the html2canvas. this was just a bit too kludge for me. |
Maybe we should just use an HTML interpreter to parse HTML files and format PDF files? This way we will also be able to switch PDF libs if necessary... |
The layout problems could arise from the css source files (like bootstrap) not in the html rendered by Blaze. This means jsPDF doesn't see a stylesheet link. |
from @gouthamve
|
I looked into some alternates because jsPDF is not reliable for html to pdf conversion. I found two options:
I am in favour of having Phantomjs instead of second option as it seems natural but I havent had time so I dont know if its possible to produce PDFs using phantom in Meteor. |
See #52 re phantomjs: it worked, sort of, but we had issues with it as well. That was the initial solution I implemented. |
Suggestion: https://atmospherejs.com/pascoual/pdfkit
Implement document-based pdf generation, as Blaze.saveAsPDF seems unreliable and has poor formatting support.
The text was updated successfully, but these errors were encountered: