Skip to content

Commit a429a71

Browse files
committed
[RELEASE] Merge branch 'release/1.1.1'
2 parents 86a6150 + 1272204 commit a429a71

File tree

13 files changed

+139
-98
lines changed

13 files changed

+139
-98
lines changed

itext.tests/itext.cleanup.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
[assembly: Guid("647c862e-d837-4901-8e7b-68f5f8bf8f34")]
1717

18-
[assembly: AssemblyVersion("1.1.0.0")]
19-
[assembly: AssemblyFileVersion("1.1.0.0")]
20-
[assembly: AssemblyInformationalVersion("1.1.0")]
18+
[assembly: AssemblyVersion("1.1.1.0")]
19+
[assembly: AssemblyFileVersion("1.1.1.0")]
20+
[assembly: AssemblyInformationalVersion("1.1.1")]
2121

2222
[assembly: NUnit.Framework.Timeout(300000)]

itext.tests/itext.cleanup.tests/itext/pdfcleanup/BigDocumentAutoCleanUpTest.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ source product.
4040
For more information, please contact iText Software Corp. at this
4141
4242
*/
43-
/*
44-
* To change this license header, choose License Headers in Project Properties.
45-
* To change this template file, choose Tools | Templates
46-
* and open the template in the editor.
47-
*/
4843
using System;
4944
using System.Collections.Generic;
5045
using iText.Kernel.Colors;
@@ -57,7 +52,6 @@ source product.
5752
using iText.Test;
5853

5954
namespace iText.PdfCleanup {
60-
/// <author>Joris Schellekens</author>
6155
public class BigDocumentAutoCleanUpTest {
6256
private static readonly String inputPath = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
6357
.CurrentContext.TestDirectory) + "/resources/itext/pdfcleanup/BigDocumentAutoCleanUpTest/";

itext.tests/itext.cleanup.tests/itext/pdfcleanup/BigDocumentCleanUpTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ source product.
4242
*/
4343
using System;
4444
using System.Collections.Generic;
45+
using iText.IO.Util;
4546
using iText.Kernel.Geom;
4647
using iText.Kernel.Pdf;
4748
using iText.Kernel.Utils;
@@ -66,8 +67,8 @@ public virtual void BigUntaggedDocument() {
6667
String input = inputPath + "iphone_user_guide_untagged.pdf";
6768
String output = outputPath + "bigUntaggedDocument.pdf";
6869
String cmp = inputPath + "cmp_bigUntaggedDocument.pdf";
69-
IList<Rectangle> rects = iText.IO.Util.JavaUtil.ArraysAsList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle
70-
(300f, 370f, 215f, 260f));
70+
IList<Rectangle> rects = JavaUtil.ArraysAsList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle(300f, 370f
71+
, 215f, 260f));
7172
CleanUp(input, output, InitLocations(rects, 130));
7273
CompareByContent(cmp, output, outputPath, "diff_bigUntagged_");
7374
}
@@ -79,8 +80,8 @@ public virtual void BigTaggedDocument() {
7980
String input = inputPath + "chapter8_Interactive_features.pdf";
8081
String output = outputPath + "bigTaggedDocument.pdf";
8182
String cmp = inputPath + "cmp_bigTaggedDocument.pdf";
82-
IList<Rectangle> rects = iText.IO.Util.JavaUtil.ArraysAsList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle
83-
(300f, 370f, 215f, 270f));
83+
IList<Rectangle> rects = JavaUtil.ArraysAsList(new Rectangle(60f, 80f, 460f, 65f), new Rectangle(300f, 370f
84+
, 215f, 270f));
8485
CleanUp(input, output, InitLocations(rects, 131));
8586
CompareByContent(cmp, output, outputPath, "diff_bigTagged_");
8687
}
@@ -92,7 +93,7 @@ public virtual void TextPositioning() {
9293
String input = inputPath + "textPositioning.pdf";
9394
String output = outputPath + "textPositioning.pdf";
9495
String cmp = inputPath + "cmp_textPositioning.pdf";
95-
IList<Rectangle> rects = iText.IO.Util.JavaUtil.ArraysAsList(new Rectangle(0f, 0f, 1f, 1f));
96+
IList<Rectangle> rects = JavaUtil.ArraysAsList(new Rectangle(0f, 0f, 1f, 1f));
9697
// just to enable cleanup processing of the pages
9798
CleanUp(input, output, InitLocations(rects, 163));
9899
CompareByContent(cmp, output, outputPath, "diff_txtPos_");

itext.tests/itext.cleanup.tests/itext/pdfcleanup/PdfCleanUpToolTest.cs

Lines changed: 85 additions & 48 deletions
Large diffs are not rendered by default.

itext/itext.cleanup/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
[assembly: Guid("ec333396-8945-4d69-b626-475b4e2ede61")]
2323

24-
[assembly: AssemblyVersion("1.1.0.0")]
25-
[assembly: AssemblyFileVersion("1.1.0.0")]
26-
[assembly: AssemblyInformationalVersion("1.1.0")]
24+
[assembly: AssemblyVersion("1.1.1.0")]
25+
[assembly: AssemblyFileVersion("1.1.1.0")]
26+
[assembly: AssemblyInformationalVersion("1.1.1")]
2727

28-
[assembly: Versions.Attributes.KeyVersion("3.0.1.0")]
28+
[assembly: Versions.Attributes.KeyVersion("3.0.2.0")]

itext/itext.cleanup/itext/pdfcleanup/LineDashPattern.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ source product.
4242
*/
4343
using System;
4444
using System.Collections.Generic;
45+
using iText.IO.Util;
4546
using iText.Kernel.Geom;
4647
using iText.Kernel.Pdf;
4748

@@ -167,7 +168,7 @@ public virtual bool IsSolid() {
167168
for (int i = 1; i < dashArray.Size(); i += 2) {
168169
unitsOffSum += dashArray.GetAsNumber(i).FloatValue();
169170
}
170-
return iText.IO.Util.JavaUtil.FloatCompare(unitsOffSum, 0) == 0;
171+
return JavaUtil.FloatCompare(unitsOffSum, 0) == 0;
171172
}
172173

173174
private void InitFirst(float phase) {
@@ -250,8 +251,8 @@ public static Path ApplyDashPattern(Path path, LineDashPattern lineDashPattern)
250251
nextPoint = GetNextPoint(subpathApprox[i - 1], subpathApprox[i], remainingDist);
251252
remainingDist = ApplyDash(dashedPath, subpathApprox[i - 1], subpathApprox[i], nextPoint, remainingIsGap);
252253
}
253-
while (iText.IO.Util.JavaUtil.FloatCompare(remainingDist, 0) == 0 && !dashedPath.GetCurrentPoint().Equals(
254-
subpathApprox[i])) {
254+
while (JavaUtil.FloatCompare(remainingDist, 0) == 0 && !dashedPath.GetCurrentPoint().Equals(subpathApprox[
255+
i])) {
255256
LineDashPattern.DashArrayElem currentElem = lineDashPattern.Next();
256257
nextPoint = GetNextPoint(nextPoint != null ? nextPoint : subpathApprox[i - 1], subpathApprox[i], currentElem
257258
.GetVal());

itext/itext.cleanup/itext/pdfcleanup/PdfCleanUpProcessor.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,36 @@ source product.
6060

6161
namespace iText.PdfCleanup {
6262
public class PdfCleanUpProcessor : PdfCanvasProcessor {
63-
private static readonly ICollection<String> textShowingOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
63+
private static readonly ICollection<String> textShowingOperators = new HashSet<String>(JavaUtil.ArraysAsList
6464
("TJ", "Tj", "'", "\""));
6565

66-
private static readonly ICollection<String> pathConstructionOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
66+
private static readonly ICollection<String> pathConstructionOperators = new HashSet<String>(JavaUtil.ArraysAsList
6767
("m", "l", "c", "v", "y", "h", "re"));
6868

69-
private static readonly ICollection<String> strokeOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
70-
("S", "s", "B", "B*", "b", "b*"));
69+
private static readonly ICollection<String> strokeOperators = new HashSet<String>(JavaUtil.ArraysAsList("S"
70+
, "s", "B", "B*", "b", "b*"));
7171

72-
private static readonly ICollection<String> nwFillOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
73-
("f", "F", "B", "b"));
72+
private static readonly ICollection<String> nwFillOperators = new HashSet<String>(JavaUtil.ArraysAsList("f"
73+
, "F", "B", "b"));
7474

75-
private static readonly ICollection<String> eoFillOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
76-
("f*", "B*", "b*"));
75+
private static readonly ICollection<String> eoFillOperators = new HashSet<String>(JavaUtil.ArraysAsList("f*"
76+
, "B*", "b*"));
7777

7878
private static readonly ICollection<String> pathPaintingOperators = new HashSet<String>();
7979

80-
private static readonly ICollection<String> clippingPathOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
80+
private static readonly ICollection<String> clippingPathOperators = new HashSet<String>(JavaUtil.ArraysAsList
8181
("W", "W*"));
8282

83-
private static readonly ICollection<String> lineStyleOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
83+
private static readonly ICollection<String> lineStyleOperators = new HashSet<String>(JavaUtil.ArraysAsList
8484
("w", "J", "j", "M", "d"));
8585

86-
private static readonly ICollection<String> strokeColorOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
86+
private static readonly ICollection<String> strokeColorOperators = new HashSet<String>(JavaUtil.ArraysAsList
8787
("CS", "SC", "SCN", "G", "RG", "K"));
8888

89-
private static readonly ICollection<String> fillColorOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
89+
private static readonly ICollection<String> fillColorOperators = new HashSet<String>(JavaUtil.ArraysAsList
9090
("cs", "sc", "scn", "g", "rg", "k"));
9191

92-
private static readonly ICollection<String> textPositioningOperators = new HashSet<String>(iText.IO.Util.JavaUtil.ArraysAsList
92+
private static readonly ICollection<String> textPositioningOperators = new HashSet<String>(JavaUtil.ArraysAsList
9393
("Td", "TD", "Tm", "T*", "TL"));
9494

9595
private static readonly ICollection<String> ignoredOperators = new HashSet<String>();
@@ -104,8 +104,8 @@ static PdfCleanUpProcessor() {
104104
ignoredOperators.AddAll(pathConstructionOperators);
105105
ignoredOperators.AddAll(clippingPathOperators);
106106
ignoredOperators.AddAll(lineStyleOperators);
107-
ignoredOperators.AddAll(iText.IO.Util.JavaUtil.ArraysAsList("Tc", "Tw", "Tz", "Tf", "Tr", "Ts"));
108-
ignoredOperators.AddAll(iText.IO.Util.JavaUtil.ArraysAsList("BMC", "BDC"));
107+
ignoredOperators.AddAll(JavaUtil.ArraysAsList("Tc", "Tw", "Tz", "Tf", "Tr", "Ts"));
108+
ignoredOperators.AddAll(JavaUtil.ArraysAsList("BMC", "BDC"));
109109
}
110110

111111
private PdfDocument document;

itext/itext.cleanup/itext/pdfcleanup/PdfCleanUpTool.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ source product.
6060
using System.Collections.Generic;
6161
using System.Reflection;
6262
using System.IO;
63+
using iText.IO.Log;
6364
using Versions.Attributes;
6465
using iText.Kernel;
6566

@@ -209,7 +210,7 @@ private static Type GetClass(string className)
209210
{
210211
fileLoadExceptionMessage = fileLoadException.Message;
211212
}
212-
if (fileLoadExceptionMessage != null)
213+
if (type == null)
213214
{
214215
try
215216
{
@@ -219,6 +220,9 @@ private static Type GetClass(string className)
219220
{
220221
// empty
221222
}
223+
if (type == null && fileLoadExceptionMessage != null) {
224+
LoggerFactory.GetLogger(typeof(PdfCleanUpTool)).Error(fileLoadExceptionMessage);
225+
}
222226
}
223227
}
224228
return type;
@@ -451,12 +455,21 @@ private void DrawRolloverAppearance(PdfCanvas canvas, PdfStream redactRolloverAp
451455
/// <exception cref="System.IO.IOException"/>
452456
private void DrawOverlayText(PdfCanvas canvas, String overlayText, Rectangle annotRect, PdfBoolean repeat,
453457
PdfString defaultAppearance, int justification) {
454-
IDictionary<String, IList> parsedDA = ParseDAParam(defaultAppearance);
458+
IDictionary<String, IList> parsedDA;
459+
try
460+
{
461+
parsedDA = ParseDAParam(defaultAppearance);
462+
}
463+
catch (NullReferenceException npe)
464+
{
465+
throw new PdfException(PdfException.DefaultAppearanceNotFound);
466+
}
455467
PdfFont font;
456468
float fontSize = 12;
457469
IList fontArgs;
458470
parsedDA.TryGetValue("Tf", out fontArgs);
459-
if (fontArgs != null) {
471+
PdfDictionary formDictionary = pdfDocument.GetCatalog().GetPdfObject().GetAsDictionary(PdfName.AcroForm);
472+
if (fontArgs != null && formDictionary != null) {
460473
font = GetFontFromAcroForm((PdfName)fontArgs[0]);
461474
fontSize = ((PdfNumber)fontArgs[1]).FloatValue();
462475
}

itext/itext.cleanup/itext/pdfcleanup/autosweep/PdfAutoSweep.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ source product.
4040
For more information, please contact iText Software Corp. at this
4141
4242
*/
43-
/*
44-
* To change this license header, choose License Headers in Project Properties.
45-
* To change this template file, choose Tools | Templates
46-
* and open the template in the editor.
47-
*/
4843
using System;
4944
using System.Collections.Generic;
5045
using iText.IO.Util;
@@ -137,12 +132,12 @@ public virtual IList<PdfCleanUpLocation> GetPdfCleanUpLocations(PdfDocument doc)
137132
}
138133
ResetStrategy();
139134
}
140-
JavaCollectionsUtil.Sort(toClean, new _IComparer_132());
135+
JavaCollectionsUtil.Sort(toClean, new _IComparer_136());
141136
return toClean;
142137
}
143138

144-
private sealed class _IComparer_132 : IComparer<PdfCleanUpLocation> {
145-
public _IComparer_132() {
139+
private sealed class _IComparer_136 : IComparer<PdfCleanUpLocation> {
140+
public _IComparer_136() {
146141
}
147142

148143
public int Compare(PdfCleanUpLocation o1, PdfCleanUpLocation o2) {

pdfSweep.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>itext7.pdfsweep</id>
5-
<version>1.1.0</version>
5+
<version>1.1.1</version>
66
<title>iText 7 pdfSweep</title>
77
<authors>iText Software</authors>
88
<owners>iText Software</owners>
@@ -17,7 +17,7 @@
1717
<language>en-US</language>
1818
<tags>itext itext7 itextsharp c# .net csharp pdf cleanup pdfsweep</tags>
1919
<dependencies>
20-
<dependency id="itext7" version="7.0.6" />
20+
<dependency id="itext7" version="7.0.7" />
2121
</dependencies>
2222
</metadata>
2323
<files>

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0691d6f9bd3a7e313bdb0ba4010e65ef62ab19ad
1+
c465c21955d9a46eec96f84ed60b759f85fd2da9

0 commit comments

Comments
 (0)