本文整理汇总了Java中com.lowagie.text.pdf.codec.TiffImage类的典型用法代码示例。如果您正苦于以下问题:Java TiffImage类的具体用法?Java TiffImage怎么用?Java TiffImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TiffImage类属于com.lowagie.text.pdf.codec包,在下文中一共展示了TiffImage类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.lowagie.text.pdf.codec.TiffImage; //导入依赖的package包/类
/**
* Combines 2 tiff-files into 1 PDF (similar to tiffmesh).
*
* @param args
* [0] the file with the odd pages [1] the file with the even
* pages [2] the resulting file
*/
public void main(String... args) throws Exception {
if (args.length < 3) {
System.err.println("OddEven needs 3 Arguments.");
System.out
.println("Usage: com.lowagie.examples.objects.images.tiff.OddEven odd_file.tif even_file.tif combined_file.pdf");
return;
}
RandomAccessFileOrArray odd = new RandomAccessFileOrArray(args[0]);
RandomAccessFileOrArray even = new RandomAccessFileOrArray(args[1]);
Image img = TiffImage.getTiffImage(odd, 1);
Document document = new Document(new Rectangle(img.getScaledWidth(), img.getScaledHeight()));
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(args[2]));
document.open();
PdfContentByte cb = writer.getDirectContent();
int count = Math.max(TiffImage.getNumberOfPages(odd), TiffImage.getNumberOfPages(even));
for (int c = 0; c < count; ++c) {
Image imgOdd = TiffImage.getTiffImage(odd, c + 1);
Image imgEven = TiffImage.getTiffImage(even, count - c);
document.setPageSize(new Rectangle(imgOdd.getScaledWidth(), imgOdd.getScaledHeight()));
document.newPage();
imgOdd.setAbsolutePosition(0, 0);
cb.addImage(imgOdd);
document.setPageSize(new Rectangle(imgEven.getScaledWidth(), imgEven.getScaledHeight()));
document.newPage();
imgEven.setAbsolutePosition(0, 0);
cb.addImage(imgEven);
}
odd.close();
even.close();
document.close();
}
示例2: addTiff
import com.lowagie.text.pdf.codec.TiffImage; //导入依赖的package包/类
private void addTiff(final File file, final Document document, final PdfWriter writer)
throws Exception {
RandomAccessFileOrArray randomAccess = createRamdomAccessSource(file);
int pages = getPageCount(file);
for (int i = 1; i <= pages; i++) {
Image image = TiffImage.getTiffImage(randomAccess, i);
addImage(image, document, writer);
}
}
示例3: getPageCountTif
import com.lowagie.text.pdf.codec.TiffImage; //导入依赖的package包/类
public static int getPageCountTif(final File file) throws IOException {
RandomAccessFileOrArray randomAccess = createRamdomAccessSource(file);
return TiffImage.getNumberOfPages(randomAccess);
}