package com.pdflib.cookbook.tet.image; import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.text.NumberFormat; import com.pdflib.TET; import com.pdflib.TETException; /** * For each image, fetch the width and height in pixels from images[] and the * width and height in point from the TET_image_info structure. Determine the * image resolution in dpi. As the meaning of the dpi information changes * if the image is rotated or skewed, a warning is printed in these cases. *
* Required software: TET 3 *
* Required data: PDF document
*
* @version $Id: determine_image_resolution.java,v 1.4 2014/05/26 13:02:11 rjs Exp $
*/
public class determine_image_resolution
{
/**
* Global option list
*/
static final String GLOBAL_OPTLIST = "searchpath={../resource/cmap "
+ "../resource/glyphlist ../input}";
/**
* Document-specific option list
*/
static final String DOC_OPTLIST = "";
/**
* Page-specific option list
*/
static final String PAGE_OPTLIST = "granularity=page";
/**
* Basic image extract options (more below)
*/
static final String BASE_IMAGE_OPTLIST = "compression=auto format=auto";
/**
* The encoding in which the output is sent to System.out. For running the
* example in a Windows command window, you can set this for example to
* "windows-1252" for getting Latin-1 output.
*/
private static final String OUTPUT_ENCODING = System
.getProperty("file.encoding");
/**
* For printing to System.out in the encoding specified via OUTPUT_ENCODING.
*/
private static PrintStream out;
public static void main(String argv[]) throws UnsupportedEncodingException {
System.out.println("Using output encoding \"" + OUTPUT_ENCODING + "\"");
out = new PrintStream(System.out, true, OUTPUT_ENCODING);
TET tet = null;
try {
if (argv.length != 1) {
throw new Exception(
"usage: determine_image_resolution