@@ -25,14 +25,19 @@ This file is part of the iText (R) project.
25
25
import com .itextpdf .commons .actions .contexts .IMetaInfo ;
26
26
import com .itextpdf .html2pdf .attach .ITagWorkerFactory ;
27
27
import com .itextpdf .html2pdf .attach .impl .OutlineHandler ;
28
+ import com .itextpdf .html2pdf .attach .util .AlternateDescriptionResolver ;
28
29
import com .itextpdf .html2pdf .css .apply .ICssApplierFactory ;
29
30
import com .itextpdf .kernel .pdf .PdfAConformance ;
31
+ import com .itextpdf .kernel .pdf .PdfConformance ;
30
32
import com .itextpdf .kernel .pdf .PdfOutputIntent ;
33
+ import com .itextpdf .kernel .pdf .PdfUAConformance ;
31
34
import com .itextpdf .layout .font .FontProvider ;
32
35
import com .itextpdf .styledxmlparser .css .media .MediaDeviceDescription ;
33
36
import com .itextpdf .styledxmlparser .resolver .resource .IResourceRetriever ;
34
37
35
38
import java .io .InputStream ;
39
+ import java .util .HashMap ;
40
+ import java .util .Map ;
36
41
37
42
/**
38
43
* Properties that will be used by the {@link com.itextpdf.html2pdf.HtmlConverter}.
@@ -44,6 +49,8 @@ public class ConverterProperties {
44
49
*/
45
50
private static final int DEFAULT_LIMIT_OF_LAYOUTS = 10 ;
46
51
52
+ private final HashMap <Class <?>, Object > dependencies = new HashMap <>();
53
+
47
54
/**
48
55
* The media device description.
49
56
*/
@@ -117,12 +124,13 @@ public class ConverterProperties {
117
124
/**
118
125
* Conformance for conversion to pdf/a.
119
126
*/
120
- private PdfAConformance aConformance ;
127
+ private PdfConformance conformance = new PdfConformance () ;
121
128
122
129
/**
123
130
* Instantiates a new {@link ConverterProperties} instance.
124
131
*/
125
132
public ConverterProperties () {
133
+ this .dependencies .put (AlternateDescriptionResolver .class , new AlternateDescriptionResolver ());
126
134
}
127
135
128
136
/**
@@ -145,6 +153,11 @@ public ConverterProperties(ConverterProperties other) {
145
153
this .limitOfLayouts = other .limitOfLayouts ;
146
154
this .immediateFlush = other .immediateFlush ;
147
155
this .continuousContainerEnabled = other .continuousContainerEnabled ;
156
+ this .conformance = other .conformance ;
157
+ this .outputIntent = other .outputIntent ;
158
+ for (Class <?> aClass : other .dependencies .keySet ()) {
159
+ this .dependencies .put (aClass , other .dependencies .get (aClass ));
160
+ }
148
161
}
149
162
150
163
/**
@@ -344,7 +357,6 @@ public boolean isCreateAcroForm() {
344
357
* When enabling this acroform creation, it will disable the immediateFlushing property.
345
358
*
346
359
* @param createAcroForm true if an AcroForm needs to be created
347
- *
348
360
* @return the {@link ConverterProperties} instance
349
361
*/
350
362
public ConverterProperties setCreateAcroForm (boolean createAcroForm ) {
@@ -410,16 +422,28 @@ public ConverterProperties setCharset(String charset) {
410
422
return this ;
411
423
}
412
424
425
+ /**
426
+ * Gets pdf document output intent (final destination device) to reproduce the color in the PDF.
427
+ *
428
+ * <p>
429
+ * Note, output intent isn't applicable for HtmlConverter#convertToElements methods
430
+ * (e.g. {@link HtmlConverter#convertToElements(InputStream, ConverterProperties)})
431
+ *
432
+ * @return pdf output intent
433
+ */
434
+ public PdfOutputIntent getDocumentOutputIntent () {
435
+ return outputIntent ;
436
+ }
437
+
413
438
/**
414
439
* Sets pdf document output intent (final destination device) to reproduce the color in the PDF.
415
- * Required parameter, when converting to pdf/a one have to specify an explicit output intent.
440
+ * Required parameter, when converting to pdf/a one has to specify an explicit output intent.
416
441
*
417
442
* <p>
418
443
* Note, output intent isn't applicable for HtmlConverter#convertToElements methods
419
444
* (e.g. {@link HtmlConverter#convertToElements(InputStream, ConverterProperties)})
420
445
*
421
446
* @param outputIntent a {@link PdfOutputIntent} instance
422
- *
423
447
* @return the {@link ConverterProperties} instance
424
448
*/
425
449
public ConverterProperties setDocumentOutputIntent (PdfOutputIntent outputIntent ) {
@@ -428,38 +452,45 @@ public ConverterProperties setDocumentOutputIntent(PdfOutputIntent outputIntent)
428
452
}
429
453
430
454
/**
431
- * Sets the generation and strictness level of the PDF/A that must be followed.
432
- * Required parameter, when converting to pdf/a one have to specify an explicit pdf/a conformance.
455
+ * Gets the generation and strictness level of the PDF/A that must be followed.
433
456
*
434
- * @param conformance a {@link PdfAConformance} constant
457
+ * @return pdf/a conformance
458
+ */
459
+ public PdfAConformance getPdfAConformance () {
460
+ return conformance .getAConformance ();
461
+ }
462
+
463
+ /**
464
+ * Sets the generation and strictness level of the PDF/A that must be followed.
465
+ * Required parameter, when converting to pdf/a one has to specify an explicit pdf/a conformance.
435
466
*
467
+ * @param aConformance a {@link PdfAConformance} constant
436
468
* @return the {@link ConverterProperties} instance
437
469
*/
438
- public ConverterProperties setPdfAConformance (PdfAConformance conformance ) {
439
- this .aConformance = conformance ;
470
+ public ConverterProperties setPdfAConformance (PdfAConformance aConformance ) {
471
+ this .conformance = new PdfConformance ( aConformance , conformance . getUAConformance ()) ;
440
472
return this ;
441
473
}
442
474
443
475
/**
444
- * Gets pdf document output intent (final destination device) to reproduce the color in the PDF .
476
+ * Gets the generation and strictness level of the PDF/UA that must be followed .
445
477
*
446
- * <p>
447
- * Note, output intent isn't applicable for HtmlConverter#convertToElements methods
448
- * (e.g. {@link HtmlConverter#convertToElements(InputStream, ConverterProperties)})
449
- *
450
- * @return pdf output intent
478
+ * @return The PDF/UA conformance level.
451
479
*/
452
- public PdfOutputIntent getDocumentOutputIntent () {
453
- return outputIntent ;
480
+ public PdfUAConformance getPdfUaConformance () {
481
+ return conformance . getUAConformance () ;
454
482
}
455
483
456
484
/**
457
- * Gets the generation and strictness level of the PDF/A that must be followed.
485
+ * Sets the generation and strictness level of the PDF/UA that must be followed.
486
+ * Required parameter, when converting to PDF/UA one has to specify an explicit PDF/UA conformance.
458
487
*
459
- * @return pdf/a conformance
488
+ * @param uaConformance a {@link PdfUAConformance} constant
489
+ * @return the {@link ConverterProperties} instance
460
490
*/
461
- public PdfAConformance getPdfAConformance () {
462
- return aConformance ;
491
+ public ConverterProperties setPdfUAConformance (PdfUAConformance uaConformance ) {
492
+ this .conformance = new PdfConformance (conformance .getAConformance (), uaConformance );
493
+ return this ;
463
494
}
464
495
465
496
/**
@@ -535,4 +566,13 @@ public ConverterProperties setContinuousContainerEnabled(boolean value) {
535
566
continuousContainerEnabled = value ;
536
567
return this ;
537
568
}
569
+
570
+ /**
571
+ * Gets the dependencies.
572
+ *
573
+ * @return the dependencies
574
+ */
575
+ public Map <Class <?>, Object > getDependencies () {
576
+ return dependencies ;
577
+ }
538
578
}
0 commit comments