@@ -206,4 +206,66 @@ void testPageTextSchema() throws XmpParsingException
206206 Assertions .assertEquals ("adobe:docid:indd:db084a4d-dbb2-11dc-ac34-beb3cc4028ec" , xmpMediaManagementSchema .getDocumentID ());
207207 Assertions .assertEquals ("adobe:docid:indd:fa7c6589-9f4a-11dc-9641-af983df728d7" , derivedFromProperty .getDocumentID ());
208208 }
209+
210+ /**
211+ * PDFBOX-3882: Test PageTextSchema with dimensions mixed as children or attributes.
212+ *
213+ * @throws XmpParsingException
214+ */
215+ @ Test
216+ void testPageTextSchema2 () throws XmpParsingException
217+ {
218+ String s = "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
219+ "<?xpacket begin=\" \" id=\" W5M0MpCehiHzreSzNTczkc9d\" ?>\n " +
220+ "<x:xmpmeta xmlns:x=\" adobe:ns:meta/\" >\n " +
221+ " <rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
222+ " <rdf:Description xmlns:xmpTPg=\" http://ns.adobe.com/xap/1.0/t/pg/\" " +
223+ " xmlns:stDim=\" http://ns.adobe.com/xap/1.0/sType/Dimensions#\" " +
224+ " rdf:about=\" \" >\n " +
225+ " <xmpTPg:MaxPageSize>\n " +
226+ " <rdf:Description stDim:w=\" 4\" stDim:h=\" 3\" >\n " +
227+ " <stDim:unit>inch</stDim:unit>\n " +
228+ " </rdf:Description>\n " +
229+ " </xmpTPg:MaxPageSize>\n " +
230+ " <xmpTPg:NPages>7</xmpTPg:NPages>\n " +
231+ " </rdf:Description>\n " +
232+ " </rdf:RDF>\n " +
233+ "</x:xmpmeta><?xpacket end=\" r\" ?>" ;
234+ DomXmpParser xmpParser = new DomXmpParser ();
235+ XMPMetadata xmp = xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 ));
236+ XMPPageTextSchema pageTextSchema = xmp .getPageTextSchema ();
237+ DimensionsType dim = (DimensionsType ) pageTextSchema .getProperty (XMPPageTextSchema .MAX_PAGE_SIZE );
238+ Assertions .assertEquals ("DimensionsType{4.0 x 3.0 inch}" , dim .toString ());
239+ Assertions .assertEquals ("[NPages=IntegerType:7]" , pageTextSchema .getProperty (XMPPageTextSchema .N_PAGES ).toString ());
240+ }
241+
242+ /**
243+ * PDFBOX-3882: Test PageTextSchema with dimensions as attributes only.
244+ *
245+ * @throws XmpParsingException
246+ */
247+ @ Test
248+ void testPageTextSchema3 () throws XmpParsingException
249+ {
250+ String s = "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
251+ "<?xpacket begin=\" \" id=\" W5M0MpCehiHzreSzNTczkc9d\" ?>\n " +
252+ "<x:xmpmeta xmlns:x=\" adobe:ns:meta/\" >\n " +
253+ " <rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
254+ " <rdf:Description xmlns:xmpTPg=\" http://ns.adobe.com/xap/1.0/t/pg/\" " +
255+ " xmlns:stDim=\" http://ns.adobe.com/xap/1.0/sType/Dimensions#\" " +
256+ " rdf:about=\" \" >\n " +
257+ " <xmpTPg:MaxPageSize>\n " +
258+ " <rdf:Description stDim:w=\" 4\" stDim:h=\" 3\" stDim:unit=\" inch\" />\n " +
259+ " </xmpTPg:MaxPageSize>\n " +
260+ " <xmpTPg:NPages>7</xmpTPg:NPages>\n " +
261+ " </rdf:Description>\n " +
262+ " </rdf:RDF>\n " +
263+ "</x:xmpmeta><?xpacket end=\" r\" ?>" ;
264+ DomXmpParser xmpParser = new DomXmpParser ();
265+ XMPMetadata xmp = xmpParser .parse (s .getBytes (StandardCharsets .UTF_8 ));
266+ XMPPageTextSchema pageTextSchema = xmp .getPageTextSchema ();
267+ DimensionsType dim = (DimensionsType ) pageTextSchema .getProperty (XMPPageTextSchema .MAX_PAGE_SIZE );
268+ Assertions .assertEquals ("DimensionsType{4.0 x 3.0 inch}" , dim .toString ());
269+ Assertions .assertEquals ("[NPages=IntegerType:7]" , pageTextSchema .getProperty (XMPPageTextSchema .N_PAGES ).toString ());
270+ }
209271}
0 commit comments