|
28 | 28 | import java.util.List; |
29 | 29 |
|
30 | 30 | import org.apache.xmpbox.XMPMetadata; |
| 31 | +import org.apache.xmpbox.schema.PDFAIdentificationSchema; |
31 | 32 | import org.apache.xmpbox.schema.PhotoshopSchema; |
32 | 33 | import org.apache.xmpbox.schema.XMPMediaManagementSchema; |
33 | 34 | import org.apache.xmpbox.schema.XMPPageTextSchema; |
34 | 35 | import org.apache.xmpbox.schema.XMPSchema; |
35 | 36 | import org.apache.xmpbox.type.AbstractField; |
36 | 37 | import org.apache.xmpbox.type.ArrayProperty; |
| 38 | +import org.apache.xmpbox.type.BadFieldValueException; |
37 | 39 | import org.apache.xmpbox.type.DefinedStructuredType; |
38 | 40 | import org.apache.xmpbox.type.DimensionsType; |
39 | 41 | import org.apache.xmpbox.type.PDFASchemaType; |
@@ -405,4 +407,100 @@ void testPDFBox3882_2() throws XmpParsingException |
405 | 407 | // xmpMediaManagementSchema.getDerivedFromProperty() doesn't work. |
406 | 408 | // However the PDFLib XMP validator considers this file to be invalid, so lets not bother more |
407 | 409 | } |
| 410 | + |
| 411 | + /** |
| 412 | + * PDFBOX-5292: Test whether inline extension schema is detected. |
| 413 | + * |
| 414 | + * @throws XmpParsingException |
| 415 | + */ |
| 416 | + @Test |
| 417 | + void testPDFBox5292() throws XmpParsingException, BadFieldValueException |
| 418 | + { |
| 419 | + String s = "<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" + |
| 420 | + "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.6-c015 84.159810, 2016/09/10-02:41:30 \">\n" + |
| 421 | + " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" + |
| 422 | + " <rdf:Description rdf:about=\"\"\n" + |
| 423 | + " xmlns:xmp=\"http://ns.adobe.com/xap/1.0/\"\n" + |
| 424 | + " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" + |
| 425 | + " xmlns:pdf=\"http://ns.adobe.com/pdf/1.3/\"\n" + |
| 426 | + " xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\"\n" + |
| 427 | + " xmlns:pdfaExtension=\"http://www.aiim.org/pdfa/ns/extension/\"\n" + |
| 428 | + " xmlns:pdfaSchema=\"http://www.aiim.org/pdfa/ns/schema#\"\n" + |
| 429 | + " xmlns:pdfaProperty=\"http://www.aiim.org/pdfa/ns/property#\"\n" + |
| 430 | + " xmlns:example=\"http://ns.example.org/default/1.0/\">\n" + |
| 431 | + " <xmp:CreateDate>2021-05-21T11:42:49+01:00</xmp:CreateDate>\n" + |
| 432 | + " <xmp:ModifyDate>2021-05-21T11:47:16+02:00</xmp:ModifyDate>\n" + |
| 433 | + " <xmp:MetadataDate>2021-05-21T11:47:16+02:00</xmp:MetadataDate>\n" + |
| 434 | + " <dc:format>application/pdf</dc:format>\n" + |
| 435 | + " <dc:title>\n" + |
| 436 | + " <rdf:Alt>\n" + |
| 437 | + " <rdf:li xml:lang=\"x-default\">Inline XMP Extension PoC</rdf:li>\n" + |
| 438 | + " </rdf:Alt>\n" + |
| 439 | + " </dc:title>\n" + |
| 440 | + " <dc:creator>\n" + |
| 441 | + " <rdf:Seq>\n" + |
| 442 | + " <rdf:li>DSO</rdf:li>\n" + |
| 443 | + " </rdf:Seq>\n" + |
| 444 | + " </dc:creator>\n" + |
| 445 | + " <dc:description>\n" + |
| 446 | + " <rdf:Alt>\n" + |
| 447 | + " <rdf:li xml:lang=\"x-default\">Inline XMP Extension PoC</rdf:li>\n" + |
| 448 | + " </rdf:Alt>\n" + |
| 449 | + " </dc:description>\n" + |
| 450 | + " <pdf:Keywords/>\n" + |
| 451 | + " <pdfaid:part>2</pdfaid:part>\n" + |
| 452 | + " <pdfaid:conformance>A</pdfaid:conformance>\n" + |
| 453 | + " <example:Data>Example</example:Data>\n" + |
| 454 | + " <pdfaExtension:schemas>\n" + |
| 455 | + " <rdf:Bag>\n" + |
| 456 | + " <rdf:li rdf:parseType=\"Resource\">\n" + |
| 457 | + " <pdfaSchema:schema>Simple Schema</pdfaSchema:schema>\n" + |
| 458 | + " <pdfaSchema:namespaceURI>http://ns.example.org/default/1.0/</pdfaSchema:namespaceURI>\n" + |
| 459 | + " <pdfaSchema:prefix>example</pdfaSchema:prefix>\n" + |
| 460 | + " <pdfaSchema:property>\n" + |
| 461 | + " <rdf:Seq>\n" + |
| 462 | + " <rdf:li rdf:parseType=\"Resource\">\n" + |
| 463 | + " <pdfaProperty:name>Data</pdfaProperty:name>\n" + |
| 464 | + " <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n" + |
| 465 | + " <pdfaProperty:category>internal</pdfaProperty:category>\n" + |
| 466 | + " <pdfaProperty:description>Example Data</pdfaProperty:description>\n" + |
| 467 | + " </rdf:li>\n" + |
| 468 | + " </rdf:Seq>\n" + |
| 469 | + " </pdfaSchema:property>\n" + |
| 470 | + " </rdf:li>\n" + |
| 471 | + " <rdf:li rdf:parseType=\"Resource\">\n" + |
| 472 | + " <pdfaSchema:namespaceURI>http://www.aiim.org/pdfa/ns/id/</pdfaSchema:namespaceURI>\n" + |
| 473 | + " <pdfaSchema:prefix>pdfaid</pdfaSchema:prefix>\n" + |
| 474 | + " <pdfaSchema:schema>PDF/A ID Schema</pdfaSchema:schema>\n" + |
| 475 | + " <pdfaSchema:property>\n" + |
| 476 | + " <rdf:Seq>\n" + |
| 477 | + " <rdf:li rdf:parseType=\"Resource\">\n" + |
| 478 | + " <pdfaProperty:category>internal</pdfaProperty:category>\n" + |
| 479 | + " <pdfaProperty:description>Part of PDF/A standard</pdfaProperty:description>\n" + |
| 480 | + " <pdfaProperty:name>part</pdfaProperty:name>\n" + |
| 481 | + " <pdfaProperty:valueType>Integer</pdfaProperty:valueType>\n" + |
| 482 | + " </rdf:li>\n" + |
| 483 | + " <rdf:li rdf:parseType=\"Resource\">\n" + |
| 484 | + " <pdfaProperty:category>internal</pdfaProperty:category>\n" + |
| 485 | + " <pdfaProperty:description>Conformance level of PDF/A standard</pdfaProperty:description>\n" + |
| 486 | + " <pdfaProperty:name>conformance</pdfaProperty:name>\n" + |
| 487 | + " <pdfaProperty:valueType>Text</pdfaProperty:valueType>\n" + |
| 488 | + " </rdf:li>\n" + |
| 489 | + " </rdf:Seq>\n" + |
| 490 | + " </pdfaSchema:property>\n" + |
| 491 | + " </rdf:li>\n" + |
| 492 | + " </rdf:Bag>\n" + |
| 493 | + " </pdfaExtension:schemas>\n" + |
| 494 | + " </rdf:Description>\n" + |
| 495 | + " </rdf:RDF>\n" + |
| 496 | + "</x:xmpmeta>\n" + |
| 497 | + "\n" + |
| 498 | + "<?xpacket end=\"w\"?>"; |
| 499 | + DomXmpParser xmpParser = new DomXmpParser(); |
| 500 | + XMPMetadata xmp = xmpParser.parse(s.getBytes(StandardCharsets.UTF_8)); |
| 501 | + PDFAIdentificationSchema pdfaIdSchema = xmp.getPDFAIdentificationSchema(); |
| 502 | + assertEquals(2, pdfaIdSchema.getPart()); |
| 503 | + String dataValue = xmp.getSchema("http://ns.example.org/default/1.0/").getUnqualifiedTextPropertyValue("Data"); |
| 504 | + assertEquals("Example", dataValue); |
| 505 | + } |
408 | 506 | } |
0 commit comments