use of com.tom_roush.pdfbox.text.PDFTextStripper in project PdfBox-Android by TomRoush.
the class TestPublicKeyEncryption method setUp.
/**
* {@inheritDoc}
*/
@Before
public void setUp() throws Exception {
if (Cipher.getMaxAllowedKeyLength("AES") != Integer.MAX_VALUE) {
// we need strong encryption for these tests
fail("JCE unlimited strength jurisdiction policy files are not installed");
}
testContext = InstrumentationRegistry.getInstrumentation().getContext();
PDFBoxResourceLoader.init(testContext);
testResultsDir = new File(testContext.getCacheDir(), "pdfbox-test-output/crypto");
testResultsDir.mkdirs();
permission1 = new AccessPermission();
permission1.setCanAssembleDocument(false);
permission1.setCanExtractContent(false);
permission1.setCanExtractForAccessibility(true);
permission1.setCanFillInForm(false);
permission1.setCanModify(false);
permission1.setCanModifyAnnotations(false);
permission1.setCanPrint(false);
permission1.setCanPrintDegraded(false);
permission2 = new AccessPermission();
permission2.setCanAssembleDocument(false);
permission2.setCanExtractContent(false);
permission2.setCanExtractForAccessibility(true);
permission2.setCanFillInForm(false);
permission2.setCanModify(false);
permission2.setCanModifyAnnotations(false);
// it is true now !
permission2.setCanPrint(true);
permission2.setCanPrintDegraded(false);
recipient1 = getRecipient("test1.der", permission1);
recipient2 = getRecipient("test2.der", permission2);
password1 = "test1";
password2 = "test2";
keyStore1 = "test1.pfx";
keyStore2 = "test2.pfx";
document = PDDocument.load(testContext.getAssets().open(path + "test.pdf"));
text = new PDFTextStripper().getText(document);
producer = document.getDocumentInformation().getProducer();
document.setVersion(1.7f);
}
use of com.tom_roush.pdfbox.text.PDFTextStripper in project PdfBox-Android by TomRoush.
the class TestFontEncoding method testPDFBox3884.
/**
* PDFBOX-3826: Some unicodes are reached by several names in glyphlist.txt, e.g. tilde and
* ilde.
*
* @throws IOException
*/
public void testPDFBox3884() throws IOException {
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage(page);
PDPageContentStream cs = new PDPageContentStream(doc, page);
cs.setFont(PDType1Font.HELVETICA, 20);
cs.beginText();
cs.newLineAtOffset(100, 700);
// first tilde is "asciitilde" (from the keyboard), 2nd tilde is "tilde"
// using ˜ would bring IllegalArgumentException prior to bugfix
cs.showText("~˜");
cs.endText();
cs.close();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
doc.save(baos);
doc.close();
// verify
doc = PDDocument.load(baos.toByteArray());
PDFTextStripper stripper = new PDFTextStripper();
String text = stripper.getText(doc);
assertEquals("~˜", text.trim());
doc.close();
}
Aggregations