Merge Multiple Images
Sometimes it is necessary to merge multiple documents into a single file. Combining image files is particularly useful when digitizing paper documents — for example, when you have photographed or scanned individual pages and want to create a single, continuous PDF for easier viewing, sharing, or archiving.
Merge Multiple Images Before Saving to PDF
If you need to combine multiple images and save each image as a separate page in PDF, use the Merge method and the following code example:
Merger.Merge("DocumentOut.pdf", new string[] { "MultiFrameIn.tiff", "DocumentIn.png" });You can also merge multiple images using Fluent API and the Create method:
Merger.Create()
.From("MultiFrameIn.tiff")
.From("DocumentIn.png")
.To("DocumentOut.pdf")
.Execute();Merge Multiple Images Into One
You can also merge multiple images into one by arranging them:
- vertically
- horizontally
- or in a grid
Сustomize the layout to render multiple pages in a single output using the MultiPageLayout class.
The following code example shows how to combine multiple images into a single image, placing each image or frame in a grid layout:
ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.Png);
opt.PageLayout = MultiPageLayout.Grid(2, 10, 10);
opt.PageLayout.BorderColor = Color.Black;
opt.PageLayout.BorderWidth = 1;
Merger.Create()
.From("MultiFrameIn.tiff")
.From("DocumentIn.png")
.To("DocumentOut.png", opt)
.Execute();FAQ
Q: Can I merge images of different formats (e.g., TIFF, PNG, JPEG) together?
A: Yes. TheMergerAPI accepts any image format that Wordize supports. You can pass a mixed list of file paths toMerger.Mergeor the Fluent API, and the library will convert each source image to the format you specify for the output.Q: How do I control the layout when merging images into a single image file?
A: UseImageSaveOptionstogether withMultiPageLayout. SetPageLayouttoGrid,Horizontal, orVerticaland adjust spacing, borders, and page size via the options before callingExecute().Q: How can I create a PDF where each image appears on its own page?
A: CallMerger.Merge(or the Fluent API) with a PDF file name as the target and do not supplyImageSaveOptions. The library automatically creates one PDF page per input image.Q: What should I do if the merged PDF is blank or missing images?
A: Verify that all source image files exist, are accessible, and are in a supported format. Also ensure the output path is writable and that no other process is locking the target file.Q: Is there a limit to the number of images I can merge in a single operation?
A: There is no hard‑coded limit, but merging a very large number of high‑resolution images can consume significant memory. If you encounterOutOfMemoryexceptions, consider merging the images in smaller batches or increasing the process’s memory allocation.