Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How does the margin_top argument of PageBreak work? #136

Closed
stenci opened this issue Sep 10, 2021 · 4 comments · Fixed by #137
Closed

How does the margin_top argument of PageBreak work? #136

stenci opened this issue Sep 10, 2021 · 4 comments · Fixed by #137
Labels
bug Something isn't working

Comments

@stenci
Copy link
Contributor

stenci commented Sep 10, 2021

I am building a multipage PDF by adding a few pages separated by PageBreak. Everything seems to be working well. I don't really need an answer here for completing my job, but since I don't understand what an undocumented and apparently useless, but required parameter does, I thought I would bring it up here.

I tried using both 1 and 500 integers and '1px' and '500px' strings with the following code, but the result doesn't change:

class PrintPDF(PrintPDFTemplate):
  def __init__(self, project_number, release_number, truck_number, **properties):
    self.release = Release(project_number, release_number)
    self.truck = self.release.trucks[truck_number - 1]

    self.init_components(**properties)

    self.add_component(TruckPDF(self.truck))
    self.add_component(PageBreak('500px'))
    self.add_component(TruckPDF(self.truck))
    self.add_component(PageBreak('1px'))
    self.add_component(TruckPDF(self.truck))

I wasn't expecting it to require any parameter, but since one is required, I was expecting to see some difference in the top margin. instead it doesn't make any difference.

This is the result on the browser:
image

and this is the result on the PDF"
image

@hugetim
Copy link
Member

hugetim commented Sep 11, 2021

@stenci, thanks for reporting this. Here's a way to say the same thing that I would find more pleasant to read, for next time:

The margin_top property of PageBreak doesn't have the effect that I expected. Also, please make it an optional argument.

@stenci
Copy link
Contributor Author

stenci commented Sep 11, 2021

@hugetim
I apologize if my post sounded offensive or negative in any way. It was not my intention at all.

I just re-read my post and it didn't look harsh, offensive or rantish in any way. At least to me, I will blame it on English not being my first language.

I had a question, I investigated a little trying to understand, I failed, so I asked the question documenting my investigation.

Here is my thought process while writing it:

  • I had a question and I opened an issue with the question as subject
  • I said "I don't really need an answer" meaning I'm ok if you don't want to waste your time addressing it
  • "I don't understand" meaning it's ME not understanding
  • "apparently useless" I intentionally put apparently right after don't understand, again to blame it on myself
  • "I thought I would bring it up here" again meaning it's not important, I just want to share my thought in case you find it useful
  • I added snapshots to show what I was looking at, to make it easier for you to tell me if I was looking in the wrong place

It looks like I tried to be nice too hard and something went wrong.
Again, I apologize.

@s-cork s-cork added the bug Something isn't working label Sep 11, 2021
@s-cork
Copy link
Collaborator

s-cork commented Sep 11, 2021

It has no effect in the designer.
In some cases there is unnecessary space at the top of the generated page.
(Or at least that's what I found - but that can be browser/os specific)
so setting the margin-top to be negative might help with the final pdf.

However it clearly wasn't working and the pdf you've shown works as I'd expect.

Anyway I've fixed this in #137 by making it optional.
And documenting it.

@hugetim
Copy link
Member

hugetim commented Sep 11, 2021 via email

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants