0

I read the documentation for ReportLab and though they have good examples for each individual facet (Frames, Flowables, PageTemplates) I can't find anything to tie them together. I am struggling with how to build a story with a custom page template.

I want to make a pdf that looks like this:

|----------------------------|
| Image1 | Image 2 | Sidebar |
|------------------|         |
| Paragraphs       |         |
|----------------------------|
|Graph (image)               |
|----------------------------|

Setting the frames is fairly trivial:

f_image1 = Frame(0, HEIGHT*2/3, WIDTH/3, HEIGHT/3)
f_image2 = Frame(WIDTH/3, HEIGHT*2/3, WIDTH/3, HEIGHT/3)
f_sidebar = Frame(WIDTH*2/3, HEIGHT/3, WIDTH*2/3, HEIGHT*2/3)
f_paragraphs = Frame(0, HEIGHT/3, WIDTH/3, HEIGHT/3)
f_graph = Frame(0, 0, WIDTH, HEIGHT/3)

page_template = PageTemplate(id='myTemplate', frames=[f_image1, f_image2, f_sidebar, f_paragraphs, f_graph])

But from here, I'm not sure how to connect my story to my page_template in an intuitive way. I want certain text to go into the sidebar, certain text to go into the paragraphs, etc.

I tried putting all my story items into a list (story=[]) but then it didn't have the desired effect as text and/or images didn't go into the desired places.

I'm sure I'm just missing something really trivial, but the documentation doesn't give me any hints. (please note, I don't want to manually place things, as the sidebars/paragraphs will flow into many pages)

Can anyone help?

Gen
  • 1
  • 2
  • I have used flowables, Django FileResponse to create custom complex pdf file. https://docs.djangoproject.com/en/4.2/howto/outputting-pdf/ – Jisson Jul 13 '23 at 04:26

0 Answers0