We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image resolution reduced

We are using latest version of Aspose.Word and I am trying to convert Image to PDF. Following is the code snippet. Do we alter the resolution in the conversion process? How
would it respond to a high resolution image?Suppose If the image is 600dpi (dots per
inch) before the upload, what is the DPI value after it has been converted to
PDF? Is it reduced or does it remain the same? What are the factors it depends on ? How can I set resolution?

Code snippet:

Aspose.Words.Document document = new Aspose.Words.Document();
DocumentBuilder documentBuilder = new DocumentBuilder(document);
using (System.Drawing.Image image = System.Drawing.Image.FromFile(sourceFile))
{
    int framesCount = 1; //Default

    if (sourceFileExt != ".gif")
    {
        framesCount = image.GetFrameCount(FrameDimension.Page);
    }
    for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
    {
        if (frameIdx != 0) documentBuilder.InsertBreak(BreakType.SectionBreakNewPage);

        image.SelectActiveFrame(FrameDimension.Page, frameIdx);
        Aspose.Words.PageSetup ps = documentBuilder.PageSetup;
        ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);
        ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);

        documentBuilder.InsertImage(image,
            RelativeHorizontalPosition.Page,
            0,
            RelativeVerticalPosition.Page,
            0,
            ps.PageWidth,
            ps.PageHeight,
            WrapType.None
            );
    }
}

document.Save(destinationFilePath, Aspose.Words.SaveFormat.Pdf);

Hi Viral,

Thanks for your inquiry. I have already answered, here in this thread, to a similar query of yours. If we can help you with anything else, please feel free to ask.

Best Regards,