Creating a PDF from MultiPage TIFF images or any other image format

Hi,

With Aspose.Total 17.2 I used the Aspose.Pdf.Generator.Pdf to create a PDF from TIFF files. In the latest version the Aspose.Pdf.Generator.Pdf is removed. How can I produce the same result with the new Aspose.Pdf?

See the code below. I use GetAllPages to return a list of all pages/images from the TIFF file as System.Drawing.Image.

Aspose.Pdf.Generator.Pdf doc = new Aspose.Pdf.Generator.Pdf();

List<System.Drawing.Image> imagePages = GetAllPages(inputFileName);
foreach (System.Drawing.Image imagePage in imagePages)
{
    Aspose.Pdf.Generator.Section section = doc.Sections.Add();
    Aspose.Pdf.Generator.Image image = new Aspose.Pdf.Generator.Image(section);

    section.PageInfo.Margin.Bottom = 0;
    section.PageInfo.Margin.Top = 0;
    section.PageInfo.Margin.Left = 0;
    section.PageInfo.Margin.Right = 0;

    image.ImageInfo.SystemImage = imagePage;
    image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

    section.PageInfo.PageWidth = (imagePage.Width / imagePage.HorizontalResolution) * 72;
    section.PageInfo.PageHeight = (imagePage.Height / imagePage.VerticalResolution) * 72;

    section.Paragraphs.Add(image);
}

string outputFileName = Path.Combine(outputPath, Path.ChangeExtension(Path.GetFileName(inputFileName), ".pdf"));

doc.Save(outputFileName);

@andreas4e47b,

Thanks for contacting support.

Please try using the new Document Object Model of Aspose.Pdf namespace. Please follow the instructions specified over How to convert an Image to PDF file.

In case you encounter any issue or you have any further query, please feel free to contact.

PS, in new DOM approach, you do not need to specify the input image file type as it will be automatically detected by API.