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.
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 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.
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.
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.