Skip to content

Commit 4347293

Browse files
committed
Remove problematic metadata from form test and add test for it
DEVSIX-1870
1 parent 46dbf9c commit 4347293

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

kernel/src/test/java/com/itextpdf/kernel/pdf/XMPMetadataTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ This file is part of the iText (R) project.
6363

6464
import org.junit.Assert;
6565
import org.junit.BeforeClass;
66+
import org.junit.Ignore;
6667
import org.junit.Test;
6768
import org.junit.experimental.categories.Category;
6869

@@ -207,6 +208,45 @@ public void createEmptyDocumentWithAbcXmp() throws IOException, XMPException {
207208
reader.close();
208209
}
209210

211+
@Test
212+
@Ignore("DEVSIX-1899: fails in .NET passes in Java")
213+
public void customXmpTest() throws IOException, InterruptedException {
214+
String xmp = "<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' bytes='770'?>\n" +
215+
"\n" +
216+
"<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n" +
217+
" xmlns:iX='http://ns.adobe.com/iX/1.0/'>\n" +
218+
"\n" +
219+
" <rdf:Description about=''\n" +
220+
" xmlns='http://ns.adobe.com/pdf/1.3/'\n" +
221+
" xmlns:pdf='http://ns.adobe.com/pdf/1.3/'>\n" +
222+
" <pdf:ModDate>2001-03-28T15:17:00-08:00</pdf:ModDate>\n" +
223+
" <pdf:CreationDate>2001-03-28T15:19:45-08:00</pdf:CreationDate>\n" +
224+
" </rdf:Description>\n" +
225+
"\n" +
226+
" <rdf:Description about=''\n" +
227+
" xmlns='http://ns.adobe.com/xap/1.0/'\n" +
228+
" xmlns:xap='http://ns.adobe.com/xap/1.0/'>\n" +
229+
" <xap:ModifyDate>2001-03-28T15:17:00-08:00</xap:ModifyDate>\n" +
230+
" <xap:CreateDate>2001-03-28T15:19:45-08:00</xap:CreateDate>\n" +
231+
" <xap:MetadataDate>2001-03-28T15:17:00-08:00</xap:MetadataDate>\n" +
232+
" </rdf:Description>\n" +
233+
"\n" +
234+
"</rdf:RDF>\n" +
235+
"<?xpacket end='r'?>";
236+
String outPath = destinationFolder + "customXmp.pdf";
237+
String cmpPath = sourceFolder + "cmp_customXmp.pdf";
238+
239+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPath));
240+
PdfPage page = pdfDoc.addNewPage();
241+
page.flush();
242+
pdfDoc.setXmpMetadata(xmp.getBytes(StandardCharsets.ISO_8859_1));
243+
pdfDoc.close();
244+
245+
CompareTool compareTool = new CompareTool();
246+
Assert.assertNull(compareTool.compareByContent(outPath, cmpPath, destinationFolder, "diff_customXmp_"));
247+
Assert.assertNull(compareTool.compareDocumentInfo(outPath, cmpPath));
248+
}
249+
210250
private byte[] removeAlwaysDifferentEntries(byte[] cmpBytes) throws XMPException {
211251
XMPMeta xmpMeta = XMPMetaFactory.parseFromBuffer(cmpBytes);
212252

Binary file not shown.

0 commit comments

Comments
 (0)