Changing CompressionMode on PDF

Discussions about PDF management.
Post Reply
masteriou
Posts: 8
Joined: Sat Mar 20, 2010 4:44 pm

Changing CompressionMode on PDF

Post by masteriou » Wed Feb 20, 2013 11:00 pm

Hi!
The following problem bothers me: One of my customers has troubles printing PDF-files, he is getting the message "Unsupported Jbig2 Image". As the customer is always right, I tried to give him the ability to change the compression for bitonal PDF-files (for instance to CCITT4) but was unsuccessful in doing so.
Depending on the settings of my application I convert a TIF-file to PDF or PDF/A, with or without OCR by using the following code (only the part without OCR):

Code: Select all

pictureStatus = oGdPictureImaging.PdfCreateFromMultipageTIFF(lngImageID, PDFName, bolPDFA, Title, Author, Subject, Keywords, Creator)
How do I change the compression of the PDF-File? I already tried this:

Code: Select all

Dim oPDF As New GdPicture_NET_9.gdpicturepdf
oFSO.CopyFile PDFName, PDFName & "_orig.pdf", True
pictureStatus = oPDF.LoadFromFile(PDFName & "_orig.pdf", False)
oPDF.SetCompressionForBitonalImage PdfCompression_PdfCompressionCCITT4
oPDF.EnableCompression True
pictureStatus = oPDF.SaveToFile_2(PDFName, True)
When I check the compression of the resulting PDF-file with Acrobat Preflight I see that the image in the PDF-file still has JBIG2-compression.

Do I have to change the compression when I convert the TIF to PDF on a page by page basis instead of using the functions PdfCreateFromMultipageTIFF or SaveAsPDF?

Thanks in advance
Michael

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Changing CompressionMode on PDF

Post by Loïc » Thu Feb 21, 2013 7:56 pm

Hello Michael,

OK, to make it fast: Any current version of the toolkit allows to modify the compression scheme to apply by using an overload of the PdfCreateFromMultipageTIFF() method.

So we will add a new one, for the next release that will be published next week, to be able to specify compression scheme to use for bitonal image and scheme to use to compress color image.

Hope this helps!

Let me know if you need more information.

Best regards,

Loïc

masteriou
Posts: 8
Joined: Sat Mar 20, 2010 4:44 pm

Re: Changing CompressionMode on PDF

Post by masteriou » Thu Feb 21, 2013 9:25 pm

Hello Loïc!

That are absolutely terrific news! Thank you very much!

Best regards,

Michael

masteriou
Posts: 8
Joined: Sat Mar 20, 2010 4:44 pm

Re: Changing CompressionMode on PDF

Post by masteriou » Sun Mar 17, 2013 1:33 pm

Hi Loïc!

Yesterday I downloaded 9.4.2.0 and immediately tried the new overloaded function PdfCreateFromMultipageTIFF. It works but there are still some questions left:

1) What compression-algorithms are valid for bitonal compression? I think JPEG and JPEG2000 are only used for color images, so this leaves the following modes:
PdfCompressionNone
PdfCompressionFlate
PdfCompressionCCITT4
PdfCompressionJBIG2

Am I right about this? I could not find anything in the documentation or in an example.

2) I tried to create a PDF/A-file from a bitonal TIFF-file using PdfCompressionCCITT4. When I check the resulting PDF/A-file with Adobes Preflight, it tells me the compression of the image to be "ZIP/Flate-Compression (FlateDecode)" instead of CCITT (same result without pdf/a)

3) When trying to apply CCITT compression to PDF with OCR I also end up with "ZIP/Flate-Compression (FlateDecode)" using the following code

Code: Select all

lngPDFId = oGdPictureImaging.PdfOCRStart(PDFName, bolPDFA, Title, Author, Subject, Keywords, Creator)
lngPageCount = oGdPictureImaging.TiffGetPageCount(lngImageID)
For i = 1 To lngPageCount
    oGdPictureImaging.TiffSelectPage lngImageID, i
    oGdPictureImaging.PdfSetCompressionForBitonalImage lngPDFId, intCompressionMethodPDFBW
    oGdPictureImaging.PdfSetCompressionForColorImage lngPDFId, intCompressionMethodPDFColor
    oGdPictureImaging.PdfAddGdPictureImageToPdfOCR lngPDFId, lngImageID, strOCRLanguage, OCRDictionary, ""
Next i
pictureStatus = oGdPictureImaging.PdfOCRStop(lngPDFId)
Is there something wrong with my code, is this a bug or is there something I misunderstand completely?

Best Regards,

Michael

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest