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

Free Support Forum - aspose.com

Image conversion from PNG to PDF has very large output fileSize

We have recently purchased ASPOSE TOTAL license and have used it for our image conversion. We kind of have a problem with output pdf filesize after conversion
We have business case where output file size should be either equal to input size or less than it. We are trying to achieve this based online samples what you have shared in web-site

We have tuned this via code and it works ok for few files but for most of files we have twice the filesize of input png.
Worst case was a png file when converted to PDF had 4 times the size of the png file.

Can you please help us with your valuable suggestions as to we can compress the output pdf file.
Our goal is to have output pdf with filesize either equal or less than input png file.
Your immediate assistance is greatly appreciated.

@vcksekhar

You can please try to optimize generated PDF document using the API. In case issue still persists, please share your sample PDF document along with sample images. We will test the scenario in our environment and address it accordingly.

Hi asad

I tried this option and it did not meet our requirement. Please see attached png file.
The file size is 24 kb and output pdf ASPOSE generated after conversion and after optimizations is 141 after applying all your optimizations as suggested in link you sent.
Can you please use this sample . convert to pdf and let me know your results.
Our requirement is we need to have a compressed pdf which is same size of input png or lesser than it. Let me know what is best compressed file I can get from ASPOSE for this file

WK47002O.001.png (23.8 KB)

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

Thanks Asad for the your response. Please let us know if you have an ETA on this. Also since we have already purchased this , do we have kind of premium support ? If so let us so know so that we can we get our support sooner than later

@vcksekhar

We are afraid that we cannot provide any ETA at the moment as the ticket is not fully investigated yet. We will inform you as soon as we make some progress in this regard. Furthermore, we offer different support options (i.e. Normal/Free Support and Priority/Paid Support). We are obliged to provide you free support regardless of the type of your license and subscription.

In the normal support model, the issues are resolved and investigated on a first come first serve basis unlike the priority support where they have high priority and are resolved on an urgent basis. Priority support needs to be purchased separately along with the license and you can upgrade to priority support whenever you want. In case you need further information, please feel free to let us know.