This message (and any attachments) is confidential and reserved to the recipients named above, and is protected by law. If you are not in the list of recipients, please inform the sender immediately and destroy it. Any disclosure, reproduction, dissemination of this message, or use for any reason whatsoever, is strictly prohibited.
We did not receive any file. Would you please make sure to upload it with your post using upload button. In case you do not want to share the file in here, you may send it in a private message. In order to send private message, please click over username and press blue Message button.
We have tested the scenario in our environment using following code snippet and Aspose.PDF for .NET 19.2. We were unable to notice any issue as file size was reduced from ~36MB to ~1.2MB. For your kind reference, output PDF is also shared in a private message.
I have test this code, but I do not reduce a lot : I have 118Kb using this code and 119Kb without.
Same result if I set ImageQuality =1.
Below my test application :
We have checked the sample project shared by you. You were optimizing the PDF document even before adding the image in it. Please try saving the document after adding image so that PDF can be generated with its content and original size. Later you can optimize it. Please consider using following code snippet:
using (Aspose.Pdf.Document docPdf = new Aspose.Pdf.Document())
using (var bitmap = new Bitmap(dataDir + @"CarteVitale.png"))
using (MemoryStream ms = new MemoryStream())
{
Page page = docPdf.Pages.Add();
var image = new Aspose.Pdf.Image();
page.Paragraphs.Add(image);
page.PageInfo.Height = bitmap.Height;
page.PageInfo.Width = bitmap.Width;
page.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
image.ImageStream = ms;
docPdf.Save(dataDir + "output20.1.pdf");
var newdocPdf = new Document(dataDir + "output20.1.pdf");
if (true)
{
var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
optimizationOptions.RemoveUnusedObjects = true;
optimizationOptions.RemoveUnusedStreams = true;
optimizationOptions.ImageCompressionOptions.CompressImages = true;
optimizationOptions.ImageCompressionOptions.ImageQuality = 1;
optimizationOptions.ImageCompressionOptions.ResizeImages = true;
newdocPdf.OptimizeResources(optimizationOptions);
}
// Save the document
newdocPdf.Save(dataDir + "output20.1.pdf");
}
It is good to know that things have started working at your side. Please keep using our API and in case you need further assistance, please feel free to let us know.
I am having am issue using some of the code examples above as the PDF I am using has a LOT of images in it. I know this PDF can be reduced because other web tools reduce it by 75% or more. I have attached an example using your tool - can you please let me know what I am doing wrong?
We tried to test the scenario using your file and code snippet with Aspose.PDF for .NET 20.8 and noticed that program kept running for more than 30 minutes and never produced an output. However, could you please confirm if you are facing similar issue at your side or a different one?
Also, would you please share which tools you used to reduce the PDF file size upto 75%? Please share those obtained optimized PDF for our reference so that we can investigate the scenario accordingly and share our feedback with you.
Attached are two PDFs for each of the two options that they have (Basic or Strong) - not sure about the difference … it takes maybe 30-45 seconds on their site. I have a regular stream of files on this file size that I would prefer to automate though - thus looking at your tool. My testing has the same issue with the 30+ mins and I eventually ended up stopping VS instead of allowing to continue running.Drawing_Compressed_Basic.pdf (4.8 MB) Drawing_Compressed_Strong.pdf (4.5 MB)
We have logged an issue as PDFNET-48721 in our issue tracking system for the sake of correction. We will further investigate this behavior of the API in details and keep you informed with the status of ticket resolution. Please be patient and give us some time.
I’m afraid, there is no progress on this issue yet. Please note the issues are managed to first come, first serve basis. As this issue was logged recently, our team will get to this soon and work on it. We’ll notify you in this thread once the issue is resolved. I apologize for the inconvenience caused by this issue.