There are two different aspects of the compression. Just because you tell iTextSharp to use compression when saving the PDF, it doesn't mean it will reduce it very much if at all.
Until PDF 1.5+ Compression wasn't really all that great. The difference is how the objects table is laid out and you can clean it up, that will only do so much though. The rest is actual image compression inside the PDF. In this aspect iTextSharp
will
not make any noticable compression, and you will need to actually use iTextSharp to manually access each and every image stored as XObjects and extract
them, recompress them, then overwrite the current XObject with the compressed image.
A lot of people are against trying to do this yourself because any mishap and you corrupt the entire PDF file. With that said there are some 3rd party tools out there that will do it for you, but I don't know of any free ones.
In the past I've used Docotic.Pdf enterprise library, and it worked great. It has a the ability to optimize it for you and get great compression ratios.
The 3rd party tools will upgrade the PDF and its schema to 1.5. Just do some searches for iTextSharp and image compression there should be several internal solutions out there.
You can use http://hocrtopdf.codeplex.com/ to compress the images in your PDF files to JBIG2. It's a .NET library you can use in your programs to ocr and compress existing PDF files or create new ones from scanned
images. It uses open source programs (including iTextSharp) to perform the tasks you need.
super123
Member
82 Points
181 Posts
Optimize(compress)PDF using C# and iTextSharp
Sep 17, 2012 05:31 PM|LINK
hey everyone,
I have pdfs, and it is too big, I would like to optimize(compress) them using iTextSharp.
anybody have any idea or samples?
Thanks,
Terence
N_EvilScott
Star
8325 Points
1494 Posts
Re: Optimize(compress)PDF using C# and iTextSharp
Sep 17, 2012 05:44 PM|LINK
There are two different aspects of the compression. Just because you tell iTextSharp to use compression when saving the PDF, it doesn't mean it will reduce it very much if at all.
Until PDF 1.5+ Compression wasn't really all that great. The difference is how the objects table is laid out and you can clean it up, that will only do so much though. The rest is actual image compression inside the PDF. In this aspect iTextSharp will not make any noticable compression, and you will need to actually use iTextSharp to manually access each and every image stored as XObjects and extract them, recompress them, then overwrite the current XObject with the compressed image.
A lot of people are against trying to do this yourself because any mishap and you corrupt the entire PDF file. With that said there are some 3rd party tools out there that will do it for you, but I don't know of any free ones.
In the past I've used Docotic.Pdf enterprise library, and it worked great. It has a the ability to optimize it for you and get great compression ratios.
http://bitmiracle.com/pdf-library/
super123
Member
82 Points
181 Posts
Re: Optimize(compress)PDF using C# and iTextSharp
Sep 17, 2012 07:00 PM|LINK
you means that if my PDF files' version is under 1.5, there is not way to compress the inside images, which in result to reduce the file size.
only if we use the Third party Library, but my company is cheap,so I have to find another way.
If anybody have any suggestions or ideas, please let me know.
Thanks,T
N_EvilScott
Star
8325 Points
1494 Posts
Re: Optimize(compress)PDF using C# and iTextSharp
Sep 17, 2012 07:01 PM|LINK
The 3rd party tools will upgrade the PDF and its schema to 1.5. Just do some searches for iTextSharp and image compression there should be several internal solutions out there.
cparker77
Member
2 Points
1 Post
Re: Optimize(compress)PDF using C# and iTextSharp
Nov 12, 2012 04:48 AM|LINK
You can use http://hocrtopdf.codeplex.com/ to compress the images in your PDF files to JBIG2. It's a .NET library you can use in your programs to ocr and compress existing PDF files or create new ones from scanned images. It uses open source programs (including iTextSharp) to perform the tasks you need.