[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] PDF::Writer 1.0 (version 1.0.1

Austin Ziegler

6/13/2005 9:59:00 PM

= PDF::WriterAt long last, I have released PDF::Writer 1.0. The released versionis 1.0.1 and is available from RubyForge:Homepage:: http://rubyforge.org/projects/ruby-pdf/P... is a pure-Ruby PDF document generator. It implementsabout 75% of the PDF 1.3 specification and none of the advancedoperations from PDF 1.4, 1.5, or 1.6. It does MORE than just writeraw PDF documents, though; it implements a simple text layout enginethat does the right thing most of the time. http://partners.adobe.com/public/developer/pdf/index_refere... addition to the core functionality, there are two specialiseddocument creators, table generation, and a sample chart type.The release contains several demonstration programs and thecanonical 82-page manual in PDF. On my home development machine (a1Ghz Transmeta Crusoe with 512 Mb RAM), it takes about 5 minutes togenerate the manual; it should be faster on most machines (about 1m30s on my work machine). This is an extremely complex document thatrepresents far more than is likely to be used in most productioncases. The manual can be generated from the .tar.gz or .gem releaseby running the "techbook" program.There is a mailing list listed on the RubyForge project.== UpgradingIf you've been using PDF::Writer 0.1 (the official version of thetechnology preview released in September 2003), you will have a bitof work ahead of you: the API is dramatically different. I have hadpositive reports from a few users brave enough to use the CVSversion first checked in last month for the conversion.== Licence NotesCopyright:: 2003—2005, Austin ZieglerPDF::Writer is released under a MIT-style licence and can bedistributed without any restrictions but also without any warranty.However, there are portions of the PDF::Writer distribution that areunder more restrictive licences because some items derive from workby others. PDF::Writer is also covered by a number of patents forwhich Adobe has granted nonexclusive royalty-free licences.== RequirementsPDF::Writer requires Ruby 1.8.2 or better, color-tools 1.0.0 orbetter, and Transaction::Simple 1.3.0 or better.== Change Log=== PDF::Writer 1.0.1* Fixed a few minor gem issues.* Renamed bin/manual to bin/techbook.* Fixed the manual.pwd locator for the default install.=== PDF::Writer 1.0.0* Integrated ezwriter.rb functionality with writer.rb.* Factored out some functionality into modules and classes.* Added CMYK colour support to JPEG images.* Uses Color::CMYK (from color-utils) to provide CMYK support to drawing capabilities.* Simplified the image API significantly.* Modified image support to properly handle full image flipping.* Fixed several multi-column issues.* Fixed a bug where new pages automatically started by overflowing text may have resulted in writing the first line of text above the top margin. This may need further testing and probably causes problems with column handling.* Fixed some page numbering issues.* Added several demos, including Ruby Quick Reference Sheets.* Scrubbed the API.* Updated the documentation.* Changed installer to setup.rb 3.3.1-modified.* Applied an image resize patch; the image will be resized manually before checking to see if a new page is required. Thanks to Leslie Hensley.* Fixed a bug where entities would generate the width specified for the component characters, not the represented characters.* Fixed a performance bug. Thanks again to Leslie Hensley.== Credits* Leslie Hensley <http://www.showerinabo... has been amazing during the last month, finding and helping to fix a major performance bug. This is definitely a use of PDF::Writer that I hadn't forseen, but am tickled pink(!) to see people use it in ways that I hadn't imagined.== Notes* PDF::Writer won't restore your hair line, but it will certainly reduce the speed at which you lose your hair due to report generation.-- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca
20 Answers

Austin Ziegler

6/14/2005 1:17:00 AM

0

On 6/13/05, Austin Ziegler <halostatue@gmail.com> wrote:
> = PDF::Writer
>
> At long last, I have released PDF::Writer 1.0. The released version
> is 1.0.1 and is available from RubyForge:
>
> Homepage:: http://rubyforge.org/projects...

There are two notes regarding this. Thanks to Bill Guindon for finding one.

1. The 1.0.1 gem does not install on Windows. You will need to use the
tar.gz. I'm not
sure if this is a problem with RubyGems or the Windows 1.8.2-15
installer, but there is
a Zlib buffer error :( If I can generate a workaround, I will.
2. There is a file that should not be included in either distribution
that I forgot to clean up.
Ignore or remove the techbook.bat. I don't remember if the setup.rb
does this properly
or not, but I will make sure that it does with the next release.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Bill Guindon

6/14/2005 1:31:00 AM

0

On 6/13/05, Austin Ziegler <halostatue@gmail.com> wrote:
> On 6/13/05, Austin Ziegler <halostatue@gmail.com> wrote:
> > = PDF::Writer
> >
> > At long last, I have released PDF::Writer 1.0. The released version
> > is 1.0.1 and is available from RubyForge:
> >
> > Homepage:: http://rubyforge.org/projects...
>
> There are two notes regarding this. Thanks to Bill Guindon for finding one.
>
> 1. The 1.0.1 gem does not install on Windows. You will need to use the
> .tar.gz. I'm not
> sure if this is a problem with RubyGems or the Windows 1.8.2-15
> installer, but there is
> a Zlib buffer error :( If I can generate a workaround, I will.

Gem installed fine here with "gem install pdf".

C:\>ruby -v
ruby 1.8.2 (2004-07-29) [i386-mswin32]

> 2. There is a file that should not be included in either distribution
> that I forgot to clean up.
> Ignore or remove the techbook.bat. I don't remember if the setup.rb
> does this properly
> or not, but I will make sure that it does with the next release.

Only ran across that from trying to find the techbook app (which was
appropriately in ruby/bin).

... and Wow! That's one impressive library!

The manual is well done, and it also serves as a great example of how
powerful this is.


> -austin
> --
> Austin Ziegler * halostatue@gmail.com
> * Alternate: austin@halostatue.ca

--
Bill Guindon (aka aGorilla)


Aleksi

6/14/2005 6:57:00 AM

0

Austin Ziegler wrote:

> At long last, I have released PDF::Writer 1.0. The released version
> is 1.0.1 and is available from RubyForge:
>
> Homepage:: http://rubyforge.org/projects...

Thanks! This looks promising! But it's hard to evaluate immediate
usefulness without seeing results and API.

Any chances to get a "Project Home Page" with (at least the same info
that you wrote in this email and) the complex manual as a show case and
browsable API reference (and/or documentation). Now I guess I'll be able
to reach it only by installing and running or generating RDoc on my own.

> The release contains several demonstration programs and the
> canonical 82-page manual in PDF. On my home development machine (a
> 1Ghz Transmeta Crusoe with 512 Mb RAM), it takes about 5 minutes to
> generate the manual; it should be faster on most machines (about 1m
> 30s on my work machine).

At first this seemed to be quite slow, but then, if a document of some
complexity takes roughly 1 sec / page it might not be that bad. Unless
you've used to LaTeX but then you have used to many other problems as
well :).

- Aleksi

Austin Ziegler

6/14/2005 11:11:00 AM

0

On 6/14/05, Aleksi <foobar@fuzzball.org.net> wrote:
> Austin Ziegler wrote:
>> At long last, I have released PDF::Writer 1.0. The released
>> version is 1.0.1 and is available from RubyForge:
>>
>> Homepage:: http://rubyforge.org/projects...
> Thanks! This looks promising! But it's hard to evaluate immediate
> usefulness without seeing results and API.

> Any chances to get a "Project Home Page" with (at least the same
> info that you wrote in this email and) the complex manual as a
> show case and browsable API reference (and/or documentation). Now
> I guess I'll be able to reach it only by installing and running or
> generating RDoc on my own.

Yes. All of this *will* be made available, but it's taking a bit of
time as I do have to do this in my spare time and work is quite busy
right now (with equally interesting stuff -- XMPP!).

It may be next week before the first pass at the home page gets
posted. I'm currently evaluating a couple of different technologies
that will help me reduce the amount of duplicated information I have
to type ;)

>> The release contains several demonstration programs and the
>> canonical 82-page manual in PDF. On my home development machine
>> (a 1Ghz Transmeta Crusoe with 512 Mb RAM), it takes about 5
>> minutes to generate the manual; it should be faster on most
>> machines (about 1m 30s on my work machine).
> At first this seemed to be quite slow, but then, if a document of
> some complexity takes roughly 1 sec / page it might not be that
> bad. Unless you've used to LaTeX but then you have used to many
> other problems as well :).

There are some important points to measure with this timing. First,
this is pure Ruby. There's no C code in this library, except the
Ruby interpreter. Second, the manual has at about two dozen tables,
and tables are known to be the slowest thing in the library --
because of the way that I implement the necessary backtracking
capabilities/undo buffer (as whole objects using
Transaction::Simple).

What I know is that Leslie Hensley is generating 6-page documents
relatively quickly. Whether this is a partially generated PDF (a
technique that I will be illustrating in the web pages) or fully
generated on the fly, I don't know. But it's visibly responsive for
web downloads (~3 seconds or less).

There's definitely some neat tricks, and there will be some
improvements that I will be making to the API over time. Some of
these will come a little later, as they will be breaking existing
APIs (I meant to, but forgot to, improve the image APIs to allow for
easy hyperlinked images; however, I was looking over the reference
documentation on annotations and actions and see that I need to
drastically improve *that* moving forward, too.) Others may come in
the near future as I get a few other things done (such as maybe
having an #each that iterates through the pages on the document).

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Jim Freeze

6/14/2005 2:54:00 PM

0

* Austin Ziegler <halostatue@gmail.com> [2005-06-14 10:17:24 +0900]:

> On 6/13/05, Austin Ziegler <halostatue@gmail.com> wrote:
> > = PDF::Writer
> >
> > At long last, I have released PDF::Writer 1.0. The released version
> > is 1.0.1 and is available from RubyForge:

Great. I'm excited to roll this into my app.
However, none of the demos seem to work.

irb(main):013:0> pdf.select_font("Helvetica")
TypeError: Font Helvetica not found.
from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/font.rb:109:in `open'
from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/writer.rb:228:in `open_font'
from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/writer.rb:245:in `select_font'
from (irb):13
from :0

But, if I add a path I get:

irb(main):014:0> pdf.select_font("pdf/fonts/Helvetica")
=> "pdf/fonts/Helvetica"
irb(main):015:0> pdf.select_font("pdf/fonts/Times-Roman")
=> "pdf/fonts/Times-Roman"

Is this correct behaviour?

--
Jim Freeze


Austin Ziegler

6/14/2005 3:47:00 PM

0

On 6/14/05, Jim Freeze <jim@freeze.org> wrote:
> * Austin Ziegler <halostatue@gmail.com> [2005-06-14 10:17:24 +0900]:
> > On 6/13/05, Austin Ziegler <halostatue@gmail.com> wrote:
> > > = PDF::Writer
> > >
> > > At long last, I have released PDF::Writer 1.0. The released version
> > > is 1.0.1 and is available from RubyForge:
> Great. I'm excited to roll this into my app.
> However, none of the demos seem to work.

> irb(main):013:0> pdf.select_font("Helvetica")
> TypeError: Font Helvetica not found.
> from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/font.rb:109:in `open'
> from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/writer.rb:228:in `open_font'
> from /Users/jdf/local_ruby/ruby-1.8.2/lib/ruby/site_ruby/1.8/pdf/writer.rb:245:in `select_font'
> from (irb):13
> from :0

This is an old version of PDF::Writer installed in your site_ruby (the
current release doesn't have pdf/font.rb; it's
pdf/writer/fontmetrics.rb). If you have an old version installed, you
*will* want to remove it before installing the new version.

A fresh install works just fine.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Jim Freeze

6/14/2005 5:27:00 PM

0

* Austin Ziegler <halostatue@gmail.com> [2005-06-15 00:46:55 +0900]:

> This is an old version of PDF::Writer installed in your site_ruby (the
> current release doesn't have pdf/font.rb; it's
> pdf/writer/fontmetrics.rb). If you have an old version installed, you
> *will* want to remove it before installing the new version.
>
> A fresh install works just fine.

Ah yes. It works now. Thanks.

BTW, did you really mean to 'squeeze' the Gettyburg address so that all
double letter words are now misspelled? E.g.:

fitting => fiting
battlefield => batlefield
hallow => halow

--
Jim Freeze


Austin Ziegler

6/14/2005 6:09:00 PM

0

On 6/14/05, Jim Freeze <jim@freeze.org> wrote:
> * Austin Ziegler <halostatue@gmail.com> [2005-06-15 00:46:55 +0900]:
> > This is an old version of PDF::Writer installed in your site_ruby (the
> > current release doesn't have pdf/font.rb; it's
> > pdf/writer/fontmetrics.rb). If you have an old version installed, you
> > *will* want to remove it before installing the new version.

> > A fresh install works just fine.
> Ah yes. It works now. Thanks.

> BTW, did you really mean to 'squeeze' the Gettyburg address so that all
> double letter words are now misspelled? E.g.:
>
> fitting => fiting
> battlefield => batlefield
> hallow => halow

You mean that's not the way that Abe spelled it?

No, that's a bug. ;) If I can get a working Win32 gem, that will be
fixed in a 1.0.2 release as well.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


threeve.org

6/14/2005 9:07:00 PM

0

No love from PDF::Writer on Mac OS X 10.4.1. I hope to get this fixed
as I'm really looking forward to using this library. Thanks for all
the hard work Austin!

Installed via gem, accepted the dependencies.

legolas:~ jason$ ruby -v
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]

Here is the error. My wild guess would be this is an Endian-ness
issue when reading in the images, but I don't have any evidence to
back up that claim, nor do I have the knowledge to figure it out
myself. If any more info is required I will surely oblige.

legolas:~ jason$ techbook
Using default document '/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/
lib/pdf/../../manual.pwd'.

Error in document around line 205:
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/
graphics/imageinfo.rb:176:in `measure_JPEG': JPEG marker not found!
Backtrace:
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
690:in `techbook_directive_endeval'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/graphics/
imageinfo.rb:174:in `loop'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/graphics/
imageinfo.rb:174:in `measure_JPEG'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/graphics/
imageinfo.rb:85:in `__send__'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/graphics/
imageinfo.rb:85:in `initialize'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/
graphics.rb:546:in `new'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/
graphics.rb:546:in `add_image'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/writer/
graphics.rb:537:in `add_image_from_file'
(eval):43:in `techbook_directive_endeval'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb: 686:in `eval'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
690:in `techbook_directive_endeval'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
686:in `initialize'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb: 686:in `new'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
686:in `techbook_directive_endeval'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
547:in `__send__'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
547:in `techbook_parse'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb: 536:in `each'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
536:in `techbook_parse'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb: 874:in `run'
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/bin/techbook:24
/usr/bin/techbook:18:in `load'
/usr/bin/techbook:18
/usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/techbook.rb:
690:in `techbook_directive_endeval': /usr/lib/ruby/gems/1.8/gems/pdf-
writer-1.0.1/lib/pdf/writer/graphics/imageinfo.rb:176:in
`measure_JPEG': JPEG marker not found! (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics/imageinfo.rb:174:in `loop'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics/imageinfo.rb:174:in `measure_JPEG'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics/imageinfo.rb:85:in `__send__'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics/imageinfo.rb:85:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics.rb:546:in `new'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics.rb:546:in `add_image'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
writer/graphics.rb:537:in `add_image_from_file'
from (eval):43:in `techbook_directive_endeval'
... 9 levels...
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/lib/pdf/
techbook.rb:874:in `run'
from /usr/lib/ruby/gems/1.8/gems/pdf-writer-1.0.1/bin/ techbook:24
from /usr/bin/techbook:18:in `load'
from /usr/bin/techbook:18
Exception around line 0.


Thanks!

Jason


Austin Ziegler

6/14/2005 11:12:00 PM

0

On 6/14/05, Jason Foreman <threeve.org@gmail.com> wrote:
> No love from PDF::Writer on Mac OS X 10.4.1. I hope to get this fixed
> as I'm really looking forward to using this library. Thanks for all
> the hard work Austin!
>
> Installed via gem, accepted the dependencies.
>
> legolas:~ jason$ ruby -v
> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
>
> Here is the error. My wild guess would be this is an Endian-ness
> issue when reading in the images, but I don't have any evidence to
> back up that claim, nor do I have the knowledge to figure it out
> myself. If any more info is required I will surely oblige.

That seems weird. Is there anyone who can grant me access to a MacOS X
box with 10.4.1 to test this?

JPEGs are supposed to be in network byte order. Jason, the other
option is to look at the ImageSize and see if it gives a similar
result.

I want to solve this, but I don't have access to a MacOS X box. :(

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca