IronSoftware
  • Products
    for .NET Java Python
    Create, read, and edit PDFs
    for .NET
    Image to text in 127 languages
    for .NET
    Read and write QR & Barcodes
    for .NET
    Edit Excel & CSV Files.
    No Office Interop required
    for .NET
    Extract structured data from websites
    5 for the Price of 2 All 5 .NET product licenses from $1498 Save 60% with Iron Suite Iron Suites - Donate $50
  • Open Source
    for .NET
    System.Drawing.Common Replacement
    Free Software Development Tools
  • About Us

    Our Company

    • About Us 
    • Company News 
    • Environmental Commitments 
    • Beta Program 
    • Year in Review: 2022 

    Sales Partners

    • Global Resellers 

    Contact Us

    • Live Chat 
    • Send an Email 
    +1 (312) 500-3060
    205 N. Michigan Ave.
    Chicago, IL 60611, USA

    Careers at Iron

    Join our teamJoin our team
    We're hiring
  • Contact Us

205 N. Michigan Ave. Chicago, IL 60611, USA +1 (312) 500-3060

Join Iron Slack

  • Home
  • Licensing
  • EULA
  • Start 30-Day Trial
  • Get Started
  • Code Examples
  • Tutorials
  • How-Tos
  • Troubleshooting
  • Product Updates
  • Search
  • Free pip Install
IronPDF Library for Python IronPDF Library for Python
  • IronPDF for .NET
  • IronPDF for Java
  • Home
  • Licensing
    • Licensing
    • EULA
    • Start 30-Day Trial
  • Docs
    • Search
    • Get Started
    • Code Examples
    • Tutorials
    • How-Tos
    • Troubleshooting
    • Product Updates
    • Search
  • Search CtrlK
  • Free pip Install
Message's icon
IronPDF
IronPDF
Iron Software Product Iron Software Documents

Search

CtrlK
  • Get Started
  • Code Examples
    • HTML to PDF
    • Compatibility
      • License Keys
    • Generating PDFs
      • Create PDF
      • PDF to Image
    • Editing PDFs
      • Compress PDFs
      • Merge PDFs
      • Print PDFs
      • Fill PDF Forms
    • Exception Messages
      • Failed to locate IronPdf.Slim.dll
      • Module Not Defined
    • Changelog
Install with pip

Install with pip

Version: 2023.9.1

> pip install ironpdf

HTML to PDF
HTML to PDF HTML Files to PDF URL to a PDF
Convert Images
Images To PDF TIFF to PDF with Multi-Page Support Embedding Bitmaps and Images Add Barcodes in HTML to PDF
Apply Settings
HTML Rendering Settings Set Temp PDF File Path
Supports
RTF to PDF Markdown to PDF Rasterize a PDF to Images Website & System Logins Parallel PDF Generation Async PDF Generation PDF/A Document Export
Use HTML Assets
JavaScript in HTML To PDF Execute Custom JavaScript Angular.JS to PDF Rendering Charts in PDFs Custom Fonts in HTML to PDF
Set View
Responsive HTML to PDF
Apply Templates
Add Classic Text Headers & Footers Add HTML Headers & Footers Add Headers/Footers on Specific Pages Page Numbers and Page Breaks Attach a Cover Page
Apply Page Settings
Set Custom Margins Custom PDF Size Portrait & Landscape Orientation Set to Grayscale
International Languages
Unicode & UTF-8 Support
Change Page Structure
Joining Two or More PDFs Split a PDF and Extract Pages Remove Specific PDF Pages Copying Pages between PDF Files
Edit Content
Editing PDFs Stamping HTML Content Watermarking Backgrounds & Foregrounds Adding HTML Content Efficiently Annotations Outlines & Bookmarks Add Attachments
Use Forms
PDF Forms
Apply Document Settings
PDF Compression Passwords, Security & Metadata Digital Signatures PDF Encryption & Decryption
Send PDF to a Printer
Paper Printing PDFs
Read a PDF
Extract Image Extract Text

Set Custom Margins

from ironpdf import *
 
renderer = ChromePdfRenderer()

# Set Margins (in millimeters)
renderer.RenderingOptions.MarginTop = 40
renderer.RenderingOptions.MarginLeft = 20
renderer.RenderingOptions.MarginRight = 20
renderer.RenderingOptions.MarginBottom = 40

renderer.RenderHtmlFileAsPdf("my-content.html").SaveAs("my-content.pdf")
#Set Margins (in millimeters)
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'from ironpdf import * renderer = ChromePdfRenderer() renderer.RenderingOptions.MarginTop = 40 renderer.RenderingOptions.MarginLeft = 20 renderer.RenderingOptions.MarginRight = 20 renderer.RenderingOptions.MarginBottom = 40 renderer.RenderHtmlFileAsPdf("my-content.html").SaveAs("my-content.pdf")

Set Custom Margins

Related Docs Links

Ready to get started? Version: 2023.9.1 just released

Free pip Install View Licenses >
Try IronPDF for Free
Get Set Up in 5 Minutes
Python Module Download for PDF
Install with pip
Version: 2023.9.1
 pip install ironpdf
https://pypi.org/project/IronPdf/
  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module
Version: 2023.9.1
Download Now
Manually install into your project
  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2023.9.1-py37-none-win_amd64.whi
Licenses from $749

Have a question? Get in touch with our development team.

15 1000 1
Now that you’ve downloaded IronPDF
Want to deploy IronPDF to a live project for FREE?
Not ready to buy?

Want to deploy IronPDF to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No watermarks in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
15 1000 1
Your Trial License Key has been emailed to you.
Not ready to buy?
Thank you.
View your license options:
Thank you.
If you'd like to speak to our licensing team:
View Licensing
Schedule a call
Have a question? Get in touch with our development team.
Have a question? Get in touch with our development team.
15 1000 1
Want to deploy IronPDF to a live project for FREE?
Not ready to buy?

Want to deploy IronPDF to a live project for FREE?

What’s included?
30 days of fully-functional product
Test and share in a live environment
No watermarks in production
Get your free 30-day Trial Key instantly.
Thank you.
If you'd like to speak to our licensing team:

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Schedule a call
Have a question? Get in touch with our development team.
No credit card or account creation required
15 1000 1
Your Trial License Key has been emailed to you.
Not ready to buy?
Download IronPDF free to apply
your Trial Licenses Key
Thank you.
If you'd like to speak to our licensing team:
Free pip Install View Licenses
Schedule a call
Licenses from $749. Have a question? Get in touch.
Have a question? Get in touch with our development team.
IronPDF for Python

Get started for FREE

No credit card required

Fully-functional product

Get 30 days of fully-functional product.
Have it up and running in minutes.

bullet_calendar

Test in a live environment

Test and share in a live environment.
Works wherever you need it to.

bullet_test

No watermarks

No watermarks in production.
No limits.

bullet_watermark
IronPDF for Python

Get your free 30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required

badge_greencheck_in_yellowcircle

The trial form was submitted
successfully.

Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com

Trusted by Over 2 Million Engineers Worldwide

  • aetna_logo
  • wwf_logo
  • nasa_logo
  • usda_logo
  • 3m_logo
  • tesla_logo
IronPDF for Python

Get started for FREE

No credit card required

Fully-functional product

Get 30 days of fully-functional product.
Have it up and running in minutes.

bullet_calendar

Test in a live environment

Test and share in a live environment.
Works wherever you need it to.

bullet_test

No watermarks

No watermarks in production.
No limits.

bullet_watermark
IronPDF for Python

Your Trial License Key has been emailed to you.

Install with pip
View Licensing

Licenses from $749. Have a question? Get in touch.

Trusted by Over 2 Million Engineers Worldwide

  • aetna_logo
  • wwf_logo
  • nasa_logo
  • usda_logo
  • 3m_logo
  • tesla_logo
Free 30-Day Trial Key Start for Free Start Free Trial Start Free 30-Day Trial Free 30-Day Trial Key Start for Free Start Free Trial Start Free 30-Day Trial

Fully-functional product, get the key instantly

IronPDF for Python

When you need your PDF to look like HTML, fast.

Documentation

  • Code Examples
  • Blog
  • Credits

Tutorials

  • Get Started
  • HTML to PDF

Licensing

  • Buy a License
  • Resellers
  • License Keys
  • EULA

Try IronPDF Free

  • Download with pip
  • Download Module

  • 30-Day Trial License

When you need your PDF to look like HTML, fast.

Tesseract 5 OCR in the languages you need, We support 127+.

When you need to read, write, and style, QR & Barcodes, fast.

The Excel API you need, without the Office Interop hassle.

The power you need to scrape & output clean, structured data.

The complete .NET Suite for your office.

  • IRONSUITE
  • |
  • IRONPDF
  • IRONOCR
  • IRONBARCODE
  • IRONXL
  • IRONWEBSCRAPER
IronSoftware
205 N. Michigan Ave. Chicago, IL 60611 USA +1 (312) 500-3060
  • About Us
  • News
  • Careers
  • Contact Us
  • Join Iron Slack

Supporting Teamseas

Copyright © Iron Software LLC 2013-2023

  • Terms
  • Privacy

Thank you!

Your license key has been delivered to the email provided. Contact us

24-Hour Upgrade Offer:

Save 50% on a
Professional Upgrade

Go Professional to cover 10 developers
and unlimited projects.

hours

:

minutes

:

seconds

Upgrade to Professional

Upgrade

Professional

$600 USD

$299 USD


  • 10 developers
  • 10 locations
  • 10 projects
TODAY ONLY
Iron Suite

5 .NET Products for the Price of 2

IronPDF IronOCR IronXL IronBarcode IronWebscraper

Total Suite Value:

$7,192 USD

Upgrade price

TODAY
ONLY

$499 USD

After 24 Hrs

$1,098 USD