tif转pdf
需求:做一个可视化java工具,选中某个文件,可以遍历文件中的所有tif文件,在有tif文件的文件夹同级创建一个文件夹同名的pdf文件,将文件夹内的tif都添加到pdf
import java.awt.BorderLayout;
import java.awt.DisplayMode;
import java.awt.FlowLayout;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.pdf.RandomAccessFileOrArray;
import com.itextpdf.text.pdf.codec.TiffImage;
public class TiffToPdf extends JFrame implements ActionListener {
public final static String INDEX_FILEEXT = ".tif.tiff";
private JTextField inPath;
private JTextField outPath;
private JTextField text;
private JButton selectInPath;
private JButton selectOutPath;
private JButton submit;
private JLabel lb1;
private JLabel lb2;
private JLabel lb3;
private JFileChooser chooser;
private Box baseBox, box1, box2, box3, box4, box5;
JProgressBar progressBar;
int allCount = 0;// 统计成功转换成双层pdf的个数
int successCount = 0;
//final static JavaSDK javaSDK = new JavaSDK();
public TiffToPdf(String title) {
init(title);
baseBox = Box.createVerticalBox();
box1 = Box.createHorizontalBox();
//box2 = Box.createHorizontalBox();
box3 = Box.createHorizontalBox();
box4 = Box.createHorizontalBox();
box5 = Box.createHorizontalBox();
box4 = Box.createHorizontalBox();
progressBar = new JProgressBar();
box5.add(progressBar);
progressBar.setStringPainted(true);
lb1 = new JLabel("输入源:");
//lb2 = new JLabel("输出源:");
// lb3=new JLabel("文件转换结果:");
// lb3.setVisible(false);
inPath = new JTextField(30);
inPath.setEditable(true);
//outPath = new JTextField(30);
//outPath.setEditable(false);
text = new JTextField(30);
text.setEditable(false);
text.setVisible(false);
submit = new JButton("确定");
selectInPath = new JButton("浏览");
//selectOutPath = new JButton("浏览");
box1.add(lb1