Prawn PDF problems on header and number pages

1,016 views
Skip to first unread message

Phoebe

unread,
Nov 16, 2009, 3:53:08 AM11/16/09
to Prawn
Hi Prawn team:

1.
I found header(pdf.header) always be covered by contents.
but when i changed document.rb -> row 235:
@y = @bounding_box.absolute_top
change to @y = @bounding_box.absolute_top - 40

then this problem gone.

2.
There are 3 pages in my test code, but if i use code:
pdf.number_pages "/", [doc.pdf.margin_box.right, 0]
then the third page's content will cover the second page's
content.
I also run the code on
http://github.com/sandal/prawn/blob/stable/examples/general/page_numbering.rb
but i got the same problem.

3.
And another problem, I don't know how to fix, I tried many way
but this problem still there,
so I think may it's a bug.
In my pdf(3 pages), have a big table start in the first page and
end in the second page,
but there are half page white space in the second page, I
tried to remove it and let the content
on third page move to the second page, but failed.
If I remove the big table, the big white space gone.

my ruby env

ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
Rails 2.2.2
prawn (0.6.1)
prawn-core (0.6.1)
prawn-format (0.2.2)
prawn-layout (0.3.1)
prawn-security (0.1.1)

Gregory Brown

unread,
Nov 16, 2009, 10:23:16 AM11/16/09
to prawn...@googlegroups.com
On Mon, Nov 16, 2009 at 3:53 AM, Phoebe <sunj...@gmail.com> wrote:
>
> Hi Prawn team:
>
>   1.
>      I found header(pdf.header) always be covered by contents.
>      but when i changed document.rb -> row 235:
>      @y = @bounding_box.absolute_top
>      change to @y = @bounding_box.absolute_top - 40
>
>      then this problem gone.

I'm sure that makes some other exciting changes as well.
You know, we do have better ways of setting the margin :)

The general suggestion with headers is to bound all of your content
inside of a bounding box, and then draw your headers in the area above
that box.
Search the archive for lots and lots of discussion. None of us like
Prawn's header support, it will improve in the future.

>   2.
>      There are 3 pages in my test code, but if i use code:
>      pdf.number_pages "/", [doc.pdf.margin_box.right, 0]
>      then the third page's content will cover the second page's
> content.
>      I also run the code on
>      http://github.com/sandal/prawn/blob/stable/examples/general/page_numbering.rb
>      but i got the same problem.

You are placing this just outside of the right margin with the
baseline flush with the bottom of the page?
Is that intentional?

Anyway, I don't think this has anything to do with the different pages
contents, unless you did something like

# do something
number_pages(...)
# do something else

and forgot to start a new page there.

But in order to see the problem you are having, I need a complete,
runnable code example, what viewer you are using, and an attachment
with the PDF you generated.

>   3.
>      And another problem, I don't know how to fix, I tried many way
> but this problem still there,
>      so I think may it's a bug.
>      In my pdf(3 pages), have a big table start in the first page and
> end in the second page,
>      but there  are half page white space in the second page,  I
> tried to remove it and let the content
>      on third page move to the second page, but failed.
>      If I remove the big table, the big white space gone.

It's completely impossible to know what's going on here without an
example we can run.

sun sunjing

unread,
Nov 16, 2009, 11:07:23 PM11/16/09
to prawn...@googlegroups.com
Ni hao Gregory:

  Thank you very much, 1st and 2nd problems are gone.

   page numbering problem is gone when i updated prawn gem to 0.6.2.

   but the third problem still there, Please check the PDF file(test-1.pdf) in Attachment, you can see there are half page white space in the second page.
If I remove the big table, the big white space gone, you can check PDF file(test-2.pdf) in attachment.
You can find my source code(testpdf.rb) in attachment.





2009/11/16 Gregory Brown <gregory...@gmail.com>



--
phoebe sun
test-1.pdf
test-2.pdf
experience_logo.jpeg
testpdf.rb

Gregory Brown

unread,
Nov 17, 2009, 12:32:50 AM11/17/09
to prawn...@googlegroups.com
On Mon, Nov 16, 2009 at 11:07 PM, sun sunjing <sunj...@gmail.com> wrote:
> Ni hao Gregory:
>
>   Thank you very much, 1st and 2nd problems are gone.
>
>    page numbering problem is gone when i updated prawn gem to 0.6.2.
>
>    but the third problem still there, Please check the PDF file(test-1.pdf)
> in Attachment, you can see there are half page white space in the second
> page.

Looks like you did find a bug. This is related to the change in
bounding box stretchiness calculations.
It can be reproduced trivially with this:

require "prawn/core"
require "prawn/layout"

Prawn::Document.generate("table.pdf") do
table((1..35).map { [ "foo"] }, :position => :center)
text "Hi"
end

If I can put together a quick fix, I'll include it in the 0.6.3
release, which I plan to do first thing tomorrow morning.


-greg

Reply all
Reply to author
Forward
0 new messages