Controlling Compression on image added to PDF

Discussions about PDF management.
Post Reply
blewis
Posts: 38
Joined: Wed May 18, 2011 4:28 am

Controlling Compression on image added to PDF

Post by blewis » Mon Oct 24, 2011 7:58 pm

I have a PDF file that I am using as a template. Then I am using gdPicture to lay down additional information onto the file and then save out a new PDF.

One of the items I am putting down on the page is an image that is a qrCode (2d barcode). Using a separate library a small crCode image that is then rendered into a Drawing.Bitmap object. I am then using the CreateGdPictureImageFromBitmap function to create a GdPicture of that bitmap and then AddImageFromGdPictureImage and DrawImage to place it in the PDF. It works, but the saved PDF is showing artifacting on the qrCode image. The qrCode should of course be straight black and white -- and if I directly save the qrCode image to the file system as a PNG, it looks perfect. However, inside the PDF it shows grey blocks throughout the qrCode.

I looked at changing the SetCompressionForBitonalImage property (to PdfCompressionNone) and also setting the EnableCompression option to False. Neither helped. Because this PDF is going to be printed, then eventually re-scanned and read using the qrCode reader in gdPicture, I want to start with the best possible quality and avoid these artifacts. I am new to using the PDF plugin, so any pointers would be appreciated.

Thanks,
Bryan

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Controlling Compression on image added to PDF

Post by SamiKharma » Tue Oct 25, 2011 11:42 am

Hello,

From reading your post, I can assume the image is 24 bit and 1 bit even if it black and white, and since the library uses JPEG compression, there will be some artifacts, so there are three ways around it:
1. - Convert the image to 1bpp before adding it to the PDF, or
2. Use another compression scheme for colour image via SetCompressionForColorImage instead of SetCompressionForBitonalImage, or
3. Keep jpeg compression but set the JPEG quality to 100 using the SetJpegQuality method

I hope this works, keep us posted,
Best Regards,
Sami Kharma
GdPicture Support Team Member

blewis
Posts: 38
Joined: Wed May 18, 2011 4:28 am

Re: Controlling Compression on image added to PDF

Post by blewis » Tue Oct 25, 2011 4:40 pm

Thanks. Using ConvertTo1Bpp before adding the image to the PDF took care of the issue.

Bryan

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest