is it possible to set the dpi for pdf file or set the dpi for the image in the pdf file? If it’s yes, then is there any way to locate the image in each page of the pdf file, so that I can fetch that page’s image to process dpi and do compress without quality loss, and finllay I can get the small size of the pdf file
Hi,
Is there any way I can use to calculate each of pdf required size for the final output merged pdf.
Thanks imran.rafique,
For 3 small files, what’s the size for each of them can meet the final output PDF’s size less than 3M? Is there any approach can accomplish it?
Thanks, for example, if I have 3 files, 1M,1.5M 1M, if I can generate final output pdf file with less 3M? any approach I can do to accomplish it? such as the following optimization method.
pdfDocument.OptimizeResources(new Document.OptimizationOptions()
10 {
11 LinkDuplcateStreams = true,
12 RemoveUnusedObjects = true,
13 RemoveUnusedStreams = true,
14 CompressImages = true,
15 ImageQuality = 10
16 });
if couldn’t optimize it to be less than 3M, that means I have to make sure the total size for all 3 little file has to be less than 3M.
Hi,
Thanks for writing back.
As per my understanding, you want to check the file size of the PDF before saving it to some physical location. If so, then you can achieve this requirement by saving document into memory stream and check the size of that stream. Please check following code snippet to check the file size before saving it physically.
Document doc = new Document();
// do your stuff
MemoryStream ms = new MemoryStream();
doc.Save(ms);
long filesize = ms.Length;
// Put a check on size in MBs
if ((filesize / (1024 * 1024)) < 3) // Check if less than 3MB
{
// do your stuff
}
In case you have different requirements than my assumption, please share some more details so that we can test the scenario in our environment and respond you accordingly.
Best Regards,
thanks for the code snippet. sorry for not describe it clearly. let me explain it in brief.
Hi,
Thank you for the inquiry. We have tested three files with the same size as you narrated and Aspose.Pdf for .NET API generates the final PDF with 2.7MB in size. We have optimized input PDFs by using the following code example: Optimize PDF File Size. However, the file size also depends on the elements of input PDFs like which type of graphics you have used.
You can test every aspect of the Aspose.Pdf API before buying it. You can get a 30 day temporary license for the testing purposes from the purchase portal. Its option is available in step 4. Please also refer to these helping links: Apply License to Aspose.Pdf for .NET API and Download Aspose.Pdf for .NET API