Skip to content

Commit 3ca54cc

Browse files
committed
[RELEASE] merging 'release/5.5.12' into 'master'
2 parents aa98a78 + 6e136be commit 3ca54cc

File tree

97 files changed

+2109
-431
lines changed

Some content is hidden

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

97 files changed

+2109
-431
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ iText is licensed as [AGPL][agpl] software.
2424

2525
AGPL is a free / open source software license.
2626

27-
This doesn't mean the software is gratis!
27+
This doesn't mean the software is [gratis][gratis]!
2828

2929
Buying a license is mandatory as soon as you develop commercial activities
3030
distributing the iText software inside your product or deploying it on a network
@@ -41,3 +41,4 @@ Contact sales for more info: http://itextpdf.com/sales
4141
[contributing]: CONTRIBUTING.md
4242
[extrajars]: EXTRAJARS.md
4343
[itext]: http://itextpdf.com/
44+
[gratis]: https://en.wikipedia.org/wiki/Gratis_versus_libre

itext/barcodeDataMatrix.pdf

1.51 KB
Binary file not shown.

itext/pom.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>itextpdf</artifactId>
13-
<version>5.5.11</version>
13+
<version>5.5.12</version>
1414

1515
<name>iText Core</name>
1616
<description>A Free Java-PDF library</description>
@@ -268,18 +268,6 @@
268268
<links>
269269
<link>http://developers.itextpdf.com/reference/classes</link>
270270
</links>
271-
<footer><![CDATA[
272-
<script>
273-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
274-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
275-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
276-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
277-
278-
ga('create', 'UA-11854164-1', 'itextpdf.com');
279-
ga('send', 'pageview');
280-
281-
</script>
282-
]]></footer>
283271
</configuration>
284272
</plugin>
285273
</plugins>

itext/src/main/java/com/itextpdf/awt/PdfGraphics2D.java

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,15 @@ private static final class Kid {
202202
private Graphics2D getDG2() {
203203
if (dg2 == null) {
204204
dg2 = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB).createGraphics();
205-
dg2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
206-
setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
207-
setRenderingHint(HyperLinkKey.KEY_INSTANCE, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
205+
dg2.setRenderingHints(rhints);
208206
}
209207
return dg2;
210208
}
211209

212-
private PdfGraphics2D() {}
210+
private PdfGraphics2D() {
211+
setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
212+
setRenderingHint(HyperLinkKey.KEY_INSTANCE, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
213+
}
213214

214215
public PdfGraphics2D(PdfContentByte cb, final float width, final float height) {
215216
this(cb, width, height, null, false, false, 0);
@@ -507,21 +508,32 @@ public void drawString(String s, float x, float y) {
507508

508509
double width = 0;
509510
if (font.getSize2D() > 0) {
510-
float scale = 1000 / font.getSize2D();
511-
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
512-
width = derivedFont.getStringBounds(s, getFontRenderContext()).getWidth();
513-
if (derivedFont.isTransformed())
514-
width /= scale;
511+
if (RenderingHints.VALUE_FRACTIONALMETRICS_OFF.equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS))) {
512+
width = font.getStringBounds(s, getFontRenderContext()).getWidth();
513+
} else {
514+
float scale = 1000 / font.getSize2D();
515+
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
516+
width = derivedFont.getStringBounds(s, getFontRenderContext()).getWidth();
517+
if (derivedFont.isTransformed())
518+
width /= scale;
519+
}
515520
}
516521
// if the hyperlink flag is set add an action to the text
517522
Object url = getRenderingHint(HyperLinkKey.KEY_INSTANCE);
518523
if (url != null && !url.equals(HyperLinkKey.VALUE_HYPERLINKKEY_OFF))
519524
{
520-
float scale = 1000 / font.getSize2D();
521-
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
522-
double height = derivedFont.getStringBounds(s, getFontRenderContext()).getHeight();
523-
if (derivedFont.isTransformed())
524-
height /= scale;
525+
double height = 0;
526+
if (font.getSize2D() > 0) {
527+
if (RenderingHints.VALUE_FRACTIONALMETRICS_OFF.equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS))) {
528+
height = font.getStringBounds(s, getFontRenderContext()).getHeight();
529+
} else {
530+
float scale = 1000 / font.getSize2D();
531+
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
532+
height = derivedFont.getStringBounds(s, getFontRenderContext()).getHeight();
533+
if (derivedFont.isTransformed())
534+
height /= scale;
535+
}
536+
}
525537
double leftX = cb.getXTLM();
526538
double leftY = cb.getYTLM();
527539
PdfAction action = new PdfAction(url.toString());
@@ -817,32 +829,33 @@ public void setStroke(Stroke s) {
817829

818830
/**
819831
* Sets a rendering hint
820-
* @param arg0
821-
* @param arg1
832+
* @param hintKey
833+
* @param hintValue
822834
*/
823835
@Override
824-
public void setRenderingHint(Key arg0, Object arg1) {
825-
if (arg1 != null) {
826-
rhints.put(arg0, arg1);
836+
public void setRenderingHint(Key hintKey, Object hintValue) {
837+
if (hintValue != null) {
838+
rhints.put(hintKey, hintValue);
827839
} else {
828-
if (arg0 instanceof HyperLinkKey)
829-
{
830-
rhints.put(arg0, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
840+
if (hintKey instanceof HyperLinkKey) {
841+
rhints.put(hintKey, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
831842
}
832-
else
833-
{
834-
rhints.remove(arg0);
843+
else {
844+
rhints.remove(hintKey);
835845
}
836846
}
847+
if (dg2 != null) {
848+
dg2.setRenderingHint(hintKey, hintValue);
849+
}
837850
}
838851

839852
/**
840-
* @param arg0 a key
853+
* @param hintKey a key
841854
* @return the rendering hint
842855
*/
843856
@Override
844-
public Object getRenderingHint(Key arg0) {
845-
return rhints.get(arg0);
857+
public Object getRenderingHint(Key hintKey) {
858+
return rhints.get(hintKey);
846859
}
847860

848861
/**
@@ -852,6 +865,9 @@ public Object getRenderingHint(Key arg0) {
852865
public void setRenderingHints(Map<?,?> hints) {
853866
rhints.clear();
854867
rhints.putAll(hints);
868+
if (dg2 != null) {
869+
dg2.setRenderingHints(hints);
870+
}
855871
}
856872

857873
/**
@@ -860,6 +876,9 @@ public void setRenderingHints(Map<?,?> hints) {
860876
@Override
861877
public void addRenderingHints(Map<?,?> hints) {
862878
rhints.putAll(hints);
879+
if (dg2 != null) {
880+
dg2.addRenderingHints(hints);
881+
}
863882
}
864883

865884
/**

itext/src/main/java/com/itextpdf/testutils/CompareTool.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import java.io.InputStream;
8080
import java.io.InputStreamReader;
8181
import java.io.OutputStream;
82+
import java.io.StringReader;
8283
import java.util.ArrayList;
8384
import java.util.Arrays;
8485
import java.util.Comparator;
@@ -91,6 +92,7 @@
9192
import java.util.StringTokenizer;
9293
import java.util.TreeSet;
9394

95+
import javax.xml.XMLConstants;
9496
import javax.xml.parsers.DocumentBuilder;
9597
import javax.xml.parsers.DocumentBuilderFactory;
9698
import javax.xml.parsers.ParserConfigurationException;
@@ -104,6 +106,8 @@
104106
import org.w3c.dom.Document;
105107
import org.w3c.dom.Element;
106108
import org.w3c.dom.Node;
109+
import org.xml.sax.EntityResolver;
110+
import org.xml.sax.InputSource;
107111
import org.xml.sax.SAXException;
108112

109113
/**
@@ -375,6 +379,9 @@ public void writeReportToXml(OutputStream stream) throws ParserConfigurationExce
375379
xmlReport.appendChild(root);
376380

377381
TransformerFactory tFactory = TransformerFactory.newInstance();
382+
try {
383+
tFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, true);
384+
} catch (Exception exc) {}
378385
Transformer transformer = tFactory.newTransformer();
379386
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
380387
DOMSource source = new DOMSource(xmlReport);
@@ -1193,6 +1200,7 @@ public boolean compareXmls(byte[] xml1, byte[] xml2) throws ParserConfigurationE
11931200
dbf.setIgnoringElementContentWhitespace(true);
11941201
dbf.setIgnoringComments(true);
11951202
DocumentBuilder db = dbf.newDocumentBuilder();
1203+
db.setEntityResolver(new SafeEmptyEntityResolver());
11961204

11971205
org.w3c.dom.Document doc1 = db.parse(new ByteArrayInputStream(xml1));
11981206
doc1.normalizeDocument();
@@ -1343,6 +1351,7 @@ public boolean compareXmls(String xml1, String xml2) throws ParserConfigurationE
13431351
dbf.setIgnoringElementContentWhitespace(true);
13441352
dbf.setIgnoringComments(true);
13451353
DocumentBuilder db = dbf.newDocumentBuilder();
1354+
db.setEntityResolver(new SafeEmptyEntityResolver());
13461355

13471356
org.w3c.dom.Document doc1 = db.parse(new File(xml1));
13481357
doc1.normalizeDocument();
@@ -1486,5 +1495,11 @@ public void renderImage(ImageRenderInfo renderInfo) {
14861495

14871496
}
14881497

1498+
private static class SafeEmptyEntityResolver implements EntityResolver {
1499+
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
1500+
return new InputSource(new StringReader(""));
1501+
}
1502+
}
1503+
14891504

14901505
}

itext/src/main/java/com/itextpdf/text/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class Version {
7070
* This String contains the version number of this iText release.
7171
* For debugging purposes, we request you NOT to change this constant.
7272
*/
73-
private String release = "5.5.11";
73+
private String release = "5.5.12";
7474
/**
7575
* This String contains the iText version as shown in the producer line.
7676
* iText is a product developed by iText Group NV.

0 commit comments

Comments
 (0)