[reportlab-users] How to change margins from page to page

Paul Keating Paul.Keating at nibc.com
Fri Mar 14 11:14:08 EDT 2014


What you want to do means that your document is no longer "simple".

To achieve different page layouts you need to up two page templates that define the margins. That's not hard:

FirstPageTextFrame = Frame( ...dimensons... )
StatementFirstPage = PageTemplate (id='Page 1', frames=[FirstPageTextFrame], onPage=FirstPageStatic)

where FirstPageStatic is the function that sets up your fixed header and footer.

OtherPageTextFrame = Frame( ...dimensons... )
StatementFirstPage = PageTemplate (id='Page N', frames=[OtherPageTextFrame], onPage=OtherPageStatic)

Once you've done that you can use a BaseDocTemplate instead of a SimpleDocTemplate:

doc = BaseDocTemplate(filename, pageTemplates=[StatementFirstPage, StatementOtherPage])

Then the first thing you put in your Story is an indication that all pages beyond the first use the alternate page template:

Story = []
Story.append(NextPageTemplate('Page N'))
Story.append( ...flowable... )
etc

I think I'm correct in saying that you really are using a Frame, it's just a default one.

Paul Keating

From: reportlab-users-bounces at lists2.reportlab.com [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Mike Driscoll
Sent: 14 March 2014 14:59
To: reportlab-users
Subject: [reportlab-users] How to change margins from page to page

Hi,
I have a case where the first page of a document has two inches worth of fixed header information and another 4 inches of data on the bottom of the document that is taken up with a check. The middle 3 or 4 inches on the first page is for dynamic flowable stuff, like a table and some paragraphs. The first page works great.
I am using a bottom margin of 4 inches for it. However, I don't need to have a bottom margin on any pages past the first page. How do I change the margins for the rest of the document?
I tried adding this to my later pages method:

doc.bottomMargin = 0.5 * inch
But that doesn't have any effect. I also saw this post from a few years ago:

http://two.pairlist.net/pipermail/reportlab-users/2011-November/010262.html
But I'm not using Frames. Does anyone have any insights? I am using a SimpleDocTemplate. Thanks!

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

________________________________

The information contained in this e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail. Please delete this e-mail and do not disclose its contents to any person. NIBC Holding N.V. nor its subsidiaries accept liability for any errors, omissions, delays of receipt or viruses in the contents of this message which arise as a result of e-mail transmission. NIBC Holding N.V. (Chamber of commerce nr. 27282935), NIBC Bank N.V. (Chamber of commerce nr. 27032036) and NIBC Investment Management N.V. (Chamber of commerce nr. 27253909) all have their corporate seat in The Hague, The Netherlands.

De informatie in dit e-mailbericht is vertrouwelijk en uitsluitend bestemd voor de geadresseerde. Wanneer u dit bericht per abuis ontvangt, gelieve onmiddellijk contact op te nemen met de afzender per kerende e-mail. Wij verzoeken u dit e-mailbericht te Vernietigen en de inhoud ervan aan niemand openbaar te maken. NIBC Holding N.V. noch haar dochterondernemingen aanvaarden enige aansprakelijkheid voor onjuiste, onvolledige dan wel ontijdige overbrenging van de inhoud van een verzonden e-mailbericht, noch voor door haar daarbij overgebrachte virussen. NIBC Holding N.V. (KvK nr. 27282935), NIBC Bank N.V. (KvK nr. 27032036) en NIBC Investment Management N.V. (KvK nr. 27253909) zijn statutair gevestigd te Den Haag, Nederland.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20140314/a783408b/attachment.html>


More information about the reportlab-users mailing list