本文整理汇总了Java中com.itextpdf.text.pdf.PRStream类的典型用法代码示例。如果您正苦于以下问题:Java PRStream类的具体用法?Java PRStream怎么用?Java PRStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PRStream类属于com.itextpdf.text.pdf包,在下文中一共展示了PRStream类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FindImages
import com.itextpdf.text.pdf.PRStream; //导入依赖的package包/类
/**
* @see #testExtractImageLikeSteveB()
*/
private static List<BufferedImage> FindImages(PdfReader reader, PdfDictionary pdfPage) throws IOException
{
List<BufferedImage> result = new ArrayList<>();
Iterable<PdfObject> imgPdfObject = FindImageInPDFDictionary(pdfPage);
for (PdfObject image : imgPdfObject)
{
int xrefIndex = ((PRIndirectReference)image).getNumber();
PdfObject stream = reader.getPdfObject(xrefIndex);
// Exception occurs here :
PdfImageObject pdfImage = new PdfImageObject((PRStream)stream);
BufferedImage img = pdfImage.getBufferedImage();
// Do something with the image
result.add(img);
}
return result;
}
示例2: unpack
import com.itextpdf.text.pdf.PRStream; //导入依赖的package包/类
private void unpack(Set<PdfDictionary> dictionaries) throws TaskIOException {
for (PdfDictionary dictionary : dictionaries) {
PdfName type = dictionary.getAsName(PdfName.TYPE);
if (PdfName.F.equals(type) || PdfName.FILESPEC.equals(type)) {
PdfDictionary ef = dictionary.getAsDict(PdfName.EF);
PdfString fn = dictionary.getAsString(PdfName.F);
if (fn != null && ef != null) {
PRStream prs = (PRStream) PdfReader.getPdfObject(ef.get(PdfName.F));
if (prs != null) {
File tmpFile = copyToTemporaryFile(prs);
outputWriter.addOutput(file(tmpFile).name(fn.toUnicodeString()));
}
}
}
}
}
示例3: copyToTemporaryFile
import com.itextpdf.text.pdf.PRStream; //导入依赖的package包/类
private File copyToTemporaryFile(PRStream prs) throws TaskIOException {
File tmpFile = createTemporaryBuffer();
LOG.debug("Created output temporary buffer {}", tmpFile);
ByteArrayInputStream inputStream = null;
try {
inputStream = new ByteArrayInputStream(PdfReader.getStreamBytes(prs));
FileUtils.copyInputStreamToFile(inputStream, tmpFile);
LOG.debug("Attachment unpacked to temporary buffer");
} catch (IOException e) {
throw new TaskIOException("Unable to copy attachment to temporary file.", e);
} finally {
IOUtils.closeQuietly(inputStream);
}
return tmpFile;
}