我一直在試圖把我的PDF文件的權限。 我有這將設置訪問權限上稱爲訪問訪問權限不起作用
private AccessPermission access = new AccessPermission();
public void setPdfPermissions(boolean allowPrint, boolean degradePrint,
boolean editPage, boolean allowAssembly, boolean allowCopy,
boolean allowReaders, boolean editAnnotation, boolean allowFillIn) {
if (allowPrint) { // allow printing
access.setCanPrint(allowPrint);
}
if (degradePrint) { // degrade printing
access.setCanPrintDegraded(allowAssembly);
}
if (editPage) { // edit page contents
access.setCanModify(editPage);
}
if (allowAssembly) { // insert, remote or rotate page
access.setCanAssembleDocument(allowAssembly);
}
if (allowCopy) { // copy page contents or graphics
access.setCanExtractForAccessibility(allowCopy);
}
if (allowReaders) { // screen readers can copy contents or graphics
access.setReadOnly();
}
if (editAnnotation) { // edit annotations
access.setCanModifyAnnotations(editAnnotation);
}
if (allowFillIn) { // fill form fields
access.setCanFillInForm(allowFillIn);
}
}
,然後我米保存在安全處理程序中訪問的實例變量的方法
StandardSecurityHandler secHandler = new StandardSecurityHandler();
if((userPass != null) || (ownerPass != null)) {
System.out.println("userPass:"+userPass+"owner pass:"+userPass);
// TODO
StandardProtectionPolicy policy = new StandardProtectionPolicy(ownerPass.toString(), userPass.toString(),
access);
secHandler = new StandardSecurityHandler(policy);
document.setSecHandler(secHandler);
時,即時通訊傳遞錯誤的價值像setPrint爲假,它允許我打印。任何幫助,高度讚賞。