Issues with Converting TIFF to PDF using either Aspose.Words for .NET or Aspose.PDF for .NET

I’m having an issue attempting to convert the attached image to PDF with a reasonable result.

The attached image is a 8.5" x 11" document scanned at 200 DPI

I first tried the sample code for Aspose.Words for .NET here:

Convert Images to PDF

This resulted in a PDF that was a good file size, but the image on the page was reduced in size and placed in the upper left corner of the page.

I then tried the sample code for Aspose.PDF for .NET here:

This resulted in a PDF that had the correct visual appearance when opened that I was looking for but the file size was way too large to be useful.

What I need is the best of both of those in one set of code. The PDF page to look like the second example, but have the file size of the first.

Hi Michael,

Thanks for using our API’s.

I have tested the scenario while converting TIFF image to PDF format using Aspose.PDF for .NET 10.6.0 and have managed to reproduce the same issue that resultant PDF being generated is too large (1.50 MB). For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-39180. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Has there been any further development with the Aspose.Words for .NET issue?

Hi Michael,

Thanks for your inquiry. Regarding Aspose.Words query, please use the following code:

// Create Aspose.Words.Document and DocumentBuilder.
// The builder makes it simple to add content to the document.
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Read the image from file, ensure it is disposed.
using (System.Drawing.Image image = System.Drawing.Image.FromFile(MyDir + "image.tif"))
{
    // Find which dimension the frames in this image represent. For example
    // the frames of a BMP or TIFF are "page dimension" whereas frames of a GIF image are "time dimension".
    FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);

    // Get the number of frames in the image.
    int framesCount = image.GetFrameCount(dimension);

    // Loop through all frames.
    for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
    {
        // Insert a section break before each new page, in case of a multi-frame TIFF.
        if (frameIdx != 0)
            builder.InsertBreak(BreakType.SectionBreakNewPage);

        // Select active frame.
        image.SelectActiveFrame(dimension, frameIdx);

        // Insert the image into the document and position it at the top left corner of the page.
        Shape shape = builder.InsertImage(
                                image,
                                RelativeHorizontalPosition.Page,
                                0,
                                RelativeVerticalPosition.Page,
                                0,
                                image.Width,
                                image.Height,
                                WrapType.None);


        // We want the size of the page to be the same as the size of the image.
        // Convert pixels to points to size the page to the actual image size.
        PageSetup ps = builder.PageSetup;
        ps.PageWidth = shape.Width;
        ps.PageHeight = shape.Height;
    }

    doc.Save(MyDir + @"15.7.0.pdf");

I hope, this helps.

Best regards,

I had to modify it a little, but that worked. I think the problem is that when the shape is added to the builder, it’s dimensions aren’t being calculated correctly.



If after I call builder.InsertImage, I then call PixelToPoint to get the correct image width and height, then set those to the shape and ps width and height, the resulting pdf is correct.

Hi Michael,


Thanks for the additional information. It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,

Just would like to know the status of PDFNEWNET-39180

Hi Michael,

Thanks for your patience.

As we recently have been able to notice this issue, and until or unless we have investigated and have figured out the actual reasons of this problem, we might not be able to share any timelines by which this problem will be resolved.

However, as soon as we have made some significant progress towards the resolution of this issue, we would be more than happy to update you with the status of correction. Please be patient and spare us little time.