Images seem to start some where at the end of the page

4 views
Skip to first unread message

ct9a

unread,
Jun 22, 2010, 5:55:45 AM6/22/10
to Prawn
hello, guys,

I got the text on one of my html pages converted into a simplified
pdf version in minutes with Prawn To (I am running rails 2.3.5 and my
images are managed with the paperclip plugin).

With that success, I thought I put my images in.

Basically, consider a page that describes some second hand goods for
sale.
There's a title, description, contact details and about 5 to 6 images.

What I am finding is that my images seem to appear towards the
bottom of each of the pages.

Hence, if there were 5 images and a short bit of text, it looks to me
that
1) each image has its own page
2) each image consistently gets positioned at the end of the pages

Why is that so?

Here's how my simple code looks like:


----- Start
-------------------------------------------------------------------------------



require "open-uri"

pdf.image open( request.protocol + request.host + '/images/logo-for-
pdf.png' )

pdf.text @item.title

details = Array.new()
details.push( [ 'Category', @item.category.name ])
details.push(
[ 'Sub category', @item.sub_category.name ?
@item.sub_category.name : '-' ]
)
details.push( ['Description', @item.description ] )

pdf.table details, :border_style => :grid,
:row_colors => ["FFFFFF", "DDDDDD"],
:align => { 0 => :left, 1 => :left }

for image in @item.images
pdf.image (image.info.path(:medium));
end


----- End
-------------------------------------------------------------------------------



Any ideas?

Gregory Brown

unread,
Jun 22, 2010, 8:55:57 AM6/22/10
to prawn...@googlegroups.com
On 6/22/10 4:55 AM, ct9a wrote:

> Any ideas?

No, we don't have any ideas, because you just pasted a bunch of Rails
code on us without giving us something we can run. Try your code
outside of Rails, include any images you use, and give us something we
can run without access to your environment.

And then we can give you some ideas.

Gordon Yeong

unread,
Jun 22, 2010, 9:20:13 AM6/22/10
to prawn...@googlegroups.com
sorry, i am aware you can't run the bunch of codes i have given but that's essentially what runs prawn (via prawn to's pdf variable).
In general,  how would one go about displaying a bunch of text content followed by an image (without the image coming up at the
bottom of each of the pages)?

thank you.

Gregory Brown

unread,
Jun 22, 2010, 9:52:01 AM6/22/10
to prawn...@googlegroups.com
On 6/22/10 8:20 AM, Gordon Yeong wrote:
> sorry, i am aware you can't run the bunch of codes i have given but
> that's essentially what runs prawn (via prawn to's pdf variable).
> In general, how would one go about displaying a bunch of text content
> followed by an image (without the image coming up at the
> bottom of each of the pages)?

Please show us code that you think should do something that it doesn't.
That's the only way we can help you without shooting in the dark.

-greg

Gordon Yeong

unread,
Jun 22, 2010, 10:03:13 AM6/22/10
to prawn...@googlegroups.com


----- Start ------------------------------




require "open-uri"

pdf.image open( request.protocol + request.host + '/images/logo-for-
pdf.png' )

pdf.text @item.title

details = Array.new()
details.push( [ 'Category', @item.category.name ])
details.push(
 [ 'Sub category', @item.sub_category.name ?
@item.sub_category.name : '-'  ]
)
details.push( ['Description', @item.description ] )

pdf.table details, :border_style => :grid,
  :row_colors => ["FFFFFF", "DDDDDD"],
  :align => { 0 => :left, 1 => :left }

for image in @item.images                           <----- Seems that going through the loop of images I have seems
                                                                               to give each image its own page

 pdf.image (image.info.path(:medium));
end


----- End --------------------------

thank you .



Gregory Brown

unread,
Jun 22, 2010, 11:21:07 AM6/22/10
to prawn...@googlegroups.com
On 6/22/10 9:03 AM, Gordon Yeong wrote:
>
>
> ----- Start ------------------------------
>
>
>
>
> require "open-uri"
>
> pdf.image open( request.protocol + request.host + '/images/logo-for-
> pdf.png' )

We don't have this on our machines

> pdf.text @item.title


We don't have this on our machines

> pdf.table details, :border_style => :grid,
> :row_colors => ["FFFFFF", "DDDDDD"],
> :align => { 0 => :left, 1 => :left }
>
> for image in @item.images <----- Seems that
> going through the loop of images I have seems


We don't have this on our machines

CODE, THAT RUNS STANDALONE, OUTSIDE OF RAILS. THATS WHAT WE NEED.

Gordon Yeong

unread,
Jun 22, 2010, 9:28:58 PM6/22/10
to prawn...@googlegroups.com
I will try and get something that's outside of rails but if there's any other rails users using prawn with prawnto,
I would like to hear your thoughts.

thank you all.



On 23 June 2010 01:21, Gregory Brown <gregor...@letterboxes.org> wrote:


CODE, THAT RUNS STANDALONE, OUTSIDE OF RAILS.  THATS WHAT WE NEED.

DONT NEED TO SHOUT

Gregory Brown

unread,
Jun 22, 2010, 10:32:16 PM6/22/10
to prawn...@googlegroups.com
On 6/22/10 8:28 PM, Gordon Yeong wrote:

> CODE, THAT RUNS STANDALONE, OUTSIDE OF RAILS. THATS WHAT WE NEED.
>
>
> DONT NEED TO SHOUT

I asked you several times to give us what we need so that we could help
you, and you seemed to have completely ignored me.

I was hoping giant caps would catch your attention, and they seem to
have done so, but until you post code, we can't help you. So please
make sure that your next post to this list contains something we can
work with.

-geg

Gordon Yeong

unread,
Jun 22, 2010, 10:35:08 PM6/22/10
to prawn...@googlegroups.com
hello, Greg,

  I have just started using prawn via prawnto in my rails app. I find it's a really lightweight tool for generating pdfs. I like it
and I m trying to expand my use of it (ie. by putting in images).

  Perhaps this is the wrong list to post the question. Is there such a thing as a prawnto group/forum?

thank you.

Gordon Yeong :)

Gregory Brown

unread,
Jun 22, 2010, 10:41:34 PM6/22/10
to prawn...@googlegroups.com
On 6/22/10 9:35 PM, Gordon Yeong wrote:
> hello, Greg,
>
> I have just started using prawn via prawnto in my rails app. I find
> it's a really lightweight tool for generating pdfs. I like it
> and I m trying to expand my use of it (ie. by putting in images).
>
> Perhaps this is the wrong list to post the question. Is there such a
> thing as a prawnto group/forum?

There is no such thing, unfortunately. The main reason is that Prawnto
has been abandoned by its original author. We have a supported process
for using Prawn in Rail, and it is documented here:

http://wiki.github.com/sandal/prawn/using-prawn-in-rails

But in order to answer questions about Prawn behavior, whether you are
using Prawnto or not, you still would need to give us code that runs
outside of Rails.

Keep in mind when you show us code that is not directly runnable, and
has not been stripped down to a minimal example, you're literally asking
us to spend time figuring out your code and helping you debug what might
be a user error. We do offer consulting hours, but this is not the
place to do it. :)

Instead, take 5 minutes to reproduce your issue in pure Ruby, and we can
help you then. When you show consideration for the time of the
volunteers on this list by cleaning up and preparing your questions and
test code, you will definitely see that returned to you in volumes.

Otherwise, you might see ALL CAPS GTFO messages ;)

-greg

Gordon Yeong

unread,
Jun 22, 2010, 11:03:08 PM6/22/10
to prawn...@googlegroups.com
Greg

Yep, I have managed to strip the codes down to a ruby script.

I have the following source code. Run it. Observe that the images consistently
1) get placed at the bottom of pages
2) cause a new page to be made for each image

------------- Start ------------------------------------------
require 'prawn'
require 'open-uri'

Prawn::Document.generate("test_basic_images.pdf", :page_layout => :landscape) do
    image open( 'http://ccinsider.comedycentral.com/files/2010/05/blog_futurama_375x75.jpg')
    move_down(10)

    text 'This is a title'

    move_down(10)

    details = Array.new()
    details.push( [ 'Category: ' +  ' t-shirts' ])
    details.push(
      [ 'Sub category: threadless' ]
    )

    details.push( ['Description:  Nice white t shirts suitable for company promo.' ] )

    details.push( [ 'Location: Victoria '  ] )
    details.push( [ 'Contact: Gordon' ] )

    move_down(5)
    text 'Please confirm all details with the seller.'
    move_down(5)
    text 'Printed on ' + Time.now.strftime("%I:%M%p %Y-%m-%d")

    image open 'http://4.bp.blogspot.com/_hY0FQwcl9tM/S1iXpaBY5wI/AAAAAAAAC2o/HbFH9u8ewwY/s400/1958_corum_chinesehat.jpg'
    image open 'http://3.bp.blogspot.com/_hY0FQwcl9tM/S1iYorX6VRI/AAAAAAAAC2w/5MYCxGg9IxY/s400/1960-admirals-cup.jpg'
    image open 'http://cache.gawker.com/assets/images/4/2010/01/500x_template_10.jpg'
end

------------End -------------------------------------------------

thank you

Gregory Brown

unread,
Jun 23, 2010, 9:05:28 AM6/23/10
to prawn...@googlegroups.com
On 6/22/10 10:03 PM, Gordon Yeong wrote:
> Greg
>
> Yep, I have managed to strip the codes down to a ruby script.
>
> I have the following source code. Run it. Observe that the images
> consistently
> 1) get placed at the bottom of pages
> 2) cause a new page to be made for each image

Reproducing on edge. Please file an issue at:
http://github.com/sandal/prawn/issues and include this example.

Gordon Yeong

unread,
Jun 25, 2010, 7:21:27 PM6/25/10
to prawn...@googlegroups.com
greg,
 i have logged an entry  at http://github.com/sandal/prawn/issues#issue/125 as advised.
 
thanks

Gordon Yeong

unread,
Jul 6, 2010, 6:30:20 PM7/6/10
to prawn...@googlegroups.com
hi Greg/guys
 Any progress on this bug?
 
thanks 

Gregory Brown

unread,
Jul 6, 2010, 6:35:02 PM7/6/10
to prawn...@googlegroups.com
On 7/6/10 6:30 PM, Gordon Yeong wrote:
> hi Greg/guys

No need to address me directly on this list. It's not my inbox and we
have plenty of core devs and contributors who are more active than I am :)

> Any progress on this bug?

See this post:
http://groups.google.com/group/prawn-ruby/msg/0a2923726a810d9a

I just gave Jonathan the thumbs up on merging his fix, though it may be
a temporary stop-gap.

Reply all
Reply to author
Forward
0 new messages