本文整理匯總了Java中org.pdfbox.exceptions.CryptographyException類的典型用法代碼示例。如果您正苦於以下問題:Java CryptographyException類的具體用法?Java CryptographyException怎麽用?Java CryptographyException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CryptographyException類屬於org.pdfbox.exceptions包,在下文中一共展示了CryptographyException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doActionExtractText
import org.pdfbox.exceptions.CryptographyException; //導入依賴的package包/類
private void doActionExtractText() throws PageException, IOException, CryptographyException, InvalidPasswordException {
required("pdf", "extractText", "name", name,true);
PDFDocument doc = toPDFDocument(source,password,null);
doc.setPages(pages);
pageContext.setVariable(name, PDFUtil.extractText(doc,doc.getPages()));
/*
<cfpdf
required
action="extracttext" <!---extract all the words in the PDF.--->
***source= "absolute or relative path of the PDF file|PDF document variable|
cfdocument variable"
pages = "*" <!----page numbers from where the text needs to be extracted from the
PDF document--->
optional
addquads = "add the position or quadrants for the text in the PDF"
honourspaces = "true|false"
overwrite = "true" <!---Overwrite the specified object in the PDF document--->
***password = "" <!--- PDF document password--->
type = "string|xml" <!---format in which the text needs to be extracted--->
one of the following:
destination = "PDF output file pathname"
name = "PDF document variable"
usestructure = "true|false"
* */
}
示例2: toPDDocument
import org.pdfbox.exceptions.CryptographyException; //導入依賴的package包/類
public PDDocument toPDDocument() throws CryptographyException, InvalidPasswordException, IOException {
PDDocument doc;
if(barr!=null)
doc= PDDocument.load(new ByteArrayInputStream(barr,0,barr.length));
else if(resource instanceof FileResource)
doc= PDDocument.load((File)resource);
else
doc= PDDocument.load(new ByteArrayInputStream(IOUtil.toBytes(resource),0,barr.length));
if(password!=null)doc.decrypt(password);
return doc;
}
示例3: extractText
import org.pdfbox.exceptions.CryptographyException; //導入依賴的package包/類
public static Object extractText(PDFDocument doc, Set<Integer> pageNumbers) throws IOException, CryptographyException, InvalidPasswordException {
PDDocument pdDoc = doc.toPDDocument();
//PDPageNode pages = pdDoc.getDocumentCatalog().getPages();
//pages.
//pdDoc.getDocumentCatalog().
/*Iterator<Integer> it = pageNumbers.iterator();
int p;
while(it.hasNext()){
p=it.next().intValue();
pdDoc.getDocumentCatalog().getPages()
}
*/
//print.o(pages);
//pdDoc.
//PDFTextStripperByArea stripper = new PDFTextStripperByArea();
//PDFHighlighter stripper = new PDFHighlighter();
PDFText2HTML stripper = new PDFText2HTML();
//PDFTextStripper stripper = new PDFTextStripper();
StringWriter writer = new StringWriter();
stripper.writeText(pdDoc, writer);
return writer.toString();
}