Skip to content

Commit 4a35017

Browse files
committed
[RELEASE] iText 7 Core - 7.1.11
https://github.com/itext/itext7/releases/tag/7.1.11 * release/7.1.11: Revert 'protected' FontSelectorStrategy#tempFonts field renaming [RELEASE] 7.1.11-SNAPSHOT -> 7.1.11 Add missing copyright headers Cover AreaBreakRenderer with unit tests Let PointTest extend ExtendedITextTest. Remove DefaultStylesTest#inheritedDefaultStyleTest Add missing copyright headers Change category of StylesTest class Improve layout's Style code coverage Move PdfPagesTest tests from samples internal Add PointTest Add tests on tiff image extraction Consider not set LINE_HEIGHT property to be exactly the same as LineHeight.NORMAL Add InheritedPageEntriesTest#setRotationToPageTest Unignore a test on Float.MIN_VALUE. Update dependency-check-maven to version 5.3.1 Add missing copyright headers Take epsilon into account while deciding whether a cell of a fixed height sgould be split. Add html mode check for LineRenderer childs Add new tests for tiff images Add properties and default values for orphans and widows css support Add new Pdfa2Checker and Pdfa3Checker tests Add comment to MemoryLimitsAwareOutputStream#write() Deprecate one of Canvas constructors Add missing copyright headers Improve isVersionNumeric. Change the accessability of some Version methods from private to default. Cover Version with tests. Add tests for grayscale alpha png without embedded profile Move PdfColorSpace test from samples internal, add unit test Add MonospaceFontTest test Revert to typo_ascender scale coefficient usage for Type1Fonts for HTML mode Fix TextRenderer #resolveFirstPdfFont, refactor Property#FONT_SET usage documentation Implement HTML-like line-stacking algorithm in layout. Implement ascender/descender calculation according to CSS specification. Add new tests on orphans and widows Add missing copyright headers Add integration tests for orphans/widows Support orphans/widows processing Handle collapsing margins info in relayouting context Add new test for collapsing margins Deprecated redundant field in ParagraphRenderer Substitute RND tickets numbers to DEVSIX Change the type of expected exception Extend Test classes from ExtendedITextTest to check log messages Move xfa form test to forms repository Add category to test classes Move test from samples internal repository Move hugeDocumentWithFullCompression test to manual tests repository Add PdfAIndirectResourcesTest class Process fillOpacity and strokeOpacity in GraphicsState Processor Add test for UrlUtil#openStream method Move, add pattern color tests to kernel repository, add Logger to PdfCanvasProcessor, add LogMessageConstant class for kernel module Improve documentation of PdfPKCS7#getTimeStampDate. Make UNDEFINED_TIMESTAMP_DATE public and move to a separate class Add PdfAStampingModeTest and signature field tests Separate code licensed under Apache License into separate file Add missing copyright headers Add ClipperException and ClipperExceptionConstant classes Add PdfCanvasParserTest#innerArraysInContentStreamTest Add PdfContentExtractionTest#contentExtractionInDocWithBigCoordinatesTest Add InlineImageExtractionTest#parseInlineImageTest Refactor URL links generation Add a test which demonstrate an NPE while processing cells with big rowspans Add missing copyright headers Fix mark to ligature positioning in GposLookupType5 Replace CorruptedTagStructureTest from samples-internal repo Add some tests to cover big rowspan splits Pdftest update, EventCounterHandler update Add missing copyright headers Make fringe attribute of square annotation optional Refactor CompareTool.compareXmls(String, String) method Add missing copyright headers Add ShapeTransformUtil class and add unit tests Add missing copyright headers Fix colorspace processing for png images Add PngTest class and new tests Add a test which demonstrates a NPE bein thrown while processing links Replace character with its unicode representation Refactor nested if to switch in Pipeline Fix deployment to Artifactory Fix inserting whitespaces and newline charachers in RegexBasedLocationExtractionStrategy Make log message more general, when FormField cannot be created and add nullFormFieldTest Fix null pointer in PdfAcroForm Refactor and improve some tests of TableRendererTest Update PdfMerger and PdfDocument JavaDoc [RELEASE] Update dependency versions Add tests for svg wrong font-size case Update documentation for page events Add missing copyright headers Replace tests from samples-internal repo and add new tests Add new tests on page entries Consider /TI when highlighting selected choice fields Add I key to every choice field for backward compatibility Support handling of I key of choice fields in accordance with spec Add missing copyright headers Add SmartModePdfObjectSerializerTest class Review PdfPagesTest commented tests; add test for parsing form xobjects with circular references
2 parents a24ac93 + cb85f88 commit 4a35017

File tree

364 files changed

+9473
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+9473
-1129
lines changed

Jenkinsfile

Lines changed: 69 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
#!/usr/bin/env groovy
22
@Library('pipeline-library')_
33

4-
def schedule = env.BRANCH_NAME.contains('master') ? '@monthly' : env.BRANCH_NAME == 'develop' ? '@midnight' : ''
5-
def sonarBranchName = env.BRANCH_NAME.contains('master') ? '-Dsonar.branch.name=master' : '-Dsonar.branch.name=' + env.BRANCH_NAME
6-
def sonarBranchTarget = env.BRANCH_NAME.contains('master') ? '' : env.BRANCH_NAME == 'develop' ? '-Dsonar.branch.target=master' : '-Dsonar.branch.target=develop'
4+
def schedule, sonarBranchName, sonarBranchTarget
5+
switch (env.BRANCH_NAME) {
6+
case ~/.*master.*/:
7+
schedule = '@monthly'
8+
sonarBranchName = '-Dsonar.branch.name=master'
9+
sonarBranchTarget = ''
10+
break
11+
case ~/.*develop.*/:
12+
schedule = '@midnight'
13+
sonarBranchName = '-Dsonar.branch.name=develop'
14+
sonarBranchTarget = '-Dsonar.branch.target=master'
15+
break
16+
default:
17+
schedule = ''
18+
sonarBranchName = '-Dsonar.branch.name=' + env.BRANCH_NAME
19+
sonarBranchTarget = '-Dsonar.branch.target=develop'
20+
break
21+
}
722

823
pipeline {
924

@@ -17,7 +32,6 @@ pipeline {
1732
ansiColor('xterm')
1833
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
1934
parallelsAlwaysFailFast()
20-
retry(1)
2135
skipStagesAfterUnstable()
2236
timeout(time: 2, unit: 'HOURS')
2337
timestamps()
@@ -33,46 +47,66 @@ pipeline {
3347
}
3448

3549
stages {
36-
stage('Clean workspace') {
50+
stage('Build') {
3751
options {
38-
timeout(time: 5, unit: 'MINUTES')
52+
retry(2)
3953
}
40-
steps {
41-
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
42-
sh 'mvn --threads 2C clean'
43-
sh 'mvn dependency:purge-local-repository -Dinclude=com.itextpdf -DresolutionFuzziness=groupId -DreResolve=false'
54+
stages {
55+
stage('Clean workspace') {
56+
options {
57+
timeout(time: 5, unit: 'MINUTES')
58+
}
59+
steps {
60+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
61+
sh 'mvn --threads 2C --no-transfer-progress clean dependency:purge-local-repository -Dinclude=com.itextpdf -DresolutionFuzziness=groupId -DreResolve=false'
62+
}
63+
}
64+
}
65+
stage('Compile') {
66+
options {
67+
timeout(time: 10, unit: 'MINUTES')
68+
}
69+
steps {
70+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
71+
sh 'mvn --threads 2C --no-transfer-progress package -Dmaven.test.skip=true'
72+
}
73+
}
4474
}
4575
}
46-
}
47-
stage('Compile') {
48-
options {
49-
timeout(time: 10, unit: 'MINUTES')
50-
}
51-
steps {
52-
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
53-
sh 'mvn --threads 2C compile test-compile package -Dmaven.test.skip=true -Dmaven.javadoc.failOnError=false'
76+
post {
77+
failure {
78+
sleep time: 2, unit: 'MINUTES'
79+
}
80+
success {
81+
script { currentBuild.result = 'SUCCESS' }
5482
}
5583
}
5684
}
57-
stage('Run Tests') {
85+
stage('Static Code Analysis') {
5886
options {
5987
timeout(time: 1, unit: 'HOURS')
6088
}
6189
steps {
6290
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
63-
withSonarQubeEnv('Sonar') {
64-
sh 'mvn --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report -Dsonar.java.spotbugs.reportPaths="target/spotbugs.xml" sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget
65-
}
91+
sh 'mvn --no-transfer-progress verify --activate-profiles qa -Dpmd.analysisCache=true'
6692
}
93+
recordIssues(tools: [
94+
checkStyle(),
95+
pmdParser(),
96+
spotBugs(useRankAsPriority: true)
97+
])
98+
dependencyCheckPublisher pattern: 'target/dependency-check-report.xml'
6799
}
68100
}
69-
stage('Static Code Analysis') {
101+
stage('Run Tests') {
70102
options {
71103
timeout(time: 30, unit: 'MINUTES')
72104
}
73105
steps {
74106
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
75-
sh 'mvn --activate-profiles qa verify -Dpmd.analysisCache=true'
107+
withSonarQubeEnv('Sonar') {
108+
sh 'mvn --no-transfer-progress --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.main.skip=true -Dmaven.test.failure.ignore=false org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report -Dsonar.java.spotbugs.reportPaths="target/spotbugs.xml" sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget
109+
}
76110
}
77111
}
78112
}
@@ -94,13 +128,15 @@ pipeline {
94128
}
95129
}
96130
steps {
97-
script {
98-
def server = Artifactory.server('itext-artifactory')
99-
def rtMaven = Artifactory.newMavenBuild()
100-
rtMaven.deployer server: server, releaseRepo: 'releases', snapshotRepo: 'snapshot'
101-
rtMaven.tool = 'M3'
102-
def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'package --threads 2C --offline -Dmaven.main.skip=true -Dmaven.test.skip=true -Dmaven.javadoc.failOnError=false'
103-
server.publishBuildInfo buildInfo
131+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
132+
script {
133+
def server = Artifactory.server('itext-artifactory')
134+
def rtMaven = Artifactory.newMavenBuild()
135+
rtMaven.deployer server: server, releaseRepo: 'releases', snapshotRepo: 'snapshot'
136+
rtMaven.tool = 'M3'
137+
def buildInfo = rtMaven.run pom: 'pom.xml', goals: '--threads 2C --no-transfer-progress install --activate-profiles artifactory'
138+
server.publishBuildInfo buildInfo
139+
}
104140
}
105141
}
106142
}
@@ -121,8 +157,8 @@ pipeline {
121157
getAndConfigureJFrogCLI()
122158
if (env.GIT_URL) {
123159
repoName = ("${env.GIT_URL}" =~ /(.*\/)(.*)(\.git)/)[ 0 ][ 2 ]
124-
findFiles(glob: 'target/*.jar').each { item ->
125-
if (!(item ==~ /.*\/fb-contrib-.*?.jar/) && !(item ==~ /.*\/findsecbugs-plugin-.*?.jar/) && !(item ==~ /.*-sources.jar/) && !(item ==~ /.*-javadoc.jar/)) {
160+
findFiles(glob: '*/target/*.jar').each { item ->
161+
if (!(item ==~ /.*\/[fs]b-contrib-.*?.jar/) && !(item ==~ /.*\/findsecbugs-plugin-.*?.jar/) && !(item ==~ /.*-sources.jar/) && !(item ==~ /.*-javadoc.jar/)) {
126162
sh "./jfrog rt u \"${item.path}\" branch-artifacts/${env.BRANCH_NAME}/${repoName}/java/ --recursive=false --build-name ${env.BRANCH_NAME} --build-number ${env.BUILD_NUMBER} --props \"vcs.revision=${env.GIT_COMMIT};repo.name=${repoName}\""
127163
}
128164
}
@@ -141,14 +177,6 @@ pipeline {
141177
}
142178
}
143179
}
144-
stage('Archive Artifacts') {
145-
options {
146-
timeout(time: 5, unit: 'MINUTES')
147-
}
148-
steps {
149-
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.jar, **/*.pom', excludes: '**/fb-contrib-*.jar, **/findsecbugs-plugin-*.jar'
150-
}
151-
}
152180
}
153181

154182
post {

barcodes/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.10</version>
7+
<version>7.1.11</version>
88
</parent>
99
<artifactId>barcodes</artifactId>
1010
<name>iText 7 - barcodes</name>

font-asian/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.10</version>
7+
<version>7.1.11</version>
88
</parent>
99
<artifactId>font-asian</artifactId>
1010
<name>iText 7 - Asian fonts</name>

forms/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.10</version>
7+
<version>7.1.11</version>
88
</parent>
99
<artifactId>forms</artifactId>
1010
<name>iText 7 - forms</name>

forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This file is part of the iText (R) project.
4646
import com.itextpdf.forms.fields.PdfFormField;
4747
import com.itextpdf.forms.xfa.XfaForm;
4848
import com.itextpdf.io.LogMessageConstant;
49+
import com.itextpdf.io.util.MessageFormatUtil;
4950
import com.itextpdf.kernel.PdfException;
5051
import com.itextpdf.kernel.geom.AffineTransform;
5152
import com.itextpdf.kernel.geom.Point;
@@ -69,6 +70,7 @@ This file is part of the iText (R) project.
6970
import com.itextpdf.kernel.pdf.tagutils.TagReference;
7071
import com.itextpdf.kernel.pdf.tagutils.TagTreePointer;
7172
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
73+
7274
import org.slf4j.Logger;
7375
import org.slf4j.LoggerFactory;
7476

@@ -879,6 +881,11 @@ private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfF
879881
continue;
880882
}
881883
PdfFormField formField = PdfFormField.makeFormField(field, document);
884+
if (formField == null) {
885+
logger.warn(MessageFormatUtil.format(LogMessageConstant.CANNOT_CREATE_FORMFIELD,
886+
field.getIndirectReference() == null ? field : field.getIndirectReference()));
887+
continue;
888+
}
882889
PdfString fieldName = formField.getFieldName();
883890
String name;
884891
if (fieldName == null) {

forms/src/main/java/com/itextpdf/forms/fields/PdfChoiceFormField.java

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ This file is part of the iText (R) project.
4343
*/
4444
package com.itextpdf.forms.fields;
4545

46+
import com.itextpdf.io.LogMessageConstant;
47+
import com.itextpdf.io.font.PdfEncodings;
48+
import com.itextpdf.io.util.MessageFormatUtil;
4649
import com.itextpdf.kernel.pdf.PdfArray;
4750
import com.itextpdf.kernel.pdf.PdfDictionary;
4851
import com.itextpdf.kernel.pdf.PdfDocument;
@@ -52,6 +55,11 @@ This file is part of the iText (R) project.
5255
import com.itextpdf.kernel.pdf.PdfString;
5356
import com.itextpdf.kernel.pdf.annot.PdfWidgetAnnotation;
5457

58+
import java.util.ArrayList;
59+
import java.util.List;
60+
import org.slf4j.LoggerFactory;
61+
import org.slf4j.Logger;
62+
5563
/**
5664
* An AcroForm field type representing any type of choice field. Choice fields
5765
* are to be represented by a viewer as a list box or a combo box.
@@ -119,50 +127,80 @@ public PdfNumber getTopIndex() {
119127
public PdfChoiceFormField setIndices(PdfArray indices) {
120128
return (PdfChoiceFormField) put(PdfName.I, indices);
121129
}
130+
122131
/**
123132
* Highlights the options. If this method is used for Combo box, the first value in input array
124133
* will be the field value
125134
* @param optionValues Array of options to be highlighted
126135
* @return current {@link PdfChoiceFormField}
127136
*/
128137
public PdfChoiceFormField setListSelected(String[] optionValues) {
138+
return setListSelected(optionValues, true);
139+
}
140+
141+
/**
142+
* Highlights the options and generates field appearance if needed.. If this method is used for Combo box, the first value in input array
143+
* will be the field value
144+
* @param optionValues Array of options to be highlighted
145+
* @param generateAppearance if false, appearance won't be regenerated
146+
* @return current {@link PdfChoiceFormField}
147+
*/
148+
public PdfChoiceFormField setListSelected(String[] optionValues, boolean generateAppearance) {
149+
if (optionValues.length > 1 && !isMultiSelect()) {
150+
Logger logger = LoggerFactory.getLogger(this.getClass());
151+
logger.warn(LogMessageConstant.MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD);
152+
}
129153
PdfArray options = getOptions();
130154
PdfArray indices = new PdfArray();
131155
PdfArray values = new PdfArray();
156+
List<String> optionsToUnicodeNames = optionsToUnicodeNames();
132157
for (String element : optionValues) {
133-
for (int index = 0; index < options.size(); index++) {
134-
PdfObject option = options.get(index);
135-
PdfString value = null;
136-
if (option.isString()) {
137-
value = (PdfString) option;
138-
} else if (option.isArray()) {
139-
value = (PdfString) ((PdfArray)option).get(1);
140-
}
141-
if (value != null && value.toUnicodeString().equals(element)) {
142-
indices.add(new PdfNumber(index));
143-
values.add(value);
158+
if (element == null) {
159+
continue;
160+
}
161+
if (optionsToUnicodeNames.contains(element)) {
162+
int index = optionsToUnicodeNames.indexOf(element);
163+
indices.add(new PdfNumber(index));
164+
PdfObject optByIndex = options.get(index);
165+
values.add(optByIndex.isString() ? (PdfString) optByIndex : (PdfString) ((PdfArray) optByIndex).get(1));
166+
} else {
167+
if (!(this.isCombo() && this.isEdit())) {
168+
Logger logger = LoggerFactory.getLogger(this.getClass());
169+
logger.warn(MessageFormatUtil
170+
.format(LogMessageConstant.FIELD_VALUE_IS_NOT_CONTAINED_IN_OPT_ARRAY, element,
171+
this.getFieldName()));
144172
}
173+
values.add(new PdfString(element, PdfEncodings.UNICODE_BIG));
145174
}
146175
}
147176
if (indices.size() > 0) {
148177
setIndices(indices);
149-
if (values.size() == 1) {
150-
put(PdfName.V, values.get(0));
151-
} else {
152-
put(PdfName.V, values);
153-
}
178+
} else {
179+
remove(PdfName.I);
180+
}
181+
if (values.size() == 1) {
182+
put(PdfName.V, values.get(0));
183+
} else {
184+
put(PdfName.V, values);
185+
}
186+
187+
if (generateAppearance) {
188+
regenerateField();
154189
}
155-
regenerateField();
156190
return this;
157191
}
158192

159193
/**
160-
* Highlights the options. Is this method is used for Combo box, the first value in input array
194+
* Highlights the options. If this method is used for Combo box, the first value in input array
161195
* will be the field value
162196
* @param optionNumbers The option numbers
163197
* @return The edited {@link PdfChoiceFormField}
164198
*/
165199
public PdfChoiceFormField setListSelected(int[] optionNumbers) {
200+
if (optionNumbers.length > 1 && !isMultiSelect()) {
201+
Logger logger = LoggerFactory.getLogger(this.getClass());
202+
logger.warn(LogMessageConstant.MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD);
203+
}
166204
PdfArray indices = new PdfArray();
167205
PdfArray values = new PdfArray();
168206
PdfArray options = getOptions();
@@ -184,6 +222,9 @@ public PdfChoiceFormField setListSelected(int[] optionNumbers) {
184222
} else {
185223
put(PdfName.V, values);
186224
}
225+
} else {
226+
remove(PdfName.I);
227+
remove(PdfName.V);
187228
}
188229
regenerateField();
189230
return this;
@@ -307,4 +348,20 @@ public PdfChoiceFormField setCommitOnSelChange(boolean commitOnSelChange) {
307348
public boolean isCommitOnSelChange() {
308349
return getFieldFlag(FF_COMMIT_ON_SEL_CHANGE);
309350
}
351+
352+
private List<String> optionsToUnicodeNames() {
353+
PdfArray options = getOptions();
354+
List<String> optionsToUnicodeNames = new ArrayList<String>(options.size());
355+
for (int index = 0; index < options.size(); index++) {
356+
PdfObject option = options.get(index);
357+
PdfString value = null;
358+
if (option.isString()) {
359+
value = (PdfString) option;
360+
} else if (option.isArray()) {
361+
value = (PdfString) ((PdfArray) option).get(1);
362+
}
363+
optionsToUnicodeNames.add(value != null ? value.toUnicodeString() : null);
364+
}
365+
return optionsToUnicodeNames;
366+
}
310367
}

0 commit comments

Comments
 (0)