Recommended Free Tools
Set a DOCX page size on its section with python-docx, or pass a width-and-height tuple in points to ReportLab when creating a PDF. In both cases, choose the dimensions, orientation, and margins deliberately: changing the page box does not make overflowing content fit. Use DOCX-first when people need an editable Word file; generate the PDF directly when the PDF is the final deliverable.
Choose whether to create DOCX first or generate the PDF directly
The right workflow depends on what the recipient needs. A custom page size can be used in either format, but the APIs and layout model differ.
| Need | Recommended approach | Why |
|---|---|---|
| An editable Word document, Word styles, or an editable source file | Create a DOCX with python-docx |
Page size and orientation are section properties in the Word document. |
| A PDF as the final artifact, with geometry controlled by your code | Create a PDF directly with ReportLab | You provide the page dimensions to the PDF canvas in points. |
| Both an editable source and a PDF deliverable | Create the DOCX and convert it using the chosen conversion engine, then inspect the PDF | The libraries document creation APIs, but do not promise identical pagination across conversion engines. |
For straightforward positioned text or graphics, ReportLab’s canvas offers low-level control. For flowing paragraphs, tables, and repeated page structures, use ReportLab Platypus. Its page templates and frames describe usable layout areas; the page size still defines the sheet.
Set a custom page size in a DOCX with python-docx
Install the library with python -m pip install python-docx. The example below creates a portrait page 6 inches wide by 9 inches tall, applies margins, adds a paragraph, and saves an editable Word 2007-or-later .docx file.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
from docx import Document
from docx.shared import Inches
from docx.enum.section import WD_ORIENT
doc = Document()
section = doc.sections[0]
section.page_width = Inches(6)
section.page_height = Inches(9)
section.orientation = WD_ORIENT.PORTRAIT
section.top_margin = Inches(0.6)
section.bottom_margin = Inches(0.6)
section.left_margin = Inches(0.7)
section.right_margin = Inches(0.7)
doc.add_paragraph("Custom-size DOCX")
doc.save("custom.docx")
Dimensions belong to a section
A DOCX section holds its page dimensions and orientation. The example changes the first section with doc.sections[0]. If different parts of the document need different page sizes, create a new section at the appropriate boundary and configure that section’s dimensions, orientation, and margins separately; do not assume a page-size assignment is a document-wide setting.
Use dimensions and orientation consistently
For landscape, assign the intended landscape width and height and set WD_ORIENT.LANDSCAPE. The python-docx example pattern for landscape swaps the width and height. Keep one clear source of truth for the dimensions and confirm the resulting orientation rather than relying on an implicit swap.
In this example, Inches(6) and Inches(9) make the units explicit. If your input dimensions are in millimetres, convert them consistently before assigning them; avoid mixing raw values in different units.
Create a custom-size PDF directly with ReportLab
Install ReportLab with python -m pip install reportlab. A canvas accepts pagesize=(width, height) in points; one point is 1/72 of an inch. Multiply inch measurements by ReportLab’s inch unit to convert them.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minutefrom reportlab.pdfgen import canvas
from reportlab.lib.units import inch
width, height = 6 * inch, 9 * inch
pdf = canvas.Canvas("custom.pdf", pagesize=(width, height))
pdf.drawString(0.5 * inch, height - 0.75 * inch, "Custom-size PDF")
pdf.showPage()
pdf.save()
The tuple is width first, height second. Here, the canvas creates a 6-by-9-inch page, and drawString places text half an inch from the left edge and three-quarters of an inch below the top edge. ReportLab’s drawing coordinates start from the lower-left, which is why the vertical position is calculated from height.
Rank #2
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
Use standard or custom dimensions
You can pass a custom point tuple as above or use a standard page-size constant such as letter or A4. Specify the intended page size explicitly. If changing the geometry of the current page after creating the canvas, setPageSize changes its page size; it does not reposition existing drawing operations.
Choose canvas or Platypus for the layout
- Canvas: choose it when you need precise coordinates and are comfortable managing text placement, wrapping, and page breaks yourself.
- Platypus: choose it when content flows across pages and includes paragraphs, tables, or repeating structures. Define the sheet size separately from the frames that constrain content.
- Canvas callbacks: use callbacks for precisely placed headers, footers, or other page-level drawing in a flowable document.
Calculate the usable area before placing content
A custom page box sets the sheet geometry, not the content layout. Subtract margins from the page width and height before sizing text blocks, tables, or images.
For a page with width W, height H, left and right margins L and R, and top and bottom margins T and B, the usable area is:
- Usable width:
W - L - R - Usable height:
H - T - B
Use the same units for every term in each calculation. For example, do not subtract a margin in millimetres from a page width in points without converting first. In a PDF canvas, drawing beyond the page boundary is clipped or invisible; in a DOCX, content that exceeds the intended text area can wrap or paginate in ways you did not plan.
Handle landscape pages and mixed-size documents
One landscape page or document
Set the intended landscape width and height together with the orientation. Make the wider dimension the page width and the shorter dimension the page height, and verify the result in the Word viewer or generated PDF. Do not set orientation while leaving dimensions in an order that conflicts with your intended output.
Rank #3
- - Convert to Word/Excel: Select your PDF and effortlessly convert it to Word or Excel.
- - Mobile Convenience: Manage your PDFs on the go with our intuitive PDF expert.
- - Free PDF Conversion: Experience the power of our PDF converter with complimentary conversions.
Different page sizes within a DOCX
Use a separate section for each region that needs distinct geometry. Set that section’s page dimensions, orientation, and margins. Check the section boundaries as well as the page size: a correctly configured section can still have content or breaks that produce unexpected pagination.
Multi-page PDFs with flowing content
For Platypus, set the page size and define frames for the content area, taking margins into account. Use page templates when page structures repeat. A custom sheet size alone does not define how long paragraphs wrap, where tables break, or how headers and footers fit.
Convert DOCX to PDF without assuming identical pagination
If the editable Word file is the source of truth, create it first and convert it with the conversion engine used for delivery. Then inspect the PDF’s page boxes, orientation, margins, fonts, line wrapping, and page breaks. The python-docx and ReportLab creation APIs do not guarantee that a converted DOCX will paginate identically across conversion engines or viewers.
If the PDF geometry is the main requirement and nobody needs an editable Word source, generating the PDF directly avoids making DOCX conversion part of the production path. If both files matter, treat them as separate deliverables and validate each one.
Validate the output before delivery
- Confirm the dimensions and units. Check width and height in the units expected by the library, including any conversion from inches or millimetres.
- Confirm orientation. Verify that the dimension order and orientation setting agree, especially for landscape or mixed-size sections.
- Check the usable area. Subtract all margins and ensure text, tables, images, headers, and footers fit within it.
- Open the generated file in the intended viewer. Inspect every page for incorrect size, orientation, clipping, wrapping, and unexpected page breaks.
- Check downstream behavior. If the file will be printed, exported, or converted, verify that the target workflow preserves the intended geometry.
Troubleshoot common page-size and layout problems
The page is the wrong size in the DOCX
Cause: The dimensions were set on a different section from the one containing the content, or the width and height were assigned in the wrong order. Fix: Select the relevant item in doc.sections, assign its page_width and page_height explicitly, and inspect section boundaries and orientation in Word.
Rank #4
- All item converter to pdf
A landscape page appears portrait or dimensions seem reversed
Cause: Orientation and dimensions were not configured together. Fix: Set the intended landscape width and height consistently with WD_ORIENT.LANDSCAPE, then reopen the output to verify the result.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →PDF text or graphics are missing at an edge
Cause: Canvas drawing occurred outside the page or usable area. Fix: Recalculate coordinates against the actual width and height, allow for margins, and keep every drawing operation within the page. Content outside the page is not visible.
Content fits on one page but overflows in another
Cause: A fixed coordinate layout or frame does not account for varying content length, or the frame does not match the margins. Fix: For flowing paragraphs and tables, consider Platypus frames and flowables; confirm the frame dimensions on each page template.
The converted PDF wraps text differently from Word
Cause: The conversion engine, viewer, or available fonts can affect layout. Fix: Validate using the actual conversion and viewing tools in the delivery path. Check font availability, page dimensions, margins, line wrapping, and page breaks rather than assuming the DOCX and PDF will match exactly.
The output uses unexpected dimensions
Cause: A unit conversion was omitted, a raw number was interpreted in points, or width and height were passed in the wrong order. Fix: Label units in variables, convert at the boundary, and log or inspect the final dimensions passed to the library.
Best Value
- All-in-one office pack - Documents, Sheets, Slides & PDF
- Cross-platform (Android, iOS, Windows PC)
- Supports Microsoft Office formats
- Use 30+ charts & 250+ formulas in Sheets
- In-depth features for document creation & formatting
Performance, reliability, and cost considerations
These examples create files locally through Python libraries; the cited APIs do not establish a processing benchmark or a particular runtime. For repeatable results, keep dimensions, margins, fonts, and conversion settings explicit and validate the same output path used in production. A direct PDF workflow removes DOCX conversion as a dependency, while a DOCX workflow preserves an editable source at the cost of validating the conversion step if a PDF is also required. Neither approach can prevent layout overflow without suitable content-area calculations.
Or skip the browser setup
This document workflow does not require browser screenshots. If your project also needs website captures, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. Its clean-shot steps can accept cookie or consent banners and remove 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with verdict and billing information returned in response headers.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Its MCP tools include take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for free and get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can one DOCX contain pages of different sizes?
Yes. Configure a separate section for each page-size region and set that section’s dimensions, orientation, and margins.
Free tools Windows power users keep installed
One-click scans. No signup required.
Should I use ReportLab canvas or Platypus?
Use canvas for precise, manually positioned drawing; choose Platypus for flowing paragraphs, tables, and repeated page structures.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

