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

@nbopanna

Yes, Aspose.PDF supports creating Tagged PDFs as well as convert normal PDF to Tagged/PDF/UA document.

Document doc = new Document(dataDir + "Original.pdf");
doc.convert(dataDir + "log.xml", PdfFormat.PDF_UA_1, ConvertErrorAction.Delete);
doc.save(dataDir + "Converted.pdf");

Furthermore, in order to create a valid ZUGFerd PDF file with XML invoice attachment, you need to attach a compatible XML invoice that should follow a specific format. We tested the file shared by you and found that it was not a compatible document. 2020-12-03_00-10-20.png (37.2 KB)

Please also check below-attached files which are a valid ZUGFerd PDF and a compatible XML invoice.

38578.pdf (11.2 KB)
zugferd-invoice.zip (4.7 KB)

35064981_PDFA_3A.pdf (128.1 KB)

10527899ZUGFerd.pdf (234.1 KB)

Can you validate attached ZUGFeRD file …Is xml is in right format or not.

@nbopanna

We are checking this and will get back to you soon.

@nbopanna

The document is a valid ZUGFerd.

Hi Asad,

any update on JDK 1.6 version of ASPOSE??
I thought I can creat it as java object in oracle db but oracle JVM is 1.7 ,unfortunately [Aspose.PDF for Java 20.11] jar is not working.

So we need either JDK 1.6 or JDK 1.7

Neelima

@nbopanna

Aspose.PDF for Java is also released for JDK 1.7 separately. Please download it from the link given below and let us know if issue occurs with JDK 1.7 as well.

aspose-pdf-20.11-jdk17.jar

We would like to share with you that related ticket PDFJAVA-39966 has been resolved and its fix will be included in Aspose.PDF for Java 20.12. You will surely receive a notification as soon as the release is available.

Hi Asad,

If PDF JAVA-39966 is fixed then could you release it to Aspose.PDF Java 20.11 JDK1.6???

For JDK1.7 also same issue with all com/aspose/pdf/internal classes.

"ORA-29552: verification warning: java.lang.UnsupportedClassVersionError: com/aspose/pdf/internal/l27v/l1j$lI (Unsupported major.minor version 52.0)
"

@nbopanna

We regret that we cannot fix this issue in the version which has already been out for download. We have included the fix of the error in upcoming release which is yet to be published.

Thanks for your feedback. We will further review it and let you know about the updates in this regard.

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

Hi,

Thank you for the update.Is Aspose PDF for JAVA 20.12 supports digital signature and verification too?? If so could you send me sample code for the same

Hi,

I am able to get the sample code from Github but I am getting below error message while I am compiling . I am using aspose-pdf-20.12-jdk16.jar . Pl advise

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)
pdfFile.certify(1, “Signature Reason”, “Contact”, “Location”, true, rect,docMdpSignature );

My code:

import com.aspose.pdf.*;

public class AsposeTestDigSign {
private String dataDir = “/u01/oracle/devc/comn/java/oracle/apps/xxdomi/aspose/files/”;
private String concDir = “/u01/oracle/devc/comn/admin/out/DEVC_dps-ap-erpdev2/”;

    public AsposeTestDigSign(){

}

public static void main(String[] args) throws Exception {

    for (String s: args){
    new AsposeTest().Run(s);
    }
 }

    public void Run(String f) throws Exception{
            License lic = new License();
            lic.setLicense(dataDir + "Aspose.PDF.Java.lic");

            attachDigSign(f);

            System.out.println("Done16..");
    }

    public void attachDigSign(String f) {
    //      Document doc = new Document(concDir+f);
            com.aspose.pdf.facades.PdfFileSignature pdfFile = new com.aspose.pdf.facades.PdfFileSignature();
            pdfFile.bindpdf(concDir+f);

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

            DocMDPSignature docMdpSignature = new DocMDPSignature(pkcs, DocMDPAccessPermissions.FillingInForms);
            Rectangle rect = new Rectangle(100, 600, 400, 100);
            // Set signature appearance
            pdfFile.setSignatureAppearance("aspose-logo.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");
    }

@nbopanna

Could you please share your sample PDF document and .pfx file with us so that we can also test the scenario in our environment and address it accordingly.

35064981.pdf (35.2 KB)

ThomasMiller.zip (2.6 KB)

@nbopanna

You have been noticing the issue because of not using correct Rectangle Class. Please check following code snippet which we used for the testing with Aspose.PDF for Java 21.1:

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

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

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 + "aspose.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");

However, we faced another exception i.e.

class com.aspose.pdf.internal.ms.System.Security.Cryptography.l0y: Invalid MAC - file may have been tampered! ---> class com.aspose.pdf.internal.l63f.lk: Invalid MAC - file may have been tampered!

Therefore, we have logged an issue as PDFJAVA-40117 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi Team,

We are trying to create digital Signature through your code in the PDF document but while compiling your code we are facing below error.
Please check and suggest on this Error.

For you reference i have attached sample code pack as well.

--------------------------------------Error Message-------------------------------------------------------
dps-ap-erpdev2.dps.local:DEVC:appldevc>javac AsposeTest1.java
AsposeTest1.java:47: cannot find symbol
symbol : method certify(int,java.lang.String,java.lang.String,java.lang.String,boolean,com.aspose.pdf.Rectangle,com.aspose.pdf.DocMDPSignature)
location: class com.aspose.pdf.DocMDPSignature
DocMDPSignature.certify(1, “SignatureReason”, “Contact”, “location”, true, rect, docMdpSignature);
^
1 error
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);
^
1 error
dps-ap-erpdev2.dps.local:DEVC:appldevc>

Regards,
Srinivasu

@nbopanna

We could not find any attached source in your post. Please make sure to attach sample PDF and code snippet for our reference so that we can test the scenario in our environment and address it accordingly.

Hi,

Please find the attached sample code and PDF file and pfx file for your reference.

Sample code and PDF file and pfx.zip (33.9 KB)

Regards,
Srinivasu Y