Html to pdf?

in one of my apps i am currently using redcloth to use textile
formatting on my content.

i am wanting to add reporting to the system, but the content that prints
out doesn’t have the formatting obviously that i can have with html.

what’s a good solution for some kind of formatting where i can use it on
both web and print? i’m using pdf/writer right now and i think it’s
great. but if there are better solutions out there, please let me know.

thanks

On Mon, 2006-06-19 at 16:28 -0400, Michael Gurski wrote:

  • (optionally) mail off to distribution list

At the time, it was a nice “quick” way to get the pretty HTML
formatting from a 3rd party reporting tool into a format that didn’t
require a network connection, and could still be read by everyone in
the same way. It also means all changes to the exist HTML layout are
automatically reflected in the PDF version (a nice way to apply DRY in
an attempt to get this tangentially back on-topic).


I punted on this several months ago and would love to know of a
methodology to do this without inventing my own wheel…if you blog it,
you must post. :wink:

Thanks

Craig

On Mon, Jun 19, 2006 at 10:18:58PM +0200, Josh K. wrote:

in one of my apps i am currently using redcloth to use textile
formatting on my content.

i am wanting to add reporting to the system, but the content that prints
out doesn’t have the formatting obviously that i can have with html.

what’s a good solution for some kind of formatting where i can use it on
both web and print? i’m using pdf/writer right now and i think it’s
great. but if there are better solutions out there, please let me know.

It’s kind of off-topic here, but I’m doing something for generating
what should be HTML reports and bundling them into PDF format for
sending off to management and the like in a cronjob. If you’re on
unix, a similar approach might be useful for you…

Steps involved:

  • Generate HTML output
  • run html2ps on .html file (passing in paths to images in webroot) to
    convert to .ps format
  • run ps2pdf on .ps file to convert to .pdf format
  • (optionally) mail off to distribution list

At the time, it was a nice “quick” way to get the pretty HTML
formatting from a 3rd party reporting tool into a format that didn’t
require a network connection, and could still be read by everyone in
the same way. It also means all changes to the exist HTML layout are
automatically reflected in the PDF version (a nice way to apply DRY in
an attempt to get this tangentially back on-topic).


Michael A. Gurski (opt. [first].)[last]@pobox.com
http://www.pobox.com/~[last]
1024R/39B5BADD PGP: 34 93 A9 94 B1 59 48 B7 17 57 1E 4E 62 56 45 70
1024D/1166213E GPG: 628F 37A4 62AF 1475 45DB AD81 ADC9 E606 1166 213E
4096R/C0B4F04B GPG: 5B3E 75D7 43CF CF34 4042 7788 1DCE B5EE C0B4 F04B
Views expressed by the host do not reflect the staff, management or
sponsors.

“The State is that great fiction by which everyone tries to live at
the expense of everyone else.” --Frederic Bastiat (1801 - 1850),
French statesman and author.

I use htmldoc. Here’s an example action:

def report
@person = Person.find(params[:id])
add_variables_to_assigns

generator = IO.popen('htmldoc -t pdf14 --webpage -', 'w+')
generator.puts @template.render('/person/report')
generator.close_write

send_data generator.read, :filename => "Person report for

#{@person.name}.pdf", :type => ‘application/pdf’, :disposition =>
‘inline’
end

-Jonathan.

HTMLdoc doesn’t have decent CSS support (yet). The latest stable
version has no css support whatsoever, the latest development build
has, but you need to take a lot of quirky stuff into account
(absolute url to the css file, no dashes or underscores in class and
id names, â?¦).

On 20 Jun 2006, at 01:45, Jonathan V. wrote:

send_data generator.read, :filename => “Person report for
#{@person.name}.pdf”, :type => ‘application/pdf’, :disposition =>
‘inline’
end

Best regards

Peter De Berdt

On Mon, Jun 19, 2006 at 01:34:56PM -0700, Craig W. wrote:

require a network connection, and could still be read by everyone in
the same way. It also means all changes to the exist HTML layout are
automatically reflected in the PDF version (a nice way to apply DRY in
an attempt to get this tangentially back on-topic).


I punted on this several months ago and would love to know of a
methodology to do this without inventing my own wheel…if you blog it,
you must post. :wink:

I doubt I’ll be making any major changes to my process anytime soon,
as it’s technically on a production system that now is under change
control, and I don’t like the paperwork I’d need to fill out… :slight_smile:

Incidentally, the mentioned programs (on my systems at least) are in
the html2ps and gs-common packages, respectively.


Michael A. Gurski (opt. [first].)[last]@pobox.com
http://www.pobox.com/~[last]
1024R/39B5BADD PGP: 34 93 A9 94 B1 59 48 B7 17 57 1E 4E 62 56 45 70
1024D/1166213E GPG: 628F 37A4 62AF 1475 45DB AD81 ADC9 E606 1166 213E
4096R/C0B4F04B GPG: 5B3E 75D7 43CF CF34 4042 7788 1DCE B5EE C0B4 F04B
Views expressed by the host do not reflect the staff, management or
sponsors.

“Congress shall make no law respecting an establishment of religion,
or prohibiting the free exercise thereof; or abridging the freedom of
speech or the press; or the right of the people to peacably assemble
and to petition the Government for a redress of grievances.” --The
First Amendment to the Constitution of the United States of America,
declared in force December 15, 1791

Peter De Berdt wrote:

HTMLdoc doesn’t have decent CSS support (yet). The latest stable
version has no css support whatsoever, the latest development build
has, but you need to take a lot of quirky stuff into account
(absolute url to the css file, no dashes or underscores in class and
id names, �?�).

On 20 Jun 2006, at 01:45, Jonathan V. wrote:

send_data generator.read, :filename => “Person report for
#{@person.name}.pdf”, :type => ‘application/pdf’, :disposition =>
‘inline’
end

Best regards

Peter De Berdt

I am tryin to run Prince which seems to give excellent results and use
CSS
http://sublog.subimage.com/articles/2007/05/29/html-css-to-pdf-using-ruby-on-rails
http://www.nullislove.com/2007/05/30/easy-pdfs-from-rails/#comment-506

kad

Glad you guys are finding the article helpful :wink:

On 8/29/07, Kad K. [email protected] wrote:

both web and print? i’m using pdf/writer right now and i think it’s
output pdf quality from html is !!!

Posted via http://www.ruby-forum.com/.

seth at subimage interactive

http://sublog.subimage.com

Cashboard - Estimates, invoices, and time tracking software - for free!
http://www.getcashboard.com

Substruct - Open source RoR e-commerce software.
http://dev.subimage.com/projects/substruct

Good point. I should have mentioned that!

-Jonathan.

On 29 Aug 2007, at 16:37, Kad K. wrote:

I am tryin to run Prince which seems to give excellent results and use
CSS
http://sublog.subimage.com/articles/2007/05/29/html-css-to-pdf-
using-ruby-on-rails
http://www.nullislove.com/2007/05/30/easy-pdfs-from-rails/#comment-506

Sure, but it costs a fortune, especially if you’re staging one
application to several servers (e.g. each customer runs their own
internal server).

Best regards

Peter De Berdt

Well I’m sure you could try to create a web service to only have to
install prince on one machine that way.

Josh K. wrote:

in one of my apps i am currently using redcloth to use textile
formatting on my content.

i am wanting to add reporting to the system, but the content that prints
out doesn’t have the formatting obviously that i can have with html.

what’s a good solution for some kind of formatting where i can use it on
both web and print? i’m using pdf/writer right now and i think it’s
great. but if there are better solutions out there, please let me know.

thanks

I just finished testing Prince …

lok at
http://sublog.subimage.com/articles/2007/05/29/html-css-to-pdf-using-ruby-on-rails

output pdf quality from html is !!!