Embedding JPGs error

90 views
Skip to first unread message

Wes Garrison, Databasically

unread,
Nov 17, 2011, 1:38:03 AM11/17/11
to Prawn
I've used prawn for several years now, but this is a new error:

Failure/Error: page_counter =
PDF::Inspector::Page.analyze(doc.render)
PDF::Reader::MalformedPDFError:
PDF malformed, expected 'endstream' but found 0 instead

Same error for any of the analyze() methods.

Outputted PDFs won't open (via OS X Preview).

It happens when I'm embedding JPGs; if I convert them to PNGs they
work ok. I've tried big images, small images, several variations and
can't get anything to work.

I'm tracking prawn master on this project, but the code in image/jpg/
png hasn't changed in a couple months, so it sure seems like someone
else would have run into this before me. I happen to be on c041a7,
specifically.

I don't get the UnsupportedImage exception when adding the file, but
it looks like the file isn't being embedded into the PDF at all.

Suggestions? If I can provide more information, let me know what.

---
Wes Garrison
Databasically

Brad Ediger

unread,
Nov 18, 2011, 10:33:52 AM11/18/11
to prawn...@googlegroups.com
On Thu, Nov 17, 2011 at 12:38 AM, Wes Garrison, Databasically
<w...@databasically.com> wrote:
> I've used prawn for several years now, but this is a new error:
>
>     Failure/Error: page_counter =
> PDF::Inspector::Page.analyze(doc.render)
>     PDF::Reader::MalformedPDFError:
>       PDF malformed, expected 'endstream' but found 0 instead
>
> Same error for any of the analyze() methods.
>
> Outputted PDFs won't open (via OS X Preview).

Trying to understand your workflow here. Are you feeding the output of
Prawn into pdf-inspector? Can you give a sample of the PDF that is
causing the pdf-inspector errors?

-be

Wes Garrison, Databasically

unread,
Nov 18, 2011, 11:20:52 AM11/18/11
to Prawn
> Trying to understand your workflow here. Are you feeding the output of
> Prawn into pdf-inspector?

I'm doing basically the same thing as the prawn tests:

page_counter = PDF::Inspector::Page.analyze(doc.render)

> Can you give a sample of the PDF that is
> causing the pdf-inspector errors?

http://cl.ly/3d233i1y1g1M0D011638

Minimal lines of code to reproduce:
https://gist.github.com/1376918

Been kinda stumped about this for the past couple days, so thanks,
Brad.

---
Wes Garrison

Brad Ediger

unread,
Nov 18, 2011, 11:25:52 AM11/18/11
to prawn...@googlegroups.com
On Fri, Nov 18, 2011 at 10:20 AM, Wes Garrison, Databasically
<w...@databasically.com> wrote:
> Minimal lines of code to reproduce:
> https://gist.github.com/1376918

This works for me with a JPEG I had around, using
data/images/fractal.png from the Prawn distribution. Can you provide
the banner.jpg image that is causing problems?

-be

Wes Garrison, Databasically

unread,
Nov 18, 2011, 12:18:22 PM11/18/11
to Prawn

Brad Ediger

unread,
Nov 18, 2011, 12:40:07 PM11/18/11
to prawn...@googlegroups.com
Your test seems to be working for me, under the latest Prawn master
(c041a778) and Ruby 1.9.3-p0. The resulting PDF opens in OS X Preview
and shows the banner image.

Anything weird about your environment? Are you on a strange version /
patchlevel of Ruby? On Windows or another strange platform?

-be

On Fri, Nov 18, 2011 at 11:18 AM, Wes Garrison, Databasically

Wes Garrison, Databasically

unread,
Nov 18, 2011, 1:00:48 PM11/18/11
to Prawn
OS X, Snow Leopard

ruby-1.9.2-p290 (via rvm)

GIT
remote: git://github.com/sandal/prawn.git
revision: c041a778d76ab15fc1729b08018cc362810f5986
branch: master

I don't have any idea what else to check! I'm running in a separate
gemset, but it's apparently something local to my machine.

Guess I... do something else. Maybe I'll try 1.9.3 and see if that
magically resets something. Not sure what else to try, but thanks for
confirming.

Reply all
Reply to author
Forward
0 new messages