File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
main/java/com/itextpdf/kernel/pdf
test/java/com/itextpdf/kernel/pdf Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1905,7 +1905,7 @@ protected void addCustomMetadataExtensions(XMPMeta xmpMeta) {
1905
1905
protected void updateXmpMetadata () {
1906
1906
try {
1907
1907
// We add PDF producer info in any case, and the valid way to do it for PDF 2.0 in only in metadata, not in the info dictionary.
1908
- if (writer .properties .addXmpMetadata || pdfVersion .compareTo (PdfVersion .PDF_2_0 ) >= 0 ) {
1908
+ if (xmpMetadata != null || writer .properties .addXmpMetadata || pdfVersion .compareTo (PdfVersion .PDF_2_0 ) >= 0 ) {
1909
1909
setXmpMetadata (updateDefaultXmpMetadata ());
1910
1910
}
1911
1911
} catch (XMPException e ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ This file is part of the iText (R) project.
42
42
*/
43
43
package com .itextpdf .kernel .pdf ;
44
44
45
+ import com .itextpdf .io .LogMessageConstant ;
45
46
import com .itextpdf .kernel .utils .CompareTool ;
46
47
import com .itextpdf .kernel .xmp .PdfConst ;
47
48
import com .itextpdf .kernel .xmp .XMPConst ;
@@ -51,6 +52,8 @@ This file is part of the iText (R) project.
51
52
import com .itextpdf .kernel .xmp .XMPUtils ;
52
53
import com .itextpdf .kernel .xmp .options .SerializeOptions ;
53
54
import com .itextpdf .test .ExtendedITextTest ;
55
+ import com .itextpdf .test .annotations .LogMessage ;
56
+ import com .itextpdf .test .annotations .LogMessages ;
54
57
import com .itextpdf .test .annotations .type .IntegrationTest ;
55
58
56
59
import java .io .ByteArrayInputStream ;
@@ -179,6 +182,9 @@ public void emptyDocumentWithXmpAppendMode02() throws Exception {
179
182
180
183
181
184
@ Test
185
+ @ LogMessages (messages = {
186
+ @ LogMessage (messageTemplate = LogMessageConstant .EXCEPTION_WHILE_UPDATING_XMPMETADATA )
187
+ })
182
188
public void createEmptyDocumentWithAbcXmp () throws IOException , XMPException {
183
189
ByteArrayOutputStream fos = new ByteArrayOutputStream ();
184
190
PdfWriter writer = new PdfWriter (fos );
You can’t perform that action at this time.
0 commit comments