Skip to content

Commit 8db4d3e

Browse files
committed
Cover several pdfa classes with documentation
DEVSIX-6677
1 parent 1ff59d8 commit 8db4d3e

File tree

4 files changed

+207
-1
lines changed

4 files changed

+207
-1
lines changed

pdfa/src/main/java/com/itextpdf/pdfa/PdfADocument.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ protected void flushFonts() {
284284
super.flushFonts();
285285
}
286286

287+
/**
288+
* Sets the checker that defines the requirements of the PDF/A standard
289+
* depending on conformance level.
290+
*
291+
* @param conformanceLevel {@link PdfAConformanceLevel}
292+
*/
287293
protected void setChecker(PdfAConformanceLevel conformanceLevel) {
288294
switch (conformanceLevel.getPart()) {
289295
case "1":
@@ -298,6 +304,9 @@ protected void setChecker(PdfAConformanceLevel conformanceLevel) {
298304
}
299305
}
300306

307+
/**
308+
* Initializes tagStructureContext to track necessary information of document's tag structure.
309+
*/
301310
protected void initTagStructureContext() {
302311
tagStructureContext = new TagStructureContext(this, getPdfVersionForPdfA(checker.getConformanceLevel()));
303312
}

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ protected void checkPdfString(PdfString string) {
596596
}
597597
}
598598

599+
/**
600+
* Returns maximum allowed bytes length of the string in a PDF document.
601+
*
602+
* @return maximum string length
603+
*/
599604
protected int getMaxStringLength() {
600605
return 65535;
601606
}
@@ -756,6 +761,13 @@ protected void checkTrailer(PdfDictionary trailer) {
756761
}
757762
}
758763

764+
/**
765+
* Gets a {@link PdfArray} of fields with kids from a {@link PdfArray} of {@link PdfDictionary} objects.
766+
*
767+
* @param array the {@link PdfArray} of form fields {@link PdfDictionary} objects
768+
*
769+
* @return the {@link PdfArray} of form fields
770+
*/
759771
protected PdfArray getFormFields(PdfArray array) {
760772
PdfArray fields = new PdfArray();
761773
for (PdfObject field : array) {

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,13 @@ protected void checkFormXObject(PdfStream form) {
855855
checkFormXObject(form, null);
856856
}
857857

858+
/**
859+
* Verify the conformity of the Form XObject with appropriate
860+
* specification. Throws PdfAConformanceException if any discrepancy was found
861+
*
862+
* @param form the {@link PdfStream} to be checked
863+
* @param contentStream the {@link PdfStream} current content stream
864+
*/
858865
protected void checkFormXObject(PdfStream form, PdfStream contentStream) {
859866
if (isAlreadyChecked(form)) return;
860867

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ public abstract class PdfAChecker {
149149

150150
private boolean fullCheckMode = false;
151151

152+
/**
153+
* Creates a PdfAChecker with the required conformance level.
154+
*
155+
* @param conformanceLevel the required conformance level
156+
*/
152157
protected PdfAChecker(PdfAConformanceLevel conformanceLevel) {
153158
this.conformanceLevel = conformanceLevel;
154159
}
@@ -388,33 +393,187 @@ public abstract void checkColor(Color color, PdfDictionary currentColorSpaces, B
388393
*/
389394
protected abstract long getMaxNumberOfIndirectObjects();
390395

396+
/**
397+
* Retrieve forbidden actions in conforming document.
398+
*
399+
* @return set of {@link PdfName} with forbidden actions
400+
*/
391401
protected abstract Set<PdfName> getForbiddenActions();
402+
403+
/**
404+
* Retrieve allowed actions in conforming document.
405+
*
406+
* @return set of {@link PdfName} with allowed named actions
407+
*/
392408
protected abstract Set<PdfName> getAllowedNamedActions();
409+
410+
/**
411+
* Checks if the action is allowed.
412+
*
413+
* @param action to be checked
414+
*/
393415
protected abstract void checkAction(PdfDictionary action);
416+
417+
/**
418+
* Verify the conformity of the annotation dictionary.
419+
*
420+
* @param annotDic the annotation {@link PdfDictionary} to be checked
421+
*/
394422
protected abstract void checkAnnotation(PdfDictionary annotDic);
423+
424+
/**
425+
* Checks if entries in catalog dictionary are valid.
426+
*
427+
* @param catalogDict the catalog {@link PdfDictionary} to be checked
428+
*/
395429
protected abstract void checkCatalogValidEntries(PdfDictionary catalogDict);
430+
431+
/**
432+
* Verify the conformity of used color spaces.
433+
*/
396434
protected abstract void checkColorsUsages();
435+
436+
/**
437+
* Verify the conformity of the given image.
438+
*
439+
* @param image the image to check
440+
* @param currentColorSpaces the {@link PdfDictionary} containing the color spaces used in the document
441+
*/
397442
protected abstract void checkImage(PdfStream image, PdfDictionary currentColorSpaces);
443+
444+
/**
445+
* Verify the conformity of the file specification dictionary.
446+
*
447+
* @param fileSpec the {@link PdfDictionary} containing file specification to be checked
448+
*/
398449
protected abstract void checkFileSpec(PdfDictionary fileSpec);
450+
451+
/**
452+
* Verify the conformity of the form dictionary.
453+
*
454+
* @param form the form {@link PdfDictionary} to be checked
455+
*/
399456
protected abstract void checkForm(PdfDictionary form);
457+
458+
/**
459+
* Verify the conformity of the form XObject dictionary.
460+
*
461+
* @param form the {@link PdfStream} to check
462+
*/
400463
protected abstract void checkFormXObject(PdfStream form);
464+
465+
/**
466+
* Performs a number of checks on the logical structure of the document.
467+
*
468+
* @param catalog the catalog {@link PdfDictionary} to check
469+
*/
401470
protected abstract void checkLogicalStructure(PdfDictionary catalog);
471+
472+
/**
473+
* Performs a number of checks on the metadata of the document.
474+
*
475+
* @param catalog the catalog {@link PdfDictionary} to check
476+
*/
402477
protected abstract void checkMetaData(PdfDictionary catalog);
478+
479+
/**
480+
* Verify the conformity of the non-symbolic TrueType font.
481+
*
482+
* @param trueTypeFont the {@link PdfTrueTypeFont} to check
483+
*/
403484
protected abstract void checkNonSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont);
485+
486+
/**
487+
* Verify the conformity of the output intents array in the catalog dictionary.
488+
*
489+
* @param catalog the {@link PdfDictionary} to check
490+
*/
404491
protected abstract void checkOutputIntents(PdfDictionary catalog);
492+
493+
/**
494+
* Verify the conformity of the page dictionary.
495+
*
496+
* @param page the {@link PdfDictionary} to check
497+
* @param pageResources the page's resources dictionary
498+
*/
405499
protected abstract void checkPageObject(PdfDictionary page, PdfDictionary pageResources);
500+
501+
/**
502+
* Checks the allowable size of the page.
503+
*
504+
* @param page the {@link PdfDictionary} of page which size being checked
505+
*/
406506
protected abstract void checkPageSize(PdfDictionary page);
507+
508+
/**
509+
* Verify the conformity of the PDF array.
510+
*
511+
* @param array the {@link PdfArray} to check
512+
*/
407513
protected abstract void checkPdfArray(PdfArray array);
514+
515+
/**
516+
* Verify the conformity of the PDF dictionary.
517+
*
518+
* @param dictionary the {@link PdfDictionary} to check
519+
*/
408520
protected abstract void checkPdfDictionary(PdfDictionary dictionary);
521+
522+
/**
523+
* Verify the conformity of the PDF name.
524+
*
525+
* @param name the {@link PdfName} to check
526+
*/
409527
protected abstract void checkPdfName(PdfName name);
528+
529+
/**
530+
* Verify the conformity of the PDF number.
531+
*
532+
* @param number the {@link PdfNumber} to check
533+
*/
410534
protected abstract void checkPdfNumber(PdfNumber number);
535+
536+
/**
537+
* Verify the conformity of the PDF stream.
538+
*
539+
* @param stream the {@link PdfStream} to check
540+
*/
411541
protected abstract void checkPdfStream(PdfStream stream);
542+
543+
/**
544+
* Verify the conformity of the PDF string.
545+
*
546+
* @param string the {@link PdfString} to check
547+
*/
412548
protected abstract void checkPdfString(PdfString string);
549+
550+
/**
551+
* Verify the conformity of the symbolic TrueType font.
552+
*
553+
* @param trueTypeFont the {@link PdfTrueTypeFont} to check
554+
*/
413555
protected abstract void checkSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont);
556+
557+
/**
558+
* Verify the conformity of the trailer dictionary.
559+
*
560+
* @param trailer the {@link PdfDictionary} of trailer to check
561+
*/
414562
protected abstract void checkTrailer(PdfDictionary trailer);
415-
protected abstract void checkPageTransparency(PdfDictionary pageDict, PdfDictionary pageResources);
416563

564+
/**
565+
* Verify the conformity of the page transparency.
566+
*
567+
* @param pageDict the {@link PdfDictionary} contains contents for transparency to be checked
568+
* @param pageResources the {@link PdfDictionary} contains resources for transparency to be checked
569+
*/
570+
protected abstract void checkPageTransparency(PdfDictionary pageDict, PdfDictionary pageResources);
417571

572+
/**
573+
* Verify the conformity of the resources dictionary.
574+
*
575+
* @param resources the {@link PdfDictionary} to be checked
576+
*/
418577
protected void checkResources(PdfDictionary resources) {
419578
if (resources == null)
420579
return;
@@ -462,10 +621,23 @@ protected void checkResources(PdfDictionary resources) {
462621
}
463622
}
464623

624+
/**
625+
* Checks if the specified flag is set.
626+
*
627+
* @param flags a set of flags specifying various characteristics of the PDF object
628+
* @param flag to be checked
629+
* @return true if the specified flag is set
630+
*/
465631
protected static boolean checkFlag(int flags, int flag) {
466632
return (flags & flag) != 0;
467633
}
468634

635+
/**
636+
* Checks conformance level of PDF/A standard.
637+
*
638+
* @param conformanceLevel the {@link PdfAConformanceLevel} to be checked
639+
* @return true if the specified conformanceLevel is <code>a</code> for PDF/A-1, PDF/A-2 or PDF/A-3
640+
*/
469641
protected static boolean checkStructure(PdfAConformanceLevel conformanceLevel) {
470642
return conformanceLevel == PdfAConformanceLevel.PDF_A_1A
471643
|| conformanceLevel == PdfAConformanceLevel.PDF_A_2A
@@ -484,6 +656,12 @@ protected static boolean isContainsTransparencyGroup(PdfDictionary dictionary) {
484656
dictionary.getAsDictionary(PdfName.Group).getAsName(PdfName.S));
485657
}
486658

659+
/**
660+
* Checks whether the specified dictionary was already checked.
661+
*
662+
* @param dictionary the {@link PdfDictionary} to check
663+
* @return true if the specified dictionary was checked
664+
*/
487665
protected boolean isAlreadyChecked(PdfDictionary dictionary) {
488666
if (checkedObjects.contains(dictionary)) {
489667
return true;

0 commit comments

Comments
 (0)