Article Discussion
Creating Printable Documents with Ruby
Summary: In this article, Austin Ziegler introduces the creation of a variety of types of documents with PDF::Writer for Ruby. This introduction covers basic creation, partial document generation and customization, and Rails-generated documents.
24 posts on 2 pages.      
« Previous 1 2 Next »
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: December 1, 2008 4:33 AM by
James
Posts: 9 / Nickname: jbritt / Registered: March 24, 2003 4:10 PM
Creating Printable Documents with Ruby
October 9, 2005 8:00 PM      
In this article, Austin Ziegler introduces the creation of a variety of types of documents with PDF::Writer for Ruby. This introduction covers basic creation, partial document generation and customization, and Rails-generated documents.

Read this Artima article by Austin Ziegler, creator of PDF::Writer

http://www.artima.com/rubycs/articles/pdf_writer.html

What do you think about using PDF::Writer?
Matthew
Posts: 2 / Nickname: matthewmur / Registered: October 9, 2005 9:54 PM
Re: Creating Printable Documents with Ruby
October 10, 2005 2:05 AM      
I liked the article. Good introduction. I'm new to ruby and rails and am learning and starting to work on a first project which is going to involve lots of number type data so it would be really nice to allow people to be able to export that data in lots of different formats. You mentioned there was just one type of chart available at the minute. Would it be very difficult to introduce other types of charts and colour them ? And as far as I can see (maybe I'm wrong and need to pay more attention) these are static examples where everything we see in the pdf has been hardcoded. How would I go about creating a generic export PDF type function that would take the XHTML structure and spit it out into a nice pdf?
Austin
Posts: 2 / Nickname: aziegler / Registered: October 10, 2005 11:05 AM
Re: Creating Printable Documents with Ruby
October 10, 2005 4:35 PM      
> You mentioned there was just one type of chart available
> at the minute. Would it be very difficult to introduce
> other types of charts and colour them?

Strictly speaking, it wouldn't. It's a matter of time. Charts::StdDev is the only type because that's all that I've had time to develop. Any user-submitted chart type would be accepted into the PDF::Write project under the same licence.

> And as far as I can see (maybe I'm wrong and need to pay
> more attention) these are static examples where
> everything we see in the pdf has been hardcoded.

For the examples in the article, that is correct. I don't have a database application where this would make sense to demonstrate and considered it a little too advanced for this introduction.

> How would I go about creating a generic export PDF type
> function that would take the XHTML structure and spit it
> out into a nice pdf?

That's the real rub. It's a hard problem that will take a lot of code to solve. There are some bizarre things with XHTML support that need serious thought. (There's a reason that the table support model in PDF::Writer isn't based on the XHTML table model.)
Matthew
Posts: 2 / Nickname: matthewmur / Registered: October 9, 2005 9:54 PM
Re: Creating Printable Documents with Ruby
October 11, 2005 0:23 AM      
Ok, thanks for replying :) Now, I'm a completely useless coder really for this type of thing bue perhaps I could help a little bit in other ways. I'm going to start development of my first little rails application this week which would include plenty of data that you could play around once I get it onto a live domain. Then I saw this article on sitepoint a few weeks ago about pdfs and php. Maybe it could help you with a few ideas:

http://www.sitepoint.com/article/generate-pdfs-php
Austin
Posts: 2 / Nickname: aziegler / Registered: October 10, 2005 11:05 AM
Re: Creating Printable Documents with Ruby
October 11, 2005 3:19 AM      
Thank you for the pointer. The relevant code is on the 4th page of that article, and all it does is have a simple example of a manually generated pie chart. The difficulty with making charts in PDF::Writer is that they have to be a little smarter than that, as they are components to be reused. My main problem isn't with figuring out how to create such charts (as I could easily take Charts::StdDev and create Line and High-Low charts, and it wouldn't take much to go from those to vertical Bar charts), but a severe lack of time.

Future directions for PDF::Writer include SVG import (which may make some of the charting issues moot, as well), presentation support (which is almost done, but probably still a month from release), document reading and modification, and direct TTF support. Some of the work for SVG import will make it much easier to do XHTML conversion at a later date, but I think I will be leaving that for others to tackle using PDF::Writer as a worker capability.
Zach
Posts: 2 / Nickname: zdennis / Registered: September 22, 2004 8:40 AM
Re: Creating Printable Documents with Ruby
November 6, 2005 4:03 PM      
Austin, a great read! This almost seems to simple. I look forward to using PDF::Writer, and I look forward to being able to utilize ruby to generate pdfs rather then using Java!
Peter
Posts: 1 / Nickname: pgillogley / Registered: November 28, 2005 6:46 PM
Re: Creating Printable Documents with Ruby
November 29, 2005 0:05 AM      
Hi

I fell across this by accident. I had been wondering how I could create a utility that I could call from a ruby test script would log my screen based tests and support inclusion of screen images, tables, colours for highlighting sections of test. I also wanted to use common file format so that the documents could be displayed by most users. I had imagined that I would need to write something to create MS Word RTF documents (I assumed Adobe would be too hard). Then I saw your PDF::Writer for Ruby!...

The install was easy (using GEMS) and the demos run first time. The PDFs look great. All very positive (and very professional). I am looking forward to using this in my testing.

Thanks for creating this and sharing it

Peter Gillogley

http://www.gillogley.com/testing.shtml
George
Posts: 1 / Nickname: thelonious / Registered: December 1, 2005 11:43 PM
Re: Creating Printable Documents with Ruby
December 2, 2005 5:22 AM      
Hi. I am using PDF:Writer for a month now and I face only one problem, as long as I live in Greece: display of greek characters. As a first approach I extract an .afm file from a greek font file, copy it to /lib/pdf/writer/font, add the differences to the select_font function (cp1253 codes) and get greek characters displayed correctly, but only in viewers different than acrobat reader. In acrobat reader the characters are correct but seems that all the metrics are gone.
Do you have any ideas?
Kenneth
Posts: 1 / Nickname: pryce / Registered: August 15, 2005 11:53 PM
Re: Creating Printable Documents with Ruby
January 6, 2006 2:25 AM      
How about support for xsl-fo? Since it's a standard formatting technique in f.ex. xml-based publishing systems, it would seem like a natural feature to add.

Best regards,

Kenneth,
Denmark
Ray
Posts: 1 / Nickname: raycarr / Registered: February 23, 2006 0:11 AM
Re: Creating Printable Documents with Ruby
February 23, 2006 5:17 AM      
Does anyone know if PDF::Writer supports png images with transparecy?

Cheers, Ray
sinson
Posts: 1 / Nickname: franee / Registered: July 11, 2006 7:24 PM
Re: Creating Printable Documents with Ruby
July 11, 2006 11:31 PM      
Hello,

I used pdf writer in rails and i used the example:

send_data _pdf.render, :filename => "hello.pdf",
:type => "application/pdf"

When i download and open the pdf file, it can't be read because it is corrupt. Any ideas?

Thanks,
/franee
Kareem
Posts: 1 / Nickname: kbadr / Registered: August 25, 2006 8:00 AM
Re: Creating Printable Documents with Ruby
August 25, 2006 1:02 PM      
Does anyone know how to make the PDF Writer library fit a table to a page. Or, rather, resize a page to make a table fit. I've got code that dynamically generates tables (for a printable version of a report), but if the table has a lot of data, it doesn't fit on the page, and the table just gets chopped off on the left and right. Is there a way to tell PDF Writer to make the page resize to fit all the objects that are going to be rendered on it?
sf
Posts: 1 / Nickname: sfdesigner / Registered: January 5, 2007 4:30 AM
Re: Creating Printable Documents with Ruby
January 5, 2007 10:38 AM      
Where is the 95 page manual? I can't find a link to it anywhere. Is it contained in a downloadable archive?
wiktor
Posts: 1 / Nickname: wmacura / Registered: February 3, 2007 2:07 AM
Re: Creating Printable Documents with Ruby
February 3, 2007 8:11 AM      
http://files.rubyforge.mmmultiworks.com/ruby-pdf/pdf-writer-demo-1.1.3.tar.gz

The manual is in there :-)
Chris
Posts: 1 / Nickname: arch79 / Registered: February 5, 2007 4:23 AM
Re: Creating Printable Documents with Ruby
February 5, 2007 10:28 AM      
Is there any way to implement subtables with PDF:Writer? I have created a report for a database app that displays each sale on a row. I need to be able to display a subtable inside each row for the lineitems for that sale.
24 posts on 2 pages.
« Previous 1 2 Next »