elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.92k stars 378 forks source link

Inserting a subTemplate with different Header and footer into the main template #503

Open Tanishqmalu opened 11 months ago

Tanishqmalu commented 11 months ago

Describe your problem

Suppose my main template contains 3 page: Page - 1: Header = "Main Header 1" Body = "I am a normal text on page 1" Footer = NULL Page - 2: Header = "NULL" Body = "I am a normal text on page 2. {{ Insert sub template here }}" Footer = NULL Page - 3: Header = "Main Header 2" Body = "I am a normal text on page 3" Footer = NULL

Sub Template contains 2 page: Page - 1: Header = "Sub Header 1" Body = "I am a normal text on sub template page 1" Footer = NULL Page - 2: Header = "Sub Header 2" Body = "I am a normal text on sub template page 2. " Footer = NULL

Expected output: Page - 1: Header = "Main Header 1" Body = "I am a normal text on page 1" Footer = NULL Page - 2: Header = "Sub Header 1" Body = "I am a normal text on sub template page 1" Footer = NULL Page - 3: Header = "Sub Header 2" Body = "I am a normal text on sub template page 2. " Footer = NULL Page - 4: Header = "Main Header 2" Body = "I am a normal text on page 3" Footer = NULL

When I try to add subdocument using new_subdoc function, The output is quite different from what is expected? Is there a way to solve this? @elapouya