Re: Compress PDF

Thanks for the reply
Actually Iam using Aspose.Word to convert to PDF

Aspose.Words.Document doc1 = new Aspose.Words.Document(FileUpload1.PostedFile.InputStream);
doc1.SaveToPdf(Server.MapPath("~") + @"\Temp\p1.pdf");

Here how can I compress the resultant PDF(p1.pdf)

Thanks
Siraj

Hello Siraj,
You’re using the Direct-to-Pdf save method of Aspose.Words to convert the word document into PDF format. I’m not sure if Aspose.Words supports the feature of compression or not. I believe the respective team would be in better position to answer this query, so for your convenience, I’m moving this query to Aspose.Words forum.
Beside that, if you were using the conventional method of Word-to-PDf conversion, using Aspose.Pdf and Aspose.Words, then you would have specified the CompressionLevel value in the code. Please take a look over the following code snippet.
[C#]

Document doc = new Document(@"D:/pdftest/09-0207.doc");
doc.Save(@"d:/pdftest/New.xml", SaveFormat.AsposePdf);
Pdf pdf = new Pdf();
pdf.BindXML("d:/pdftest/New.xml", null);
pdf.CompressionLevel = 9;
pdf.Save(@"D:/pdftest/09-0207_new.pdf");

Hi,
I am using the latest ASPOSE.WORD DLL and I don’t wan to use the above method of converting word to pdf.
Iam using the following code. Please suggest here how can apply compression?
I wan to reduce the size of PDF.

Aspose.Words.Document doc1 = new Aspose.Words.Document(FileUpload1.PostedFile.InputStream);
doc1.SaveToPdf(Server.MapPath("~") + @"\Temp\p1.pdf");

I want to know is there is any way to compress the p1.pdf file?
Thanks
Siraj

Hi

Thanks for your inquiry. Please try to set TextCompression and JpegQuality. But you should note if you change JpegQuality you can reduce the quality of images in the document. See the following code:

// Open source document.
Document doc = new Document(@"Test075\in.doc");
// Set PdfOptions
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.TextCompression = PdfTextCompression.Flate;
pdfOptions.JpegQuality = 60;
doc.SaveToPdf(0, doc.PageCount, @"Test075\out.pdf", pdfOptions);

Hope this helps.
Best regards,

Thanks for the reply,
Above solution may not be acceptable…can’t compromise with the quality
Any way…I have an idea, pleas suggest wheather it is worthfull or not
Is it possible to open existing PDF into Aspose.PDF and utlize it’s compression feature

Please suggest
Thanks
Siraj

Hi

Thanks for your inquiry. I think, there is no difference, which method of compression you use. Size of PDF documents can be reduced only by doing the following:

  1. Decreasing size of images inside PDF (this can be done only be decreasing quality).
  2. Subseting fonts, which are embedded into the PDF documents. (Aspose.Words does this by default).
  3. Compression of text (Usually decreasing of size is not very big)

Could you please attach your Word documents, which you need convert to PDF?
Best regards,

Thanks,
Please find the sample Word, which I will conert to PDF using ASPOSE.WORD and I want to acheive good compression.
Please suggest
Siraj

Hi

Thank you for additional information. After converting this document to PDF using Aspose.Words, the output document size is a little bit less then size of the original DOC file. If I use the legacy method to convert this document, the output document size is around 10MB. Aspose.Pdf CompressionLevel, suggested by Nayyer, does not work with this document at all.
What is the acceptable size of the output document for you?
Best regards,

Thanks for the reply,
If I am comprising the output PDF using some third party PDF Compressor, then I am getting the siginficant reduction in file size.
Another issues is, I won’t find following property for pdfOptions Object.

pdfOptions.JpegQuality = 60;

I am able see TextCompression Propety but not the JpegQuality Property

// Set PdfOptions
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.TextCompression = PdfTextCompression.Flate;
pdfOptions.JpegQuality = 60;
Compression should not distort much of the image quality[Some distortion will be acceptable, but should not be visiable to user]

Please suggest,
Thanks
Siraj

Hi

Thank you for additional information. It seems you are using old version of Aspose.Words. JpegQuality option is available starting from 6.6.0. The latest version of Aspose.Words (7.0.0), you can download from here:
https://releases.aspose.com/words/net
Best regards,

Thanks for the reply,
Again Issues
I won’t find any properties called “JpegQuality” in

Aspose.Words.Rendering.PdfOptions pdfOpt = new Aspose.Words.Rendering.PdfOptions();
pdfOpt.TextCompression = Aspose.Words.Rendering.PdfTextCompression.Flate;
pdfOpt.JpegQuality = 60

Is still not availiable to me, even though I have downloaded the Aspose.Word 6.6.0
My Licence does support update till August 2009.
Please suggest, how should I proceed from here.

I noticed one more Class called “Aspose.Words.Rendering.ImageOptions”

It’s giving me “JpegQuality” Property
But I don’t know how can I use this to achieve compression.
Please Suggest
Thanks
Siraj

Hi

Sorry for my mistake. This option is available starting from Aspose.Words 7.0.0 version.
If you would like to update to the latest version of Aspose.Words, but your license does not allow you to update to this version, you should contact Aspose sales team (Aspose.Purchase forum) to renew your license.
Best regards,

Hi,
I have following concern

  1. How much compression will it give me(A rich document with many images, to what extent it can compress, so that it will be acceptable)
  2. It will compress only JPEG Image, what if document has other images like (GIF/PNG …)

Thanks
Siraj

Hi
Thanks for your inquiry.

  1. You can easily try converting your document with different value of JpegQuality and compare the result. You can choose what quality of images and what size of the document is acceptable for you.
  2. You are right, only jpg. But you can try converting all images in the document to jpg and then convert to PDF.

Best regards,