I’m using the php javabridge which is provided in the documentation to write a php application which generates a protected pdf file.
Here is the code I have to set the protection (where $ptype=‘PRINTING’):
$pdfpermissions = Java(“com.aspose.words.PdfPermissions”);
$pdfencryptiondetails = Java(“com.aspose.words.PdfEncryptionDetails”);
$permission = $pdfpermissions->{$ptype};
$pdfencryptiondetails->setPermissions($permission);
$saveoptions->setEncryptionDetails($pdfencryptiondetails);
But I get an error on the 4th line in this piece of code.
This is the error I get:
Fatal error: Uncaught [[o:Exception]:“java.lang.Exception: Invoke failed: [[c:PdfEncryptionDetails]]->setPermissions([o:Integer]). Cause: php.java.bridge.NoSuchProcedureException: static setPermissions([o:Integer]). Candidates: [] VM: 1.8.0_40@<http://java.oracle.com>/” at: #-6 php.java.bridge.JavaBridge.checkM(JavaBridge.java:1084) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1024) #-4 php.java.bridge.Request.handleRequest(Request.java:417) #-3 php.java.bridge.Request.handleRequests(Request.java:500) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.java:145) #-1 php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:60) #0 /opt/tbg/apache-tomcat-7.0.42/webapps/X-PAA/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(730, ‘java.lang.Integ…’, ‘T’, true) #1 /opt/tbg/apache-tomcat-7.0.42/webapps/X-PAA/java/Java.inc(360): java_Arg->getResult(true) #2 /opt/tbg/apache-tomcat-7.0.42/webapps/X-PAA/java/Java.inc(366): java_Client->getWrappedResult(true) #3 /opt/tbg/apache-tomcat-7.0.42/webapps/X-PAA/ja in /opt/tbg/apache-tomcat-7.0.42/webapps/X-PAA/java/Java.inc on line 195
I find this very odd because when I do a java_inspect of $pdfencrypitiondetails I get this:
[class com.aspose.words.PdfEncryptionDetails: Constructors: public com.aspose.words.PdfEncryptionDetails(java.lang.String,java.lang.String,int) Fields: Methods: public void com.aspose.words.PdfEncryptionDetails.setPermissions(int) public int com.aspose.words.PdfEncryptionDetails.getEncryptionAlgorithm() public java.lang.String com.aspose.words.PdfEncryptionDetails.getOwnerPassword() public java.lang.String com.aspose.words.PdfEncryptionDetails.getUserPassword() public void com.aspose.words.PdfEncryptionDetails.setEncryptionAlgorithm(int) public void com.aspose.words.PdfEncryptionDetails.setOwnerPassword(java.lang.String) public void com.aspose.words.PdfEncryptionDetails.setUserPassword(java.lang.String) public int com.aspose.words.PdfEncryptionDetails.getPermissions() public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException public final void java.lang.Object.wait() throws java.lang.InterruptedException public boolean java.lang.Object.equals(java.lang.Object) public java.lang.String java.lang.Object.toString() public native int java.lang.Object.hashCode() public final native java.lang.Class java.lang.Object.getClass() public final native void java.lang.Object.notify() public final native void java.lang.Object.notifyAll() public static java.lang.Class java.lang.Class.forName(java.lang.String) throws java.lang.ClassNotFoundException public static java.lang.Class java.lang.Class.forName(java.lang.String,boolean,java.lang.ClassLoader) throws java.lang.ClassNotFoundException public java.lang.String java.lang.Class.toString() public java.security.ProtectionDomain java.lang.Class.getProtectionDomain() public native boolean java.lang.Class.isAssignableFrom(java.lang.Class) public native boolean java.lang.Class.isInstance(java.lang.Object) public native int java.lang.Class.getModifiers() public native boolean java.lang.Class.isInterface() public native boolean java.lang.Class.isArray() public native boolean java.lang.Class.isPrimitive() public native java.lang.Class java.lang.Class.getSuperclass() public native java.lang.Class java.lang.Class.getComponentType() public java.lang.String java.lang.Class.getName() public java.lang.String java.lang.Class.toGenericString() public java.lang.Object java.lang.Class.newInstance() throws java.lang.InstantiationException,java.lang.IllegalAccessException public boolean java.lang.Class.isAnnotation() public boolean java.lang.Class.isSynthetic() public java.lang.ClassLoader java.lang.Class.getClassLoader() public java.lang.reflect.TypeVariable[] java.lang.Class.getTypeParameters() public java.lang.reflect.Type java.lang.Class.getGenericSuperclass() public java.lang.Package java.lang.Class.getPackage() public java.lang.Class[] java.lang.Class.getInterfaces() public java.lang.reflect.Type[] java.lang.Class.getGenericInterfaces() public native java.lang.Object[] java.lang.Class.getSigners() public java.lang.reflect.Method java.lang.Class.getEnclosingMethod() throws java.lang.SecurityException public java.lang.reflect.Constructor java.lang.Class.getEnclosingConstructor() throws java.lang.SecurityException public java.lang.Class java.lang.Class.getDeclaringClass() throws java.lang.SecurityException public java.lang.Class java.lang.Class.getEnclosingClass() throws java.lang.SecurityException public java.lang.String java.lang.Class.getSimpleName() public java.lang.String java.lang.Class.getTypeName() public java.lang.String java.lang.Class.getCanonicalName() public boolean java.lang.Class.isAnonymousClass() public boolean java.lang.Class.isLocalClass() public boolean java.lang.Class.isMemberClass() public java.lang.Class[] java.lang.Class.getClasses() public java.lang.reflect.Field[] java.lang.Class.getFields() throws java.lang.SecurityException public java.lang.reflect.Method[] java.lang.Class.getMethods() throws java.lang.SecurityException public java.lang.reflect.Constructor[] java.lang.Class.getConstructors() throws java.lang.SecurityException public java.lang.reflect.Field java.lang.Class.getField(java.lang.String) throws java.lang.NoSuchFieldException,java.lang.SecurityException public java.lang.reflect.Method java.lang.Class.getMethod(java.lang.String,java.lang.Class[]) throws java.lang.NoSuchMethodException,java.lang.SecurityException public java.lang.reflect.Constructor java.lang.Class.getConstructor(java.lang.Class[]) throws java.lang.NoSuchMethodException,java.lang.SecurityException public java.lang.Class[] java.lang.Class.getDeclaredClasses() throws java.lang.SecurityException public java.lang.reflect.Field[] java.lang.Class.getDeclaredFields() throws java.lang.SecurityException public java.lang.reflect.Method[] java.lang.Class.getDeclaredMethods() throws java.lang.SecurityException public java.lang.reflect.Constructor[] java.lang.Class.getDeclaredConstructors() throws java.lang.SecurityException public java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String) throws java.lang.NoSuchFieldException,java.lang.SecurityException public java.lang.reflect.Method java.lang.Class.getDeclaredMethod(java.lang.String,java.lang.Class[]) throws java.lang.NoSuchMethodException,java.lang.SecurityException public java.lang.reflect.Constructor java.lang.Class.getDeclaredConstructor(java.lang.Class[]) throws java.lang.NoSuchMethodException,java.lang.SecurityException public java.io.InputStream java.lang.Class.getResourceAsStream(java.lang.String) public java.net.URL java.lang.Class.getResource(java.lang.String) public boolean java.lang.Class.desiredAssertionStatus() public boolean java.lang.Class.isEnum() public java.lang.Object[] java.lang.Class.getEnumConstants() public java.lang.Object java.lang.Class.cast(java.lang.Object) public java.lang.Class java.lang.Class.asSubclass(java.lang.Class) public java.lang.annotation.Annotation java.lang.Class.getAnnotation(java.lang.Class) public boolean java.lang.Class.isAnnotationPresent(java.lang.Class) public java.lang.annotation.Annotation[] java.lang.Class.getAnnotationsByType(java.lang.Class) public java.lang.annotation.Annotation[] java.lang.Class.getAnnotations() public java.lang.annotation.Annotation java.lang.Class.getDeclaredAnnotation(java.lang.Class) public java.lang.annotation.Annotation[] java.lang.Class.getDeclaredAnnotationsByType(java.lang.Class) public java.lang.annotation.Annotation[] java.lang.Class.getDeclaredAnnotations() public java.lang.reflect.AnnotatedType java.lang.Class.getAnnotatedSuperclass() public java.lang.reflect.AnnotatedType[] java.lang.Class.getAnnotatedInterfaces() public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException public final void java.lang.Object.wait() throws java.lang.InterruptedException public boolean java.lang.Object.equals(java.lang.Object) public native int java.lang.Object.hashCode() public final native java.lang.Class java.lang.Object.getClass() public final native void java.lang.Object.notify() public final native void java.lang.Object.notifyAll() Classes: ]
which does show the methode listed. I’ve tried to call other methodes from this class but with getEncryptionAlgorithm() and getPermissions() I get the same problem. I haven’t tried it with other methodes.
I’ve tried this with aspose words for java 16.6.0 and an older version and both have the problem.
I don’t think this is in the javabridge because I’m using this for many calls to both aspose and other API’s and none of the other methose calls fails.
Could you tell me what is going on here or if this is a bug?