logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Tuesday, February 12, 2019 4:12:35 PM(UTC)
 
You can try encode such images yourself and write raw bytes into the image object stream.

Also you may try to create PdfBitmap with appropriate pixel format.
carrot Posted: Wednesday, January 23, 2019 11:12:44 AM(UTC)
 
Thanks, loading jpeg works.

It decodes Jpeg image by DCTDecode. Jpeg has sense only for images in color.
8bpp (grayscale) and 1bpp (black white) can't be used in jpeg.
Is there any other way to optimize the size of PDF?
Paul Rayman Posted: Monday, January 21, 2019 2:40:13 AM(UTC)
 
PdfBitmap is by definition an uncompressed image.
Compression mode should be applied to the PdfImageObject, that is placed in the content stream on a page.

When the PdfBitmap inserted into PdfImageObject the FlateDecode is used to compress this image. This is by default behavior.

You may try PdfImageObject.LoadJpegFile(). In this case JPXDecode will be applied.

Also you may try to create monochrome bitmap instead of argb format.
carrot Posted: Monday, January 21, 2019 1:27:20 AM(UTC)
 
Hello,

how can I specify filter for image: DCTDecode, JBIG2Decode, JPXDecode, FlateDecode...
I need to optimize size of pdf which contains only one image per page and trying to use jpeg format, but I do not know how.
I'm using following code to create PdfBitmap:

Code:
PdfBitmap result = null;

BitmapFormats pdfFormat;
int[] palette;
GetPdfFormat(bitmap, out pdfFormat, out palette);

var lockInfo = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
result = new PdfBitmap(bitmap.Width, bitmap.Height, pdfFormat, lockInfo.Scan0, lockInfo.Stride);
bitmap.UnlockBits(lockInfo);

if (palette != null)
{
	result.Palette = palette;
}


Thank you.