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.
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2006-01-02 22: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.
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (Guest)
on 2006-01-02 23:39
(Received via mailing list)
On 02/01/06, Jodi Showers <jodi@nnovation.ca> 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 Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-01-03 00:00
(Received via mailing list)
On 1/2/06, Jodi Showers <jodi@nnovation.ca> 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 Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
B09a3f6cdc4797532647d2d264b5df49?d=identicon&s=25 Jodi Showers (jshow)
on 2006-01-03 04: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.