Xportability / css-to-pdf

Convert any HTML page or region to PDF - supports CSS, SVG, embedded XML objects, and more..
http://www.cloudformatter.com/CSS2Pdf
206 stars 78 forks source link

Add functionality to return base64 #43

Open Gobind03 opened 8 years ago

Gobind03 commented 8 years ago

Please check the pull request - I have added another option for getting the base64 for the pdf also. set render variable at the time of calling to 'base64' and the script would return base64. Very handy if the pdf is being forwarded to a service after generation by the developer! Can you please have a look at it ? Thank You :)

kbrown01 commented 8 years ago

I merged the pull request but I am confused at what you think it does based on your description -- this code:

return utf8ToBase64(xepOnline.Formatter.entity_declaration + current_stylesheet + printcopy);

Would return the content in base64 encoding that is being sent to the server to be formatted, not the resulting PDF being returned after formatting. Your comment seems to indicate otherwise. I can see this being helpful in systems that may want a fully resolved chunk of HTML content.

If you wish to implement something that just stores the base64 encoded PDF that is the result of formatting, that would be easy as the system returns base64 encoded PDF in the Response XML which is already parsed out.

kbrown01 commented 8 years ago

If you look for this line ...
var base64 = jQuery(Response).find("Result").text();

you could set such a flag as you have done and if that flag is set, just return that value which would return the base64 encoded value of the result. Is that what you where trying to do?

Gobind03 commented 8 years ago

Yes I think I messed up, somehow my trial page returned the correct base64 ... I will change the render name for current commit and add a new render option for this var base64 = jQuery(Response).find("Result").text(); thing. If thats okay ?

Also would you want me to change the read me file too ?

kbrown01 commented 8 years ago

I have several changes ... I just commented on one to see how people want it implemented. I will handle the readme as I will have a new option too.

kbrown01 commented 8 years ago

I have another one similar to yours that actually breaks the base64 and stores in the webbrowser. I will need to walk through all that to see what to do. That was a fork that allows people to do something like ... Download ... As PNG and they would get a downloaded PNG of every page in the PDF.