當前位置: 首頁>>代碼示例>>Java>>正文


Java PRStream類代碼示例

本文整理匯總了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;
}
 
開發者ID:mkl-public,項目名稱:testarea-itext5,代碼行數:21,代碼來源:ImageExtraction.java

示例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()));
                }
            }
        }
    }
}
 
開發者ID:torakiki,項目名稱:sejda-itext5,代碼行數:17,代碼來源:PdfUnpacker.java

示例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;
}
 
開發者ID:torakiki,項目名稱:sejda-itext5,代碼行數:17,代碼來源:PdfUnpacker.java


注:本文中的com.itextpdf.text.pdf.PRStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。