开发者

Itextsharp: PDF size too large when including images

开发者 https://www.devze.com 2023-01-07 03:51 出处:网络
I have a size problem with some PDFs that I build with Itextsharp and C#. Indeed each page is only an image, wide as the page, that I create thru GetInstance from a bitmap, and then Set on the page af

I have a size problem with some PDFs that I build with Itextsharp and C#. Indeed each page is only an image, wide as the page, that I create thru GetInstance from a bitmap, and then Set on the page after scaling. It seems I cannot control the format of the image 开发者_如何学Gointo the PDF, that is, the object int othe resulting PDF structure doesn't show the compression type in the header. does anybody know if I can change that format, can i choose in some way the image object compression into the PDF (Tiff/jpg could be enough).... Thanks Sav


PDF (and iText) support several different image compression formats "natively"

  • JPEG
  • JPEG2000
  • LZW/Flate(zip)
  • CCITT (group 3 and 4)
  • JBIG2

Given an image in one of these formats, it will be included "as is" into the PDF. Images in other formats (png, most tiffs, etc) must be decompressed and are then recompressed as Flate (zip) streams.

So if you want the best results, use an image compression format that can be stored directly into PDF rather than Something Else that must be converted.

0

精彩评论

暂无评论...
验证码 换一张
取 消