Can we have demo of this how can we use ASPOSE API in Java program to convert PDF to PDF/A-3.
You can use Aspose.PDF to convert PDF to PDF/A-3. Please refer to the following article for more detail.
Convert PDF file to other Formats
Hi Tahir,
we are getting attached error…
We have JDK 1.8. but still getting attached errror message
Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
can we have screenshare to setup this JAR
Please read following article about installing Aspose.PDF for Java.
How to install Aspose.PDF for Java
If you still face problem, please share your working environment e.g. operating system, IDE etc. We will then provide you more information about your issue.
Installation saying maven setup…Is it mandatory to use maven to use aspose.PDF?? We are not that familiar with maven…we are trying to write core standalone JAVA program including aspose.PDF Jar files in classpath… Is that works??
we are trying to integrate this with Oracle db eventually, but we are in Linux using no IDE as such.
It is not mandatory to use Maven project for Aspose.PDF. You can download its JARs and use them directly in your Java Project. Regarding Oracle DB integration, Aspose.PDF does not provide any functionality to integrate with any database. However, you can use any type of database in your project to fetch and store data and utilize Aspose.PDF for documents creation.
Hi Asad,
Thank you for quick response.
Now we have downloaded all class file from [Aspose.PDF for Java 10.6.1].but we are getting unkown source error as follows… Is this version incompatablility errors?? Which version of PDF we need to download to compatible with our JAVA with PDF-A/3b (attachement) conversion??
Exception in thread “main” java.lang.NullPointerException
at com.aspose.pdf.FileSpecification.setMIMEType(Unknown Source)
at com.aspose.pdf.internal.p694.z2.m20(Unknown Source)
at com.aspose.pdf.internal.p694.z2.m2(Unknown Source)
at com.aspose.pdf.internal.p694.z3.m12(Unknown Source)
at com.aspose.pdf.internal.p694.z2.m1(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)
at ConvertPDFToPDFAFormat.createPDFA3AndAttachXMLFile(ConvertPDFToPDFAFormat.java:72)
at ConvertPDFToPDFAFormat.main(ConvertPDFToPDFAFormat.java:17)
Our Java version is
java version “1.6.0_151”
Java™ SE Runtime Environment (build 1.6.0_151-b31)
Java HotSpot™ Client VM (build 20.151-b31, mixed mode, sharing)
Sample Java code we are using…
import com.aspose.pdf.ConvertErrorAction;
import com.aspose.pdf.Document;
import com.aspose.pdf.FileSpecification;
import com.aspose.pdf.PdfFormat;
//import com.aspose.ms.System.*;
public class ConvertPDFToPDFAFormat {
public static void main(String[] args) {
//pdfTopdfA1bConversion();
//pdfTopdfA3bConversion();
//pdfTopdfA3aConversion();
//pdfTopdfA2aConversion();
createPDFA3AndAttachXMLFile();
}
// public static void pdfTopdfA1bConversion() {
// String myDir = “pathToDir”;
// // Open document
// Document pdfDocument = new Document(myDir + “input.pdf”);
// // Convert to PDF/A compliant document
// pdfDocument.validate(“Validation_log.xml”, PdfFormat.PDF_A_1B);
// pdfDocument.convert(“Conversion_log.xml”, PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
// // Save updated document
// pdfDocument.save(myDir + “output.pdf”);
// }
//
// public static void pdfTopdfA3bConversion() {
// String myDir = “pathToDir”;
// // Open document
// Document doc = new Document(myDir + “input.pdf”);
// // Convert to PDF/A3 compliant document
// doc.convert(“file.log”, PdfFormat.PDF_A_3B, ConvertErrorAction.Delete);
// // Save resultant document
// doc.save(myDir + “output.pdf”);
// }
//
// public static void pdfTopdfA3aConversion() {
// String myDir = “pathToDir”;
// // Open document
// Document doc = new Document(myDir + “input.pdf”);
// // Convert to PDF/A3 compliant document
// doc.convert(“file.log”, PdfFormat.PDF_A_3A, ConvertErrorAction.Delete);
// // Save resultant document
// doc.save(myDir + “output.pdf”);
// }
//
// public static void pdfTopdfA2aConversion() {
// String myDir = “pathToDir”;
// // Open document
// Document doc = new Document(myDir + “input.pdf”);
// // Convert to PDF/A2_a compliant document
// doc.convert(“file.log”, PdfFormat.PDF_A_2A, ConvertErrorAction.Delete);
// // Save resultant document
// doc.save(myDir + “output.pdf”);
// }
public static void createPDFA3AndAttachXMLFile() {
String myDir = "/u01/oracle/devc/comn/java/oracle/apps/xxdomi/aspose";
// instantiate Document instance
Document doc = new Document();
// add page to PDF file
doc.getPages().add();
// load XML file
FileSpecification fileSpecification = new FileSpecification(myDir + "attachment.xml", "Sample xml file");
// Add attachment to document's attachment collection
doc.getEmbeddedFiles().add(fileSpecification);
// perform PDF/A_3a conversion
doc.convert(myDir + "log.xml", PdfFormat./*PDF_A_3A or */PDF_A_3B , ConvertErrorAction.Delete);
// save final PDF file
doc.save(myDir + "35064981_PDFA_3A.pdf");
//system.out.println("Hello World!");
}
}
after assigning file name as an input getting below error message
Exception in thread “main” class com.aspose.pdf.internal.p391.z87: At most 4 elements (for any collection) can be viewed in evaluation mode.
com.aspose.pdf.ADocument.m1(Unknown Source)
com.aspose.pdf.PageCollection.m1(Unknown Source)
com.aspose.pdf.PageCollection.get_Item(Unknown Source)
com.aspose.pdf.PageCollection.m1(Unknown Source)
com.aspose.pdf.PageCollection.add(Unknown Source)
com.aspose.pdf.PageCollection.add(Unknown Source)
ConvertPDFToPDFAFormat.createPDFA3AndAttachXMLFile(ConvertPDFToPDFAFormat.java:66)
ConvertPDFToPDFAFormat.main(ConvertPDFToPDFAFormat.java:17)
at com.aspose.pdf.ADocument.m1(Unknown Source)
at com.aspose.pdf.PageCollection.m1(Unknown Source)
at com.aspose.pdf.PageCollection.get_Item(Unknown Source)
at com.aspose.pdf.PageCollection.m1(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at ConvertPDFToPDFAFormat.createPDFA3AndAttachXMLFile(ConvertPDFToPDFAFormat.java:66)
at ConvertPDFToPDFAFormat.main(ConvertPDFToPDFAFormat.java:17)
If this is licensing issue, I got temporary licensing but not sure how to use it in Standalone Java .
Could you tell how can I use temporary license in my program
after further research on site , I used below code to set Temporary license but getting license not found… I have kept license file in PDF/Resourese/ directory…in license.setLicense(“Aspose.Pdf.Java.lic”) do I need to give entire path??
exception I am getting as below:
java.lang.Exception: Cannot find license ‘/u01/oracle/devc/comn/java/com/aspose/pdf/resources/Aspose.Pdf.Java.lic.xml’.
at com.aspose.pdf.z50.m3(Unknown Source)
at com.aspose.pdf.z50.m1(Unknown Source)
at com.aspose.pdf.License.setLicense(Unknown Source)
at ConvertPDFToPDFAFormat.main(ConvertPDFToPDFAFormat.java:16)
public class ConvertPDFToPDFAFormat {
public static void main(String[] args) {
try{
com.aspose.pdf.License license = new com.aspose.pdf.License();
license.setLicense("Aspose.Pdf.Java.lic");
//license.setLicense(new java.io.FileInputStream("Aspose.Pdf.Java.lic"));
if (com.aspose.pdf.Document.isLicensed()) {
System.out.println("License is Set!");
createPDFA3AndAttachXMLFile();
}
else
{
System.out.println("License is NOT Set!");
}
}
catch (Exception ex)
{
System.out.println("License is NOT Set!");
ex.printStackTrace();
}
}
Pl ignore above messages …after resolving file name I am getting below error message…
java.lang.IllegalStateException: The license is not valid for this product. For free technical support, please post this error and the file in the Aspose.Pdf Forums Aspose.PDF Product Family - Free Support Forum - aspose.com
at com.aspose.pdf.z50.m1(Unknown Source)
at com.aspose.pdf.License.setLicense(Unknown Source)
at ConvertPDFToPDFAFormat.main(ConvertPDFToPDFAFormat.java:17)
We are using ASPOSE PDF for JAVA 10.6…1
We apologize for the delayed response.
We have gone through every message you posted in this forum thread and would like to share with you that please try to use latest available version of the API i.e. Aspose.PDF for Java 20.10. The older versions have a lot of discontinued Classes and Methods and we are not providing support against the issues in older versions if they do not exist in the latest one.
As per our suggestion and request, please try using 20.10 version of the API with a Temporary license and let us know in case you still face any issues.
Hi Asad,
With JAR20.10 we are getting below error message while compiling
bad class file: /u01/oracle/devc/comn/java/com/aspose/pdf/ConvertErrorAction.cla ss
class file has wrong version 52.0, should be 50.0
Please remove or make sure it appears in the correct subdirectory of the classpa th.
import com.aspose.pdf.ConvertErrorAction;
we can’t ugrade our JDK to use new version. Pl provide the license that works for JDK 12 or JDK 10.1 which support conversion of PDF to PDF A3/b .
sorry not JDK 12 -Aspose PDF for JAVA 12 or JAVA 10.1.0
The version which you want to use is quite old and a lot of features are not included in that. Also, it has discontinued classes and method for which we are not providing any support. In case of any missing feature or issue while using older version, you would not be able to get it resolved unless you upgraded to the latest version. However, if you still want to use older version, you can request a license in Purchase forum where you will be assisted accordingly.
Furthermore, would you please share which JDK version are you using? Also, please share your sample PDF with us. We will test the scenario with the latest version of the API in our environment and address it accordingly.