@@ -42,13 +42,16 @@ This file is part of the iText (R) project.
42
42
*/
43
43
package com .itextpdf .pdfa ;
44
44
45
+ import com .itextpdf .commons .utils .MessageFormatUtil ;
45
46
import com .itextpdf .forms .PdfAcroForm ;
47
+ import com .itextpdf .forms .PdfPageFormCopier ;
46
48
import com .itextpdf .forms .fields .PdfButtonFormField ;
47
49
import com .itextpdf .forms .fields .PdfChoiceFormField ;
48
50
import com .itextpdf .forms .fields .PdfFormField ;
49
51
import com .itextpdf .io .logs .IoLogMessageConstant ;
50
52
import com .itextpdf .io .font .PdfEncodings ;
51
53
import com .itextpdf .kernel .colors .ColorConstants ;
54
+ import com .itextpdf .kernel .exceptions .PdfException ;
52
55
import com .itextpdf .kernel .font .PdfFont ;
53
56
import com .itextpdf .kernel .font .PdfFontFactory ;
54
57
import com .itextpdf .kernel .font .PdfFontFactory .EmbeddingStrategy ;
@@ -59,6 +62,7 @@ This file is part of the iText (R) project.
59
62
import com .itextpdf .kernel .pdf .PdfDocument ;
60
63
import com .itextpdf .kernel .pdf .PdfName ;
61
64
import com .itextpdf .kernel .pdf .PdfOutputIntent ;
65
+ import com .itextpdf .kernel .pdf .PdfReader ;
62
66
import com .itextpdf .kernel .pdf .PdfString ;
63
67
import com .itextpdf .kernel .pdf .PdfWriter ;
64
68
import com .itextpdf .kernel .pdf .annot .PdfAnnotation ;
@@ -72,6 +76,7 @@ This file is part of the iText (R) project.
72
76
import com .itextpdf .layout .renderer .DrawContext ;
73
77
import com .itextpdf .layout .renderer .IRenderer ;
74
78
import com .itextpdf .layout .renderer .ParagraphRenderer ;
79
+ import com .itextpdf .pdfa .exceptions .PdfAConformanceException ;
75
80
import com .itextpdf .test .ExtendedITextTest ;
76
81
import com .itextpdf .test .annotations .LogMessage ;
77
82
import com .itextpdf .test .annotations .LogMessages ;
@@ -91,30 +96,30 @@ This file is part of the iText (R) project.
91
96
@ Category (IntegrationTest .class )
92
97
public class PdfAFormFieldTest extends ExtendedITextTest {
93
98
94
- public static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/" ;
95
- public static final String destinationFolder = "./target/test/com/itextpdf/pdfa/PdfAFormFieldTest/" ;
99
+ public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/pdfa/" ;
100
+ public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/pdfa/PdfAFormFieldTest/" ;
96
101
97
102
@ BeforeClass
98
103
public static void beforeClass () {
99
- createDestinationFolder (destinationFolder );
104
+ createDestinationFolder (DESTINATION_FOLDER );
100
105
}
101
106
102
107
@ Test
103
108
public void pdfAButtonFieldTest () throws Exception {
104
109
PdfDocument pdf ;
105
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
110
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
106
111
String file = "pdfAButtonField.pdf" ;
107
- String filename = destinationFolder + file ;
112
+ String filename = DESTINATION_FOLDER + file ;
108
113
pdf = new PdfADocument (
109
114
new PdfWriter (new FileOutputStream (filename )),
110
115
PdfAConformanceLevel .PDF_A_1B ,
111
116
new PdfOutputIntent ("Custom" , "" , "http://www.color.org" , "sRGB ICC preference" , is ));
112
117
113
118
PageSize pageSize = PageSize .LETTER ;
114
119
Document doc = new Document (pdf , pageSize );
115
- PdfFontFactory .register (sourceFolder + "FreeSans.ttf" , sourceFolder + "FreeSans.ttf" );
120
+ PdfFontFactory .register (SOURCE_FOLDER + "FreeSans.ttf" , SOURCE_FOLDER + "FreeSans.ttf" );
116
121
PdfFont font = PdfFontFactory .createFont (
117
- sourceFolder + "FreeSans.ttf" , EmbeddingStrategy .PREFER_EMBEDDED );
122
+ SOURCE_FOLDER + "FreeSans.ttf" , EmbeddingStrategy .PREFER_EMBEDDED );
118
123
119
124
PdfButtonFormField group = PdfFormField .createRadioGroup (pdf , "group" , "" , PdfAConformanceLevel .PDF_A_1B );
120
125
group .setReadOnly (true );
@@ -152,7 +157,8 @@ public void pdfAButtonFieldTest() throws Exception {
152
157
153
158
pdf .close ();
154
159
Assert .assertNull (
155
- new CompareTool ().compareByContent (filename , sourceFolder + "cmp/PdfAFormFieldTest/cmp_" + file , destinationFolder , "diff_" ));
160
+ new CompareTool ().compareByContent (filename , SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_" + file ,
161
+ DESTINATION_FOLDER , "diff_" ));
156
162
}
157
163
158
164
static class PdfAButtonFieldTestRenderer extends ParagraphRenderer {
@@ -206,10 +212,10 @@ public IRenderer getNextRenderer() {
206
212
@ Test
207
213
public void pdfA1DocWithPdfA1ButtonFieldTest () throws IOException , InterruptedException {
208
214
String name = "pdfA1DocWithPdfA1ButtonField" ;
209
- String fileName = destinationFolder + name + ".pdf" ;
210
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ButtonField.pdf" ;
215
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
216
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ButtonField.pdf" ;
211
217
212
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
218
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
213
219
214
220
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
215
221
@@ -225,17 +231,17 @@ public void pdfA1DocWithPdfA1ButtonFieldTest() throws IOException, InterruptedEx
225
231
226
232
pdfDoc .close ();
227
233
228
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
234
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
229
235
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
230
236
}
231
237
232
238
@ Test
233
239
public void pdfA1DocWithPdfA1CheckBoxFieldTest () throws IOException , InterruptedException {
234
240
String name = "pdfA1DocWithPdfA1CheckBoxField" ;
235
- String fileName = destinationFolder + name + ".pdf" ;
236
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1CheckBoxField.pdf" ;
241
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
242
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1CheckBoxField.pdf" ;
237
243
238
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
244
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
239
245
240
246
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
241
247
@@ -248,20 +254,20 @@ public void pdfA1DocWithPdfA1CheckBoxFieldTest() throws IOException, Interrupted
248
254
conformanceLevel ));
249
255
pdfDoc .close ();
250
256
251
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
257
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
252
258
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
253
259
}
254
260
255
261
@ Test
256
262
@ LogMessages (messages = {@ LogMessage (messageTemplate = IoLogMessageConstant .FIELD_VALUE_IS_NOT_CONTAINED_IN_OPT_ARRAY )})
257
263
public void pdfA1DocWithPdfA1ChoiceFieldTest () throws IOException , InterruptedException {
258
264
String name = "pdfA1DocWithPdfA1ChoiceField" ;
259
- String fileName = destinationFolder + name + ".pdf" ;
260
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf" ;
265
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
266
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ChoiceField.pdf" ;
261
267
262
- PdfFont fontFreeSans = PdfFontFactory .createFont (sourceFolder + "FreeSans.ttf" ,
268
+ PdfFont fontFreeSans = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" ,
263
269
"WinAnsi" , EmbeddingStrategy .FORCE_EMBEDDED );
264
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
270
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
265
271
266
272
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
267
273
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -276,20 +282,20 @@ public void pdfA1DocWithPdfA1ChoiceFieldTest() throws IOException, InterruptedEx
276
282
277
283
pdfDoc .close ();
278
284
279
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
285
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
280
286
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
281
287
}
282
288
283
289
@ Test
284
290
public void pdfA1DocWithPdfA1ComboBoxFieldTest () throws IOException , InterruptedException {
285
291
String name = "pdfA1DocWithPdfA1ComboBoxField" ;
286
- String fileName = destinationFolder + name + ".pdf" ;
287
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf" ;
292
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
293
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ComboBoxField.pdf" ;
288
294
289
- PdfFont fontCJK = PdfFontFactory .createFont (sourceFolder + "NotoSansCJKtc-Light.otf" ,
295
+ PdfFont fontCJK = PdfFontFactory .createFont (SOURCE_FOLDER + "NotoSansCJKtc-Light.otf" ,
290
296
PdfEncodings .IDENTITY_H , EmbeddingStrategy .FORCE_EMBEDDED );
291
297
292
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
298
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
293
299
294
300
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
295
301
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -302,21 +308,21 @@ public void pdfA1DocWithPdfA1ComboBoxFieldTest() throws IOException, Interrupted
302
308
303
309
pdfDoc .close ();
304
310
305
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
311
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
306
312
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
307
313
}
308
314
309
315
@ Test
310
316
@ LogMessages (messages = {@ LogMessage (messageTemplate = IoLogMessageConstant .MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD )})
311
317
public void pdfA1DocWithPdfA1ListFieldTest () throws IOException , InterruptedException {
312
318
String name = "pdfA1DocWithPdfA1ListField" ;
313
- String fileName = destinationFolder + name + ".pdf" ;
314
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf" ;
319
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
320
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1ListField.pdf" ;
315
321
316
- PdfFont fontFreeSans = PdfFontFactory .createFont (sourceFolder + "FreeSans.ttf" ,
322
+ PdfFont fontFreeSans = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" ,
317
323
"WinAnsi" , EmbeddingStrategy .FORCE_EMBEDDED );
318
324
319
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
325
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
320
326
321
327
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
322
328
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -335,20 +341,20 @@ public void pdfA1DocWithPdfA1ListFieldTest() throws IOException, InterruptedExce
335
341
336
342
pdfDoc .close ();
337
343
338
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
344
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
339
345
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
340
346
}
341
347
342
348
@ Test
343
349
public void pdfA1DocWithPdfA1PushButtonFieldTest () throws IOException , InterruptedException {
344
350
String name = "pdfA1DocWithPdfA1PushButtonField" ;
345
- String fileName = destinationFolder + name + ".pdf" ;
346
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1PushButtonField.pdf" ;
351
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
352
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1PushButtonField.pdf" ;
347
353
348
- PdfFont fontFreeSans = PdfFontFactory .createFont (sourceFolder + "FreeSans.ttf" ,
354
+ PdfFont fontFreeSans = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" ,
349
355
"WinAnsi" , EmbeddingStrategy .FORCE_EMBEDDED );
350
356
351
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
357
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
352
358
353
359
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
354
360
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -361,17 +367,17 @@ public void pdfA1DocWithPdfA1PushButtonFieldTest() throws IOException, Interrupt
361
367
362
368
pdfDoc .close ();
363
369
364
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
370
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
365
371
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
366
372
}
367
373
368
374
@ Test
369
375
public void pdfA1DocWithPdfA1RadioButtonFieldTest () throws IOException , InterruptedException {
370
376
String name = "pdfA1DocWithPdfA1RadioButtonField" ;
371
- String fileName = destinationFolder + name + ".pdf" ;
372
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1RadioButtonField.pdf" ;
377
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
378
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1RadioButtonField.pdf" ;
373
379
374
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
380
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
375
381
376
382
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
377
383
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -390,21 +396,21 @@ public void pdfA1DocWithPdfA1RadioButtonFieldTest() throws IOException, Interrup
390
396
391
397
pdfDoc .close ();
392
398
393
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
399
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
394
400
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
395
401
}
396
402
397
403
@ Test
398
404
public void pdfA1DocWithPdfA1TextFieldTest () throws IOException , InterruptedException {
399
405
String name = "pdfA1DocWithPdfA1TextField" ;
400
- String fileName = destinationFolder + name + ".pdf" ;
401
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1TextField.pdf" ;
406
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
407
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1TextField.pdf" ;
402
408
403
- PdfFont fontFreeSans = PdfFontFactory .createFont (sourceFolder + "FreeSans.ttf" ,
409
+ PdfFont fontFreeSans = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" ,
404
410
"WinAnsi" , EmbeddingStrategy .FORCE_EMBEDDED );
405
411
fontFreeSans .setSubset (false );
406
412
407
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
413
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
408
414
409
415
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
410
416
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -417,21 +423,21 @@ public void pdfA1DocWithPdfA1TextFieldTest() throws IOException, InterruptedExce
417
423
418
424
pdfDoc .close ();
419
425
420
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
426
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
421
427
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
422
428
}
423
429
424
430
@ Test
425
431
public void pdfA1DocWithPdfA1SignatureFieldTest () throws IOException , InterruptedException {
426
432
String name = "pdfA1DocWithPdfA1SignatureField" ;
427
- String fileName = destinationFolder + name + ".pdf" ;
428
- String cmp = sourceFolder + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1SignatureField.pdf" ;
433
+ String fileName = DESTINATION_FOLDER + name + ".pdf" ;
434
+ String cmp = SOURCE_FOLDER + "cmp/PdfAFormFieldTest/cmp_pdfA1DocWithPdfA1SignatureField.pdf" ;
429
435
430
- PdfFont fontFreeSans = PdfFontFactory .createFont (sourceFolder + "FreeSans.ttf" ,
436
+ PdfFont fontFreeSans = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" ,
431
437
"WinAnsi" , EmbeddingStrategy .FORCE_EMBEDDED );
432
438
fontFreeSans .setSubset (false );
433
439
434
- InputStream is = new FileInputStream (sourceFolder + "sRGB Color Space Profile.icm" );
440
+ InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
435
441
436
442
PdfAConformanceLevel conformanceLevel = PdfAConformanceLevel .PDF_A_1B ;
437
443
PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), conformanceLevel ,
@@ -444,7 +450,48 @@ public void pdfA1DocWithPdfA1SignatureFieldTest() throws IOException, Interrupte
444
450
445
451
pdfDoc .close ();
446
452
447
- Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , destinationFolder ));
453
+ Assert .assertNull (new CompareTool ().compareByContent (fileName , cmp , DESTINATION_FOLDER ));
448
454
Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
449
455
}
456
+
457
+ @ Test
458
+ // TODO: DEVSIX-3913 update this test after the ticket will be resolved
459
+ public void mergePdfADocWithFormTest () throws IOException {
460
+ String fileName = DESTINATION_FOLDER + "pdfADocWithTextFormField.pdf" ;
461
+ String mergedDocFileName = DESTINATION_FOLDER + "mergedPdfADoc.pdf" ;
462
+
463
+ try (InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
464
+ PdfADocument pdfDoc = new PdfADocument (new PdfWriter (fileName ), PdfAConformanceLevel .PDF_A_1B ,
465
+ new PdfOutputIntent ("Custom" , "" ,
466
+ "http://www.color.org" , "sRGB ICC preference" , is ));
467
+ Document doc = new Document (pdfDoc )) {
468
+
469
+ PdfFont font = PdfFontFactory .createFont (SOURCE_FOLDER + "FreeSans.ttf" , PdfEncodings .WINANSI );
470
+
471
+ doc .add (new Paragraph (new Text ("Some text" ).setFont (font ).setFontSize (10 )));
472
+
473
+ PdfAcroForm form = PdfAcroForm .getAcroForm (pdfDoc , true );
474
+ form .addField (PdfFormField .createText (pdfDoc , new Rectangle (150 , 100 , 100 , 20 ),
475
+ "text" , "textField" , font , 10 , false ,
476
+ PdfAConformanceLevel .PDF_A_1B ).setFieldName ("text" ).setPage (1 ), pdfDoc .getPage (1 ));
477
+ }
478
+
479
+ Assert .assertNull (new VeraPdfValidator ().validate (fileName ));
480
+
481
+ PdfADocument pdfDocToMerge ;
482
+ try (InputStream is = new FileInputStream (SOURCE_FOLDER + "sRGB Color Space Profile.icm" );
483
+ PdfDocument newDoc = new PdfDocument (new PdfReader (fileName ))) {
484
+ pdfDocToMerge = new PdfADocument (new PdfWriter (mergedDocFileName ).setSmartMode (true ),
485
+ PdfAConformanceLevel .PDF_A_1B ,
486
+ new PdfOutputIntent ("Custom" , "" ,
487
+ "http://www.color.org" , "sRGB ICC preference" , is ));
488
+
489
+ newDoc .copyPagesTo (1 , newDoc .getNumberOfPages (), pdfDocToMerge , new PdfPageFormCopier ());
490
+ }
491
+
492
+ Exception ex = Assert .assertThrows (PdfException .class , () -> pdfDocToMerge .close ());
493
+ Assert .assertEquals (MessageFormatUtil
494
+ .format (PdfAConformanceException .ALL_THE_FONTS_MUST_BE_EMBEDDED_THIS_ONE_IS_NOT_0 ,
495
+ "Helvetica" ), ex .getMessage ());
496
+ }
450
497
}
0 commit comments