David Modernfossil wrote:> I''ve been searching for a way to easily convert an html page into
a pdf
> in my rails app and I haven''t found anything worth calling home
about.
> Has anyone found something good out there?
There is no easy way to to this in any language actually. They all have
ways to parse the HTML into an XML And then apply a style sheet or
something on top of it to converter and create your PDF, but it''s just
not easy.
(Well if you have a good printer driver that prints pdf.. problem solved
but that''s another issue)
Okay so here''s what I have found out from my experiences on this EXACT
topic, I would LOVE to stand corrected if my info is older and outdated
and an easy solutions is around somewhere.
Part of the difficulty in finding PURE (I.E. API / Classes) coding
solution to do this in Ruby, Perl etc is is due to difficulty in dealing
with the the incompatibilities of the HTML / XHTML and how people
implement it. Some HTML ''looks'' well formed in the browser but
in
reality the document wont even pass a validation check through a schema
/ dtd / xsd because of bad or missing tags.
Then you have the issues with style sheets and display tags in the
markup. Which one take precedence.. lastly what if this page has non
html display elements like flash or something like that.
As you can see ball of hell waiting to happen. At the company I work for
I, and my team, have been tasked to look at a non-proprietary way of
doing this for months. All the ''easy ''solutions require a
printer like
driver or engine to be running on the machine handling the request. Once
you have it all parsed say in a broswer then have THAT converted for you
is much easer than writing your own parser. But, not really what you are
looking for.. so I''ll continue...
To actually try ANSWER your question, you will have to use a combination
of PDF::Writer, one of the XML tools and a way to convert your CSS and
styles into PDF tags. I would use XML just to make the iteration of the
DOM easy to convert element by element into PDF. The XML tools I know of
are libXML-Ruby and/or the whole XML Line of classes in the Ruby CORE
Api.
Hope this at LEAST gets you started in the right direction.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---