Adobe Photoshop

The following script converts the same image document (TIFF) into a PDF file using JPEG2000 lossless compression:

// =======================================================
var idOpn = charIDToTypeID( "Opn " );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc1.putPath( idnull, new File( "D:\\adieux\\archive\\tiff\\adieux-ocr-testfile-1.tif" ) );
executeAction( idOpn, desc1, DialogModes.NO );

// =======================================================
var idsave = charIDToTypeID( "save" );
var desc2 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc3 = new ActionDescriptor();
var idpdfPresetFilename = stringIDToTypeID( "pdfPresetFilename" );
desc3.putString( idpdfPresetFilename, "High Quality Print" );
var idpdfCompatibilityLevel = stringIDToTypeID( "pdfCompatibilityLevel" );
var idpdfCompatibilityLevel = stringIDToTypeID( "pdfCompatibilityLevel" );
var idpdfoneseven = stringIDToTypeID( "pdf17" );
desc3.putEnumerated( idpdfCompatibilityLevel, idpdfCompatibilityLevel, idpdfoneseven );
var idpdfEmbedThumbnails = stringIDToTypeID( "pdfEmbedThumbnails" );
desc3.putBoolean( idpdfEmbedThumbnails, true );
var idpdfViewAfterSave = stringIDToTypeID( "pdfViewAfterSave" );
desc3.putBoolean( idpdfViewAfterSave, true );
var idpdfCompressionType = stringIDToTypeID( "pdfCompressionType" );
desc3.putInteger( idpdfCompressionType, 19 );
var idPhtP = charIDToTypeID( "PhtP" );
desc2.putObject( idAs, idPhtP, desc3 );
var idIn = charIDToTypeID( "In " );
desc2.putPath( idIn, new File( "D:\\adieux\\archive\\pdf" ) );
executeAction( idsave, desc2, DialogModes.NO );

// =======================================================
var idCls = charIDToTypeID( "Cls " );
executeAction( idCls, undefined, DialogModes.NO );

While the resulting PDF file is clearly of better quality than one using standard JPEG compression (compare former with latter at 200%), the file size (13.2MB) is larger by a factor of 31.6, and is even larger than the original uncompressed TIFF.

Continued Continued