Skip to Content

Removing the PDF/A schema using the PDF Library Java and .NET interfaces

Estimated Reading Time: 1 Minutes

You can change the XMP metadata in a PDF/A compliant document to remove the PDF/A schema from that document. This will convert it into a non-conforming file.

Add the code blocks provided below to your own application to edit a PDF document and make it non-conforming as a PDF/A file.

.NET code:

  //remove PDF/A-1b markers from XMPMetadata

  var XMPmetadata = doc.XMPMetadata;
  Console.WriteLine(XMPmetadata);
  string[] pdfastrs = new string[] { "xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\"", "pdfaid:part=\"1\"", "pdfaid:conformance=\"B\"" };
  foreach (string str in pdfastrs)
    {
    int idx = XMPmetadata.IndexOf(str);
    if (idx > 0)
       XMPmetadata = XMPmetadata.Remove(idx, str.Length);
    }
  doc.XMPMetadata = XMPmetadata;
  Console.WriteLine(XMPmetadata);

 

Java code:

  //remove PDF/A-1b markers from XMPMetadata

  String XMPmetadata = doc.getXMPMetadata();
  System.out.println(XMPmetadata);
  String[] pdfastrs = new String[] { "xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\"", "pdfaid:part=\"1\"", "pdfaid:conformance=\"B\"" };
  for(String str : pdfastrs)
     XMPmetadata = XMPmetadata.replace(str, "");
  doc.setXMPMetadata(XMPmetadata);
  System.out.println(XMPmetadata);
Removing the PDF/A schema using the PDF Library Java and .NET interfaces
  • COMMENT