PDF to PDF A/3-b with attachment - standalone Java - Linux - JDK16 - ZUGFerD

@nbopanna

It seems like we have already addressed the issue related to processing of PDF file which you have now shared. The ticket PDFJAVA-40117 has been logged for this issue and we will surely inform you as soon as it is resolved. Please be patient and give us some time.

We are sorry for the inconvenience.

Hi Team,

Please let us know status on this error…
We have only one week license for checking on this.Please provide an update on this ASAP.

Regards,
Srinivasu

@nbopanna

We would like to share with you that the issue has been scheduled for a fix in 21.4 version of the API which will be released in April 2021. You will be notified once the fix is available.

We apologize for the inconvenience.

Hi Asad,

Could you please let us know the issue has been resolved? is this version 21.4 is available or still working on this issue.Please provide an update on this Please?

Regards
Srinivas

@nbopanna

The issue PDFJAVA*40117 has been fixed in 21.4v of the API which will be released at the end of this month. The exception occurred because the set password was incorrect. Aspose.PDF for java throws an incorrect exception. We fixed the message of exception in the 21.4 version.

Thank you for your update on this.

The issues you have found earlier (filed as PDFJAVA-40117) have been fixed in Aspose.PDF for Java 21.4.

Hi Asad,

Thanks for your update on this.
But we have downloaded the provided Aspose.PDF for Java 21.4 version and try to test the code but still we have seen same error.Please review the attached our sample code pack and update on this.

Regards,
SrinivasuSample code and pfx.zip (33.8 KB)

Hi Asad,

We are also facing the below error on PDF to PDF A/3-b logic,which was working without any issues earlier but now suddenly we have seen this error. could you please check on below error and update on this.And we are using aspose-pdf-20.12-jdk16.jar file for developing this project.please find the attached java code for your reference.

java AsposeTest XXDOMW_XML_RAXINV_SEL_INT _174775691_1.PDF
Exception in thread “main” java.lang.InternalError: Can’t connect to X11 window server using ‘dps-ap-erpdev1:1.0’ as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java :52)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:1 31)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:170)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi ronment.java:68)
at sun.awt.X11.XToolkit.(XToolkit.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:170)
at java.awt.Toolkit$2.run(Toolkit.java:832)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:824)
at com.aspose.pdf.internal.l58p.lI.lj(Unknown Source)
at com.aspose.pdf.internal.l58p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l58p.lI.(Unknown Source)
at com.aspose.pdf.internal.l55l.l1h.(Unknown Source)
at com.aspose.pdf.internal.l55l.ld.l0f(Unknown Source)
at com.aspose.pdf.Color.getBlack(Unknown Source)
at com.aspose.pdf.GraphInfo.(Unknown Source)
at com.aspose.pdf.Page.(Unknown Source)
at com.aspose.pdf.PageCollection.lI(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at AsposeTest.createPDFA3AndAttachXMLFile(AsposeTest.java:32)
at AsposeTest.Run(AsposeTest.java:24)
Regards,
Srinivasu PDF convert java code.zip (963 Bytes)

Regards,
Srinivasu

@nbopanna

Please note that the exception was occurring previously because the password you were using was incorrect for the .pfx file. We fixed the ticket and made the API throw a valid exception which now tells that the specified password is not correct. When we tested the scenario using 21.4v of the API and a different .pfx file with a valid password, the exception was not thrown and PDF was generated successfully.

Please make sure to use the 21.4 version of the API and if you still notice any issue, please share your sample PDF file along with the sample .xml file that you are using as an attachment. We will test the scenario in our environment and address it accordingly.

Hi Asad,

We are seeing the same error for both versions 21.4 and 20.12 while running the java code.last month we have been successfully running the pdf output with Zugfered xml attachmen with 20.12, but suddenly the code is not working and see the below error.Please find the attached code and pdf output.
Could you please check and update on this ASAP.


dps-ap-erpdev2.dps.local:DEVC:appldevc>javac AsposeTest.java
dps-ap-erpdev2.dps.local:DEVC:appldevc>java AsposeTest XXDOMW_XML_RAXINV_SEL_INT _177374421_1.PDF
Exception in thread “main” java.lang.InternalError: Can’t connect to X11 window server using ‘dps-ap-erpdev2:1.0’ as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$100(X11GraphicsEnvironment.java :52)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:155)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:1 31)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:170)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi ronment.java:68)
at sun.awt.X11.XToolkit.(XToolkit.java:87)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:170)
at java.awt.Toolkit$2.run(Toolkit.java:833)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:825)
at com.aspose.pdf.internal.l58p.lI.lj(Unknown Source)
at com.aspose.pdf.internal.l58p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l58p.lI.(Unknown Source)
at com.aspose.pdf.internal.l55l.l1h.(Unknown Source)
at com.aspose.pdf.internal.l55l.ld.l0f(Unknown Source)
at com.aspose.pdf.Color.getBlack(Unknown Source)
at com.aspose.pdf.GraphInfo.(Unknown Source)
at com.aspose.pdf.Page.(Unknown Source)
at com.aspose.pdf.PageCollection.lI(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at AsposeTest.createPDFA3AndAttachXMLFile(AsposeTest.java:32)
at AsposeTest.Run(AsposeTest.java:24)
at AsposeTest.main(AsposeTest.java:16)

Regards
Srinivasu Code Pack.zip (93.5 KB)

@nbopanna

Thanks for sharing the files.

We have tested the scenario in our environment while using Aspose.PDF for Java 21.4 and did not notice the exception that you shared. For your kind reference, an output PDF is also attached.
output.pdf (232.3 KB)

The issue seems like related to your specific environment. Could you please try to same scenario in a separate console application to see whether the issue is with the API or any other code routine of your existing application. If issue still happens, please share that console application with us so that we can also test it again in our environment and address it accordingly.

Hi Asad,

Thanks for the your update on this.
Yes this issue with our environment and now it has been fixed and now the code working for PAF A/3-b. But still we are seeing same error on Digital Signature code
even we have tested with valid .pfx password (i.e dominopfx).
Could you please check on this update on this. since your code is working in your environment without any issue ,could you please share your code so that we will check in our environment.
Please find the attached code pack along with .pfx file and below error message.

dps-ap-erpdev2.dps.local:DEVC:appldevc>javac AsposeTest1.java
AsposeTest1.java:47: certify(int,java.lang.String,java.lang.String,java.lang.String,boolean,java.awt.Rectangle,com.aspose.pdf.DocMDPSignature) in com.aspose.pdf.facades.PdfFileSignature cannot be applied to (int,java.lang.String,java.lang.String,java.lang.String,boolean,com.aspose.pdf.Rectangle,com.aspose.pdf.DocMDPSignature)
signature.certify(1, “SignatureReason”, “Contact”, “location”, true, rect, docMdpSignature);

Regards,
Srinivasu

code pack and .pfx file.zip (52.6 KB)

@nbopanna

We again tested the scenario with 21.4 version of the API and did not notice any issue. We used the same PFX file that you shared. Please check the below code snippet that we used for testing purposes.

com.aspose.pdf.facades.PdfFileSignature pdfFile = new com.aspose.pdf.facades.PdfFileSignature();
pdfFile.bindPdf(dataDir + "35064981_Digitally Signed PDF.pdf");

PKCS7 pkcs = new PKCS7(dataDir+"ThomasMiller.pfx", "dominopfx");

DocMDPSignature docMdpSignature = new DocMDPSignature(pkcs, DocMDPAccessPermissions.FillingInForms);
java.awt.Rectangle rect = new java.awt.Rectangle(100, 600, 400, 100);
// Set signature appearance
pdfFile.setSignatureAppearance(dataDir + "Test.png");
// Create any of the three signature types
pdfFile.certify(1, "Signature Reason", "Contact", "Location", true, rect, docMdpSignature);

// Save digitally signed PDF file
pdfFile.save(dataDir + "Digitally Signed PDF.pdf");

com.aspose.pdf.facades.PdfFileSignature pdfSignSingle = new com.aspose.pdf.facades.PdfFileSignature();
// Bind the source PDF by reading contents of Stream
pdfSignSingle.bindPdf(dataDir + "Digitally Signed PDF.pdf");
if (pdfSignSingle.isCertified()) {
 System.out.println("Certified");
} else {
 System.out.println("Not Certified");
}

Digitally Signed PDF.pdf (84.5 KB)

Can you please share a sample console application that is able to reproduce the same issue as you are facing. We will again test the scenario in our environment and address it accordingly.

Hi Asad,

Thank you very much your update now we can able to generate digital signature in the output file.

Now are facing another issue in the Zugfered PDF code, In our server the invoice xml file generated into text file with xml tags, we have referred the server file in the code for attaching the PDF output file , but our business expecting .xml file format of the attachment.

Could you please let us know whether we can convert the text file into .xml file format
for attaching the PDF output through your API?

In the below code the x variable the text file (i.e o177459624.out) stored and attached the PDF output file. but we need to save this file as ‘o177459624.xml’ instead of o177459624.out. could you please check the attached code and output file and suggest how we can save the .xml file format.

FileSpecification fileSpecification = new FileSpecification(concDirxml + x, “Sample xml file”);

Thank you very much for supporting so far on this…

Regards,
Srinivasu Pdf file and code pack.zip (193.1 KB)

@nbopanna

Aspose.PDF does not provide functionality to convert .txt to .xml. However, you can first save the o177459624.out file with desired extension i.e. .xml using the below code and then attach it with the PDF:

Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);

Please feel free to let us know in case you face any issue.

Hi Asad,

Thanks for the update on this.
We have another concern on Aspose digital signature code.
Currently our business is using .cer file instead .pfx for generating the digital signature , but we have tested the code with .pfx file. could you please confirm whether your API will it works for .cer file as well?
so that we will check with .cer file and proceed further on this.

Regards,
Srinivasu

@nbopanna

You can surely try using the *.cer files as long as they are valid certificates. Please feel free to let us know in case you face any issue.

Hi Asad,

Please confirm is the same version (i.e 21.4 version of the API) working for *.cer file as well as like pfx file which we have tested earlier ? if it will working in the same version could you please provide the sample code or suggest how we can test the code with *.cer file. and also please confirm the cost of license for digital signature API.

Regards,
Srinivasu

PKCS7 pkcs = new PKCS7(dataDir+"ThomasMiller.pfx", "dominopfx");