本文整理匯總了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;
}