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


Java RandomAccessBufferedFileInputStream類代碼示例

本文整理匯總了Java中org.apache.pdfbox.io.RandomAccessBufferedFileInputStream的典型用法代碼示例。如果您正苦於以下問題:Java RandomAccessBufferedFileInputStream類的具體用法?Java RandomAccessBufferedFileInputStream怎麽用?Java RandomAccessBufferedFileInputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RandomAccessBufferedFileInputStream類屬於org.apache.pdfbox.io包,在下文中一共展示了RandomAccessBufferedFileInputStream類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testPdfFromStringTo

import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream; //導入依賴的package包/類
@Test
public void testPdfFromStringTo() throws Exception {

    // GIVEN an html template containing special characters that java stores in utf-16 internally
    Pdf pdf = pdfBuilder.build();
    pdf.addPage("<html><head><meta charset=\"utf-8\"></head><h1>Müller</h1></html>", PageType.htmlAsString);

    String tempFolder = temporaryFolder.newFolder().getPath();
    pdf.saveAs(tempFolder+"/output.pdf");

    // WHEN
    byte[] pdfBytes = pdf.getPDF();

    PDFParser parser = new PDFParser(new RandomAccessBufferedFileInputStream(new ByteArrayInputStream(pdfBytes)));

    // that is a valid PDF (otherwise an IOException occurs)
    parser.parse();
    PDFTextStripper pdfTextStripper = new PDFTextStripper();
    String pdfText = pdfTextStripper.getText(new PDDocument(parser.getDocument()));

    assertThat("document should contain the creditorName", pdfText, containsString("Müller"));
}
 
開發者ID:sastix,項目名稱:cms,代碼行數:23,代碼來源:PdfTest.java

示例2: readThesaurus

import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream; //導入依賴的package包/類
private List<SubstanceInteraction> readThesaurus(File dir) throws IOException {
    File file = new File(dir, "thesaurus.pdf");

    PDFParser parser = new PDFParser(new RandomAccessBufferedFileInputStream(file));
    parser.parse();
    COSDocument cosDoc = parser.getDocument();
    ThesaurusPDFStripper pdfStripper = new ThesaurusPDFStripper();
    PDDocument pdDoc = new PDDocument(cosDoc);
    pdfStripper.setStartPage(2);
    pdfStripper.setEndPage(pdDoc.getNumberOfPages());

    pdfStripper.getText(pdDoc);

    cosDoc.close();

    return pdfStripper.substances;
}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:18,代碼來源:InteractionService.java

示例3: parse

import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream; //導入依賴的package包/類
@Test
public void parse() throws IOException {
    File file = new File(MedicamentTest.class.getClassLoader().getResource(".").getFile(), "thesaurus.pdf");

    PDFParser parser = new PDFParser(new RandomAccessBufferedFileInputStream(file));
    parser.parse();
    COSDocument cosDoc = parser.getDocument();
    AdvancedPDFStripper pdfStripper = new AdvancedPDFStripper();
    PDDocument pdDoc = new PDDocument(cosDoc);
    pdfStripper.setStartPage(2);
    pdfStripper.setEndPage(pdDoc.getNumberOfPages());

    pdfStripper.getText(pdDoc);

    System.out.println(pdfStripper.substances);
}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:17,代碼來源:PDFTest.java

示例4: sanitize

import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream; //導入依賴的package包/類
@Override
public void sanitize(InputStream inputStream, OutputStream outputStream, BleachSession session) throws BleachException {
    try (RandomAccessRead source = new RandomAccessBufferedFileInputStream(inputStream)) {
        sanitize(source, outputStream, session);
    } catch (IOException e) {
        throw new BleachException(e);
    }
}
 
開發者ID:docbleach,項目名稱:DocBleach,代碼行數:9,代碼來源:PdfBleach.java

示例5: readInteractions

import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream; //導入依賴的package包/類
private Map<String, List<Interaction>> readInteractions(File dir) throws IOException {
    File file = new File(dir, "interactions.pdf");

    PDFParser parser = new PDFParser(new RandomAccessBufferedFileInputStream(file));

    parser.parse();
    COSDocument cosDoc = parser.getDocument();
    InteractionPDFStripper pdfStripper = new InteractionPDFStripper();
    PDDocument pdDoc = new PDDocument(cosDoc);
    pdfStripper.setStartPage(2);
    pdfStripper.setEndPage(pdDoc.getNumberOfPages());

    pdfStripper.getText(pdDoc);

    cosDoc.close();

    Map<String, List<Interaction>> interactions = pdfStripper.interactions;
    Map<String, List<Interaction>> newInteractions = new HashMap<>();

    for (List<Interaction> tmp : interactions.values()) {
        for (Interaction interaction : tmp) {
            String famille2 = normalize(interaction.getFamille2(), true);

            // cas particuliers
            switch (famille2) {
                case "medicaments hyponatremiants":
                    famille2 = "hyponatremiants";
                    break;
            }

            List<Interaction> interactions2 = interactions.get(famille2);
            if (interactions2 == null) {
                LOG.warn("interaction " + interaction.getFamille2() + " inconnu");

                Interaction newInteraction;
                if (newInteractions.get(famille2) == null) {
                    newInteractions.put(famille2, new ArrayList<>());

                    newInteraction = pdfStripper.createEmptyInteraction(-1, interaction.getFamille2());
                } else {
                    newInteraction = pdfStripper.createEmptyInteraction(Integer.parseInt(newInteractions.get(famille2).get(0).getId1()), interaction.getFamille2());
                }

                newInteraction.setId2(interaction.getId1());
                newInteraction.setFamille2(interaction.getFamille1());
                newInteraction.setDescription(interaction.getDescription());
                newInteraction.setConseil(interaction.getConseil());

                newInteractions.get(famille2).add(newInteraction);

                interaction.setId2(newInteraction.getId1());
            } else {
                interaction.setId2(interactions2.get(0).getId1());
            }
        }
    }

    for (String key : newInteractions.keySet()) {
        interactions.put(key, newInteractions.get(key));
    }

    return interactions;

}
 
開發者ID:Ellixo,項目名稱:MedicamentDB,代碼行數:65,代碼來源:InteractionService.java


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