Merge PNG Images into PDF in Python
Combine multiple PNG images and save the result as a PDF document with a cross-platform Python API
Merge PNG Images into PDF Using Aspose.Slides
Aspose.Slides for Python via .NET
lets you place multiple PNG images on one Slide and export the combined layout as a single-page PDF document. Load each source image with Images.from_file, add it to Presentation.images, create picture frames, and call Presentation.save with SaveFormat.PDF.
Merge PNG Images into a PDF Document in Python
Create a Presentation, place the source PNG images side by side on its first Slide, and export the slide as a one-page PDF document.
Python code for merging PNG images into a PDF document
with slides.Presentation() as presentation:
slide = presentation.slides[0]
with slides.Images.from_file("image1.png") as first_source_image:
first_presentation_image = presentation.images.add_image(first_source_image)
slide.shapes.add_picture_frame(
slides.ShapeType.RECTANGLE, 0, 0, 360, 270, first_presentation_image)
with slides.Images.from_file("image2.png") as second_source_image:
second_presentation_image = presentation.images.add_image(second_source_image)
slide.shapes.add_picture_frame(
slides.ShapeType.RECTANGLE, 360, 0, 360, 270, second_presentation_image)
presentation.save("merged.pdf", slides.export.SaveFormat.PDF)
How to Merge PNG Images into a PDF Document in Python
Follow these steps to combine multiple PNG images into one PDF document.
Install Aspose.Slides for Python via .NET .
Import the
aspose.slidesmodule in your Python project.Create a
Presentationand access its firstSlide.Load the source PNG images with
Images.from_file, add them toPresentation.images, and arrange them in picture frames.Call
Presentation.savewithSaveFormat.PDFto create the combined PDF document.
Merge Other Files
You can also combine files in other formats.