Question

I am building an MVC 4 application in C#. I have multiple tif images (not a multipage tif document) that I need to convert to a single PDF document (multi-page)

does anyone have any samples etc?

Was it helpful?

Solution

Suppose that sourcedir is the directory where .tif the images reside, then you need:

Image image;
Directory.GetFiles(sourceDir, "*.tif");
foreach (string fileName in fileEntries) {
    image = Image.GetInstance(filename);
    image.ScaleToFit(595, 842);
    image.SetAbsolutePosition(0, 0);
    document.Add(image);
    document.NewPage();
}

In this snippet, I assume that the size of your page is A4 (595, 842). I also add the image in the lower-left corner. You may want to center the image and/or resize the pages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top