Hello,
Hello Dung,
Thanks for contacting support.
dunghnguyen:
For example, I extract the images from the attachment and save them as Jpeg files. Then, I replace the images inside the PDF file by Jpeg one. I end up with a PDF file with larger size. I also tried to use image quality parameter when replacing the images but it does not help.
We will really appreciate if you please share a code snippet which you are trying to perform above mentioned functionality and explain “Jpeg one” a little more. It would help us to replicate the scenario in our environment and address it accordingly.
dunghnguyen:
In case of grayscale images, Aspose saves them as color images inside PDF files. This causes the PDF files increased in size.
In order to reduce/optimize the PDF document you need to use Optimize() method, provided by Aspose.Pdf for .NET. Please check following code snippet that I have used to optimize your PDF file and the size has been reduced from 3.6M to 3.0M. I have also attached an output for your reference.
Document pdf = new Document(dataDir + “CleanCode.pdf”);
pdf.OptimizeResources(new Document.OptimizationOptions()
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
CompressImages = true,
ImageQuality = 10
});
pdf.Save(dataDir + "CleanCode_optimized.pdf");
dunghnguyen:
I would like to ask if there is any way to add/replace images in grayscale form?
You may check following articles in API documentation regarding images (colored and grayscale) and optimizing PDF document. May be you can identify color/grayscale images inside PDF and then replace them.
- Convert a PDF from RGB colorspace to Grayscale
- Identify if image inside PDF is colored or Black and White
- Replace image inside PDF
Best Regards,
Hello,
Hi Dung,
dunghnguyen:we would like to embed gray scale images to PDF in gray scale format so that the size is reduced.
Hello,
Hi Dung,
Hello,
Do you have any update?
I am looking forward to seeing your response.
Thanks.
Thanks for posting your inquiry.
I am afraid that earlier logged issue has not been resolved yet. Though we have intimated the relevant team about your concerns and as soon as we have some feedback from their side, we will update you. We greatly appreciate you patience and cooperation in this regard. Please spare us little time.
We are sorry for this inconvenience.
Best Regards,
Asad Ali