@vcksekhar
We tested the scenario in our environment using following code snippet and were able to observe that PDF output size was larger than the input and after optimizing it, it was not much reduced:
FileStream mystream = new FileStream(dataDir + "WK47002O.001.png", FileMode.Open);
Bitmap b = new Bitmap(mystream);
Document doc = new Document();
Page page = doc.Pages.Add();
// Set margins so image will fit, etc.
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;
page.PageInfo.Height = b.Height;
page.PageInfo.Width = b.Width;
// Create an image object
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
page.Paragraphs.Add(image1);
image1.ImageStream = mystream;
doc.Save(dataDir + "png2PDF.pdf");
mystream.Close();
doc = new Document(dataDir + "png2PDF.pdf");
//var optimizationOptions = new Document.OptimizationOptions();
var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
optimizationOptions.ImageCompressionOptions.CompressImages = true;
optimizationOptions.ImageCompressionOptions.ImageQuality = 50;
optimizationOptions.ImageCompressionOptions.MaxResolution = 100;
optimizationOptions.ImageCompressionOptions.ResizeImages = true;
doc.OptimizeResources(optimizationOptions);
doc.Save(dataDir + @"ExampleOptimized_20.7.pdf");
We have logged an issue as PDFNET-48548 in our issue tracking system for this case. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.
We are sorry for the inconvenience.