Forum: Ruby on Rails Pdf::Writer and #image

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jodi S. (Guest)
on 2006-01-02 23:31
Greetings all - happy new year,

I'm having problems getting Pdf::Writer image insertion.

pdf.image "/path/to/images/logo.jpg"

is firing "JPEG marker not found!"

Originally created the RGB (8 bit) JPEG in photoshop. After the above,
I've exported with an alternate tool using (OSX) preview.

This tutorial
http://www.artima.com/rubycs/articles/pdf_writer2.html
says that CMYK or RGB encoding is needed - so that's not the problem.
Other than that requirement, are there others?

Optionally I tried PNG, but this resulted in a nil.unpack error ('The
error occured while evaluating nil.unpack')

I've now run out of file types. harumph!

Secondary question, how do I reference a relative path to the file
(/images and ../images/file don't work) ? Or perhaps a way to find the
server root path from the os?

Thanx for any pointers.
Austin Z. (Guest)
on 2006-01-03 00:39
(Received via mailing list)
On 02/01/06, Jodi S. <removed_email_address@domain.invalid> wrote:
> Greetings all - happy new year,
>
> I'm having problems getting Pdf::Writer image insertion.
>
> pdf.image "/path/to/images/logo.jpg"
>
> is firing "JPEG marker not found!"

You're using the natively built Ruby for OS X. It is known to be
broken. Install one from darwinports, fink, or build your own.

> Secondary question, how do I reference a relative path to the file
> (/images and ../images/file don't work) ? Or perhaps a way to find the
> server root path from the os?

That will be something that the Rails people will have to deal with.
PDF::Writer will work from the current working directory, and that may
not be what you think it is in the file you're dealing with.

-austin
--
Austin Z. * removed_email_address@domain.invalid
               * Alternate: removed_email_address@domain.invalid
Kyle M. (Guest)
on 2006-01-03 01:00
(Received via mailing list)
On 1/2/06, Jodi S. <removed_email_address@domain.invalid> wrote:
>
> Secondary question, how do I reference a relative path to the file
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

There are some JPEG variations such as JPEG2000 and progressive JPEG
that are not quite universally supported.  Check to make sure your
JPEG isn't progressive.  This is general advice, because I don't know
PDF::Writer.  Your problem may very well be something else.

For relative paths, I use File.join RAILS_ROOT, "path", "to", "file"

--
Kyle M.
Chief Technologist
E Factor Media // FN Interactive
removed_email_address@domain.invalid
1-866-263-3261
Jodi S. (Guest)
on 2006-01-03 05:50
Austin:
> You're using the natively built Ruby for OS X. It is known to be
> broken. Install one from darwinports, fink, or build your own.
>

&&

Kyle:
> I use File.join RAILS_ROOT, "path", "to", "file"

YES! Thank you both. Hours later, and much googling, gem updates, and
tada.

Logo in my report header!

Good nite.
Jodi
This topic is locked and can not be replied to.