当前位置: 首页>>代码示例>>Java>>正文


Java IOUtils.toByteArray方法代码示例

本文整理汇总了Java中org.apache.pdfbox.io.IOUtils.toByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java IOUtils.toByteArray方法的具体用法?Java IOUtils.toByteArray怎么用?Java IOUtils.toByteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.pdfbox.io.IOUtils的用法示例。


在下文中一共展示了IOUtils.toByteArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProcessDefinitionDiagramById

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
public static byte[] getProcessDefinitionDiagramById(String processDefinitionId) throws Exception {
	ProcessDefinition pd = repositoryService
			.createProcessDefinitionQuery()
			.processDefinitionId( processDefinitionId )
			.singleResult();
	if (pd == null) {
		return null;
	}
	byte data[] = null;
	ProcessDefinitionEntity pde = (ProcessDefinitionEntity)pd;
	InputStream is = repositoryService.getResourceAsStream(pde.getDeploymentId(), pde.getDiagramResourceName());
	data = IOUtils.toByteArray(is);
	is.close();
	is = null;
	return data;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:17,代码来源:BusinessProcessManagementUtils.java

示例2: testDummySignInMemory

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/29123436/how-to-sign-an-inputstream-from-a-pdf-file-with-pdfbox-2-0-0">
 * How to sign an InputStream from a PDF file with PDFBox 2.0.0
 * </a>
 * 
 * Test the equivalent for PDFBox 1.8.8. Works alright.
 */
@Test
public void testDummySignInMemory() throws IOException, COSVisitorException, SignatureException
{
    try (   InputStream sourceStream = getClass().getResourceAsStream("/mkl/testarea/pdfbox1/assembly/document1.pdf");
            OutputStream output = new FileOutputStream(new File(RESULT_FOLDER, "document1-with-dummy-sig.pdf")))
    {
        byte[] input = IOUtils.toByteArray(sourceStream);
        output.write(input);
        signDetached(input, output, new SignatureInterface()
                {
                    @Override
                    public byte[] sign(InputStream content) throws SignatureException, IOException
                    {
                        return "Test".getBytes();
                    }
                });
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:26,代码来源:SignInMemory.java

示例3: test

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
void test(String resourceName, File resultFile) throws IOException, COSVisitorException, CertificateEncodingException
{
    try (   InputStream source = getClass().getResourceAsStream(resourceName);
            FileOutputStream fos = new FileOutputStream(resultFile);
            FileInputStream fis = new FileInputStream(resultFile);
            )
    {
        List<byte[]> certificates = new ArrayList<byte[]>();
        for (int i = 0; i < cert.length; i++)
            certificates.add(cert[i].getEncoded());
        COSDictionary dss = createDssDictionary(certificates, null, null);

        byte inputBytes[] = IOUtils.toByteArray(source);

        PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
        PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
        catalog.getCOSObject().setNeedToBeUpdate(true);
        catalog.getCOSDictionary().setItem(COSName.getPDFName("DSS"), dss);

        fos.write(inputBytes);
        pdDocument.saveIncremental(fis, fos);
        pdDocument.close();
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:25,代码来源:AddValidationRelatedInformation.java

示例4: download

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
@Override
public byte[] download( String prefix, Long id, String format ) throws InvoiceServiceException
{
    try
    {
        InputStream in = storeService.downloadFile( blobStoreFileFactory.produce( format, prefix, id ) );

        if ( in == null ) throw new InvoiceMissingException();

        return IOUtils.toByteArray( in );
    }
    catch ( IOException e )
    {
        throw new InvoiceServiceException( e );
    }
}
 
开发者ID:ClouDesire,项目名称:janine,代码行数:17,代码来源:InvoiceServiceImpl.java

示例5: testValidateSignatureVlidationTest

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/41116833/pdf-signature-validation">
 * PDF Signature Validation
 * </a>
 * <br/>
 * <a href="https://drive.google.com/file/d/0BzEmZ9pRWLhPOUJSYUdlRjg2eEU/view?usp=sharing">
 * SignatureVlidationTest.pdf
 * </a>
 * <p>
 * The code completely ignores the <b>SubFilter</b> of the signature.
 * It is appropriate for signatures with <b>SubFilter</b> values
 * <b>adbe.pkcs7.detached</b> and <b>ETSI.CAdES.detached</b>
 * but will fail for signatures with <b>SubFilter</b> values
 * <b>adbe.pkcs7.sha1</b> and <b>adbe.x509.rsa.sha1</b>.
 * </p>
 * <p>
 * The example document has been signed with a signatures with
 * <b>SubFilter</b> value <b>adbe.pkcs7.sha1</b>.
 * </p>
 */
@Test
public void testValidateSignatureVlidationTest() throws Exception
{
    System.out.println("\nValidate signature in SignatureVlidationTest.pdf; original code.");
    byte[] pdfByte;
    PDDocument pdfDoc = null;
    SignerInformationVerifier verifier = null;
    try
    {
        pdfByte = IOUtils.toByteArray(this.getClass().getResourceAsStream("SignatureVlidationTest.pdf"));
        pdfDoc = PDDocument.load(new ByteArrayInputStream(pdfByte));
        PDSignature signature = pdfDoc.getSignatureDictionaries().get(0);

        byte[] signatureAsBytes = signature.getContents(pdfByte);
        byte[] signedContentAsBytes = signature.getSignedContent(pdfByte);
        CMSSignedData cms = new CMSSignedData(new CMSProcessableByteArray(signedContentAsBytes), signatureAsBytes);
        SignerInformation signerInfo = (SignerInformation) cms.getSignerInfos().getSigners().iterator().next();
        X509CertificateHolder cert = (X509CertificateHolder) cms.getCertificates().getMatches(signerInfo.getSID())
                .iterator().next();
        verifier = new JcaSimpleSignerInfoVerifierBuilder().setProvider(new BouncyCastleProvider()).build(cert);

        // result if false
        boolean verifyRt = signerInfo.verify(verifier);
        System.out.println("Verify result: " + verifyRt);
    }
    finally
    {
        if (pdfDoc != null)
        {
            pdfDoc.close();
        }
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:54,代码来源:ValidateSignature.java

示例6: testValidateSignatureVlidationTestAdbePkcs7Sha1

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/41116833/pdf-signature-validation">
 * PDF Signature Validation
 * </a>
 * <br/>
 * <a href="https://drive.google.com/file/d/0BzEmZ9pRWLhPOUJSYUdlRjg2eEU/view?usp=sharing">
 * SignatureVlidationTest.pdf
 * </a>
 * <p>
 * This code also ignores the <b>SubFilter</b> of the signature,
 * it is appropriate for signatures with <b>SubFilter</b> value
 * <b>adbe.pkcs7.sha1</b> which the example document has been
 * signed with.
 * </p>
 */
@Test
public void testValidateSignatureVlidationTestAdbePkcs7Sha1() throws Exception
{
    System.out.println("\nValidate signature in SignatureVlidationTest.pdf; special adbe.pkcs7.sha1 code.");
    byte[] pdfByte;
    PDDocument pdfDoc = null;
    SignerInformationVerifier verifier = null;
    try
    {
        pdfByte = IOUtils.toByteArray(this.getClass().getResourceAsStream("SignatureVlidationTest.pdf"));
        pdfDoc = PDDocument.load(new ByteArrayInputStream(pdfByte));
        PDSignature signature = pdfDoc.getSignatureDictionaries().get(0);

        byte[] signatureAsBytes = signature.getContents(pdfByte);
        CMSSignedData cms = new CMSSignedData(new ByteArrayInputStream(signatureAsBytes));
        SignerInformation signerInfo = (SignerInformation) cms.getSignerInfos().getSigners().iterator().next();
        X509CertificateHolder cert = (X509CertificateHolder) cms.getCertificates().getMatches(signerInfo.getSID())
                .iterator().next();
        verifier = new JcaSimpleSignerInfoVerifierBuilder().setProvider(new BouncyCastleProvider()).build(cert);

        boolean verifyRt = signerInfo.verify(verifier);
        System.out.println("Verify result: " + verifyRt);

        byte[] signedContentAsBytes = signature.getSignedContent(pdfByte);
        MessageDigest md = MessageDigest.getInstance("SHA1");
        byte[] calculatedDigest = md.digest(signedContentAsBytes);
        byte[] signedDigest = (byte[]) cms.getSignedContent().getContent();
        System.out.println("Document digest equals: " + Arrays.equals(calculatedDigest, signedDigest));
    }
    finally
    {
        if (pdfDoc != null)
        {
            pdfDoc.close();
        }
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:53,代码来源:ValidateSignature.java

示例7: getDiagramByte

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
private static byte[] getDiagramByte(ProcessInstance pi) throws Exception {
	byte[] data = null;
	ProcessDiagramGenerator processDiagramGenerator = new DefaultProcessDiagramGenerator();
	BpmnModel model = repositoryService.getBpmnModel(pi.getProcessDefinitionId());
	InputStream is = processDiagramGenerator.generateDiagram(
			model, 
			"png", 
			runtimeService.getActiveActivityIds(pi.getId()));
	data = IOUtils.toByteArray(is);
	is.close();
	is = null;	
	return data;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:14,代码来源:BusinessProcessManagementUtils.java

示例8: doSignOneStep

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * {@link #doSignOriginal(InputStream, InputStream, File)} changed to add the image and sign at the same time.
 */
public void doSignOneStep(InputStream inputStream, InputStream logoStream, File outputDocument) throws Exception
{
    byte inputBytes[] = IOUtils.toByteArray(inputStream);
    PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));

    PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(logoStream));
    PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
    PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
    contentStream.drawXObject(ximage, 50, 50, 356, 40);
    contentStream.close();

    page.getResources().getCOSObject().setNeedToBeUpdate(true);
    page.getResources().getCOSDictionary().getDictionaryObject(COSName.XOBJECT).setNeedToBeUpdate(true);
    ximage.getCOSObject().setNeedToBeUpdate(true);

    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");
    signature.setSignDate(Calendar.getInstance());

    pdDocument.addSignature(signature, new TC3());

    FileOutputStream fos = new FileOutputStream(outputDocument);
    fos.write(inputBytes);
    FileInputStream is = new FileInputStream(outputDocument);

    pdDocument.saveIncremental(is, fos);
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:35,代码来源:SignLikeUnOriginalToo.java

示例9: loadCopyOfPdf

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
private Pdf loadCopyOfPdf(String pathToPdf) throws IOException {
    InputStream fos = getClass().getResourceAsStream(pathToPdf);
    assertNotNull(fos);
    // this makes sure that any changes we make to the pdf are not persisted between tests
    ByteArrayInputStream copyOfPDF = new ByteArrayInputStream(IOUtils.toByteArray(fos));
    InputStream commentBoxStream = getClass().getResourceAsStream("/images/comment_box.PNG");
    assertNotNull(commentBoxStream);
    return new Pdf(copyOfPDF, commentBoxStream);
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:10,代码来源:TestPdfCommentExtraction.java

示例10: signBySnox

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/41767351/create-pkcs7-signature-from-file-digest">
 * Create pkcs7 signature from file digest
 * </a>
 * <p>
 * The OP's own <code>sign</code> method which has some errors. These
 * errors are fixed in {@link #signWithSeparatedHashing(InputStream)}.
 * </p>
 */
public byte[] signBySnox(InputStream content) throws IOException {
    // testSHA1WithRSAAndAttributeTable
    try {
        MessageDigest md = MessageDigest.getInstance("SHA1", "BC");
        List<Certificate> certList = new ArrayList<Certificate>();
        CMSTypedData msg = new CMSProcessableByteArray(IOUtils.toByteArray(content));

        certList.addAll(Arrays.asList(chain));

        Store certs = new JcaCertStore(certList);

        CMSSignedDataGenerator gen = new CMSSignedDataGenerator();

        Attribute attr = new Attribute(CMSAttributes.messageDigest,
                new DERSet(new DEROctetString(md.digest(IOUtils.toByteArray(content)))));

        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(attr);

        SignerInfoGeneratorBuilder builder = new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                .setSignedAttributeGenerator(new DefaultSignedAttributeTableGenerator(new AttributeTable(v)));

        AlgorithmIdentifier sha1withRSA = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1withRSA");

        CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
        InputStream in = new ByteArrayInputStream(chain[0].getEncoded());
        X509Certificate cert = (X509Certificate) certFactory.generateCertificate(in);

        gen.addSignerInfoGenerator(builder.build(
                new BcRSAContentSignerBuilder(sha1withRSA,
                        new DefaultDigestAlgorithmIdentifierFinder().find(sha1withRSA))
                                .build(PrivateKeyFactory.createKey(pk.getEncoded())),
                new JcaX509CertificateHolder(cert)));

        gen.addCertificates(certs);

        CMSSignedData s = gen.generate(new CMSAbsentContent(), false);
        return new CMSSignedData(msg, s.getEncoded()).getEncoded();

    } catch (Exception e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox2,代码行数:55,代码来源:CreateSignature.java

示例11: doSign

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
public void doSign() throws Exception
{
    byte inputBytes[] = IOUtils.toByteArray(new FileInputStream("resources/rooster.pdf"));
    PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
    PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(new File("resources/logo.jpg")));
    PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
    PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
    contentStream.drawXObject(ximage, 50, 50, 356, 40);
    contentStream.close();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    pdDocument.save(os);
    os.flush();
    pdDocument.close();

    inputBytes = os.toByteArray();
    pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));

    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");
    signature.setSignDate(Calendar.getInstance());

    pdDocument.addSignature(signature, this);

    File outputDocument = new File("resources/signed.pdf");
    ByteArrayInputStream fis = new ByteArrayInputStream(inputBytes);
    FileOutputStream fos = new FileOutputStream(outputDocument);
    byte[] buffer = new byte[8 * 1024];
    int c;
    while ((c = fis.read(buffer)) != -1)
    {
        fos.write(buffer, 0, c);
    }
    fis.close();
    FileInputStream is = new FileInputStream(outputDocument);

    pdDocument.saveIncremental(is, fos);
    pdDocument.close();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:43,代码来源:TC3.java

示例12: doSignOriginal

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * Essentially the original code from {@link TC3#doSign()} with dynamic input streams and output file.
 */
public void doSignOriginal(InputStream inputStream, InputStream logoStream, File outputDocument) throws Exception
{
    byte inputBytes[] = IOUtils.toByteArray(inputStream);
    PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
    PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(logoStream));
    PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
    PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
    contentStream.drawXObject(ximage, 50, 50, 356, 40);
    contentStream.close();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    pdDocument.save(os);
    os.flush();
    pdDocument.close();

    inputBytes = os.toByteArray();
    pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));

    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");
    signature.setSignDate(Calendar.getInstance());

    pdDocument.addSignature(signature, new TC3());

    ByteArrayInputStream fis = new ByteArrayInputStream(inputBytes);
    FileOutputStream fos = new FileOutputStream(outputDocument);
    byte[] buffer = new byte[8 * 1024];
    int c;
    while ((c = fis.read(buffer)) != -1)
    {
        fos.write(buffer, 0, c);
    }
    fis.close();
    FileInputStream is = new FileInputStream(outputDocument);

    pdDocument.saveIncremental(is, fos);
    pdDocument.close();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:45,代码来源:SignLikeUnOriginalToo.java

示例13: doSignRemoveType

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * {@link #doSignOriginal(InputStream, InputStream, File)} changed to remove the Type entry from the trailer.
 */
public void doSignRemoveType(InputStream inputStream, InputStream logoStream, File outputDocument) throws Exception
{
    byte inputBytes[] = IOUtils.toByteArray(inputStream);
    PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
    PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(logoStream));
    PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
    PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
    contentStream.drawXObject(ximage, 50, 50, 356, 40);
    contentStream.close();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    pdDocument.save(os);
    os.flush();
    pdDocument.close();

    inputBytes = os.toByteArray();
    pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
    pdDocument.getDocument().getTrailer().removeItem(COSName.TYPE);

    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");
    signature.setSignDate(Calendar.getInstance());

    pdDocument.addSignature(signature, new TC3());

    ByteArrayInputStream fis = new ByteArrayInputStream(inputBytes);
    FileOutputStream fos = new FileOutputStream(outputDocument);
    byte[] buffer = new byte[8 * 1024];
    int c;
    while ((c = fis.read(buffer)) != -1)
    {
        fos.write(buffer, 0, c);
    }
    fis.close();
    FileInputStream is = new FileInputStream(outputDocument);

    pdDocument.saveIncremental(is, fos);
    pdDocument.close();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:46,代码来源:SignLikeUnOriginalToo.java

示例14: doSignTwoRevisions

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * {@link #doSignOriginal(InputStream, InputStream, File)} changed to also save the first change as new revision.
 */
public void doSignTwoRevisions(InputStream inputStream, InputStream logoStream, File intermediateDocument, File outputDocument) throws Exception
{
    FileOutputStream fos = new FileOutputStream(intermediateDocument);
    FileInputStream fis = new FileInputStream(intermediateDocument);

    byte inputBytes[] = IOUtils.toByteArray(inputStream);

    PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(inputBytes));
    PDJpeg ximage = new PDJpeg(pdDocument, ImageIO.read(logoStream));
    PDPage page = (PDPage) pdDocument.getDocumentCatalog().getAllPages().get(0);
    PDPageContentStream contentStream = new PDPageContentStream(pdDocument, page, true, true);
    contentStream.drawXObject(ximage, 50, 50, 356, 40);
    contentStream.close();

    pdDocument.getDocumentCatalog().getCOSObject().setNeedToBeUpdate(true);
    pdDocument.getDocumentCatalog().getPages().getCOSObject().setNeedToBeUpdate(true);
    page.getCOSObject().setNeedToBeUpdate(true);
    page.getResources().getCOSObject().setNeedToBeUpdate(true);
    page.getResources().getCOSDictionary().getDictionaryObject(COSName.XOBJECT).setNeedToBeUpdate(true);
    ximage.getCOSObject().setNeedToBeUpdate(true);

    fos.write(inputBytes);
    pdDocument.saveIncremental(fis, fos);
    pdDocument.close();

    pdDocument = PDDocument.load(intermediateDocument);

    PDSignature signature = new PDSignature();
    signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
    signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
    signature.setName("signer name");
    signature.setLocation("signer location");
    signature.setReason("reason for signature");
    signature.setSignDate(Calendar.getInstance());

    pdDocument.addSignature(signature, new TC3());

    fos = new FileOutputStream(outputDocument);
    fis = new FileInputStream(outputDocument);
    inputBytes = IOUtils.toByteArray(new FileInputStream(intermediateDocument));

    fos.write(inputBytes);
    pdDocument.saveIncremental(fis, fos);
    pdDocument.close();
}
 
开发者ID:mkl-public,项目名称:testarea-pdfbox1,代码行数:49,代码来源:SignLikeUnOriginalToo.java

示例15: inputStream2Mat

import org.apache.pdfbox.io.IOUtils; //导入方法依赖的package包/类
/**
 * Converts InputStream to OpenCV Mat
 *
 * @param stream Input stream
 * @param flag   org.opencv.imgcodecs.Imgcodecs flag
 * @return org.opencv.core.Mat
 * @throws IOException
 */
public static Mat inputStream2Mat(InputStream stream, int flag) throws IOException {
    byte[] byteBuff = IOUtils.toByteArray(stream);
    return Imgcodecs.imdecode(new MatOfByte(byteBuff), flag);
}
 
开发者ID:rostrovsky,项目名称:pdf-table,代码行数:13,代码来源:Utils.java


注:本文中的org.apache.pdfbox.io.IOUtils.toByteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。