I am wondering if Aspose can convert multiple PNG files into a single TIFF file. If it can, please provide me with some samples.
Hi DJ,
ConvertMultipleImagesToTiff(List<Image> images)
doc = new Document();
builder = new DocumentBuilder(doc);
all the images
PNG per page, positioned at top left corner of document
extra page break at the end of document
< images.Count - 1)
Aspose.Words document to TIFF format
}
Hi DJ,
Thanks for your inquiry.
You may find that different-sized images will have white bands around them or are cut off at the edges of the pages. Here are the changes to avoid this:
/// Converts a List of Image objects to Multi-Page TIFF format
/// <summary></summary>
/// <param name="images">System.Drawing.Image List of PNG images</param>
public static void ConvertMultipleImagesToTiff(List<Image> images)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Loop through all the images
for (int i = 0; i < images.Count; i++)
{
PageSetup ps = builder.PageSetup;
ps.PageWidth = ConvertUtil.PixelToPoint(images[i].Width,
images[i].HorizontalResolution);
ps.PageHeight = ConvertUtil.PixelToPoint(images[i].Height,
images[i].VerticalResolution);
// Insert one PNG per page, positioned at top left corner of document
builder.InsertImage(images[i],
RelativeHorizontalPosition.Page, 0,
RelativeVerticalPosition.Page, 0,
ps.PageWidth, ps.PageHeight,
WrapType.None);
// To prevent extra page break at the end of document
if (i < images.Count - 1)
{
builder.InsertBreak(BreakType.SectionBreakNewPage);
}
}
// Save Aspose.Words document to TIFF format
doc.Save(@"C:\test\PNGs\test.tiff");
If we can help with anything else, please feel free to ask.
Thanks.
Hello Agustine,