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
207 stars 77 forks source link

How does the community want this implemented? #46

Closed kbrown01 closed 8 years ago

kbrown01 commented 8 years ago

I am going to pose a question and give a few days for those that read here and use our code to respond.

Recently I added support for Glyphicons and Font Awesome icons. The code specifically referenced these libraries common "class" so that it only ran for elements that where in that class.

In doing that code, I realized that handling pseudo elements like :before and :after could be achieved. I have now done that in the code BUT it is not perfect. Pseudo element like :before are so strange, it is totally normal to do something like set the content of before to a string, but you can also set it to the string "url(path/to/my/image.jpg)" and expect it as they have programmed to interpret that you really want an image here and not the string itself. Totally weak, totally dumb. Whoever invented that should be shot because I cannot put the string url() as the actual content of the before: anymore.

Anyway ... there are two choices to implement this functionality. It either defaults to "true" (always process before: and after:) or "false" (don't process before: and after:).

One part of me says use "true" ... so now before: and after: will work ! You will get Glyphicons and Font Awesome icons and much more. And if it breaks, you will need to set a special rendering option in the call to turn that off.

The other part says it should be off by default, no one is affected and only those that actually read the documentation and understand that they need to set this rendering option to "true" will get a result.

Attached are a few sample outputs that should be self explanatory.

Opinions? I am going with "true" by default unless I have objections.

TestBedSamples (1).pdf GlyphIcons (5).pdf

kbrown01 commented 8 years ago

I guess I should take part of that back. I guess I can use url() without putting it in a string (quotes) and it is then therefore a url(), otherwise it is a string. So now I guess I have to parse the actual content to determine what it is. Still. Dumb.

kbrown01 commented 8 years ago

OK, after some work I have made images work also. So I am going to release this and allow you to only turn it off if it breaks something. It currently supports before: and after: with icon libraries like Font Awesome and Glyphcions, text content in those pseudo elements or url() notation for images.

This weekend will be the release date.