Skip to content

Commit

Permalink
[RELEASE] merging 'release/5.5.12' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
amedee committed Aug 17, 2017
2 parents aa98a78 + 6e136be commit 3ca54cc
Show file tree
Hide file tree
Showing 97 changed files with 2,109 additions and 431 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ iText is licensed as [AGPL][agpl] software.

AGPL is a free / open source software license.

This doesn't mean the software is gratis!
This doesn't mean the software is [gratis][gratis]!

Buying a license is mandatory as soon as you develop commercial activities
distributing the iText software inside your product or deploying it on a network
Expand All @@ -41,3 +41,4 @@ Contact sales for more info: http://itextpdf.com/sales
[contributing]: CONTRIBUTING.md
[extrajars]: EXTRAJARS.md
[itext]: http://itextpdf.com/
[gratis]: https://en.wikipedia.org/wiki/Gratis_versus_libre
Binary file added itext/barcodeDataMatrix.pdf
Binary file not shown.
14 changes: 1 addition & 13 deletions itext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>itextpdf</artifactId>
<version>5.5.11</version>
<version>5.5.12</version>

<name>iText Core</name>
<description>A Free Java-PDF library</description>
Expand Down Expand Up @@ -268,18 +268,6 @@
<links>
<link>http://developers.itextpdf.com/reference/classes</link>
</links>
<footer><![CDATA[
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-11854164-1', 'itextpdf.com');
ga('send', 'pageview');
</script>
]]></footer>
</configuration>
</plugin>
</plugins>
Expand Down
75 changes: 47 additions & 28 deletions itext/src/main/java/com/itextpdf/awt/PdfGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ private static final class Kid {
private Graphics2D getDG2() {
if (dg2 == null) {
dg2 = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB).createGraphics();
dg2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
setRenderingHint(HyperLinkKey.KEY_INSTANCE, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
dg2.setRenderingHints(rhints);
}
return dg2;
}

private PdfGraphics2D() {}
private PdfGraphics2D() {
setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
setRenderingHint(HyperLinkKey.KEY_INSTANCE, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
}

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

double width = 0;
if (font.getSize2D() > 0) {
float scale = 1000 / font.getSize2D();
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
width = derivedFont.getStringBounds(s, getFontRenderContext()).getWidth();
if (derivedFont.isTransformed())
width /= scale;
if (RenderingHints.VALUE_FRACTIONALMETRICS_OFF.equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS))) {
width = font.getStringBounds(s, getFontRenderContext()).getWidth();
} else {
float scale = 1000 / font.getSize2D();
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
width = derivedFont.getStringBounds(s, getFontRenderContext()).getWidth();
if (derivedFont.isTransformed())
width /= scale;
}
}
// if the hyperlink flag is set add an action to the text
Object url = getRenderingHint(HyperLinkKey.KEY_INSTANCE);
if (url != null && !url.equals(HyperLinkKey.VALUE_HYPERLINKKEY_OFF))
{
float scale = 1000 / font.getSize2D();
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
double height = derivedFont.getStringBounds(s, getFontRenderContext()).getHeight();
if (derivedFont.isTransformed())
height /= scale;
double height = 0;
if (font.getSize2D() > 0) {
if (RenderingHints.VALUE_FRACTIONALMETRICS_OFF.equals(getRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS))) {
height = font.getStringBounds(s, getFontRenderContext()).getHeight();
} else {
float scale = 1000 / font.getSize2D();
Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale));
height = derivedFont.getStringBounds(s, getFontRenderContext()).getHeight();
if (derivedFont.isTransformed())
height /= scale;
}
}
double leftX = cb.getXTLM();
double leftY = cb.getYTLM();
PdfAction action = new PdfAction(url.toString());
Expand Down Expand Up @@ -817,32 +829,33 @@ public void setStroke(Stroke s) {

/**
* Sets a rendering hint
* @param arg0
* @param arg1
* @param hintKey
* @param hintValue
*/
@Override
public void setRenderingHint(Key arg0, Object arg1) {
if (arg1 != null) {
rhints.put(arg0, arg1);
public void setRenderingHint(Key hintKey, Object hintValue) {
if (hintValue != null) {
rhints.put(hintKey, hintValue);
} else {
if (arg0 instanceof HyperLinkKey)
{
rhints.put(arg0, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
if (hintKey instanceof HyperLinkKey) {
rhints.put(hintKey, HyperLinkKey.VALUE_HYPERLINKKEY_OFF);
}
else
{
rhints.remove(arg0);
else {
rhints.remove(hintKey);
}
}
if (dg2 != null) {
dg2.setRenderingHint(hintKey, hintValue);
}
}

/**
* @param arg0 a key
* @param hintKey a key
* @return the rendering hint
*/
@Override
public Object getRenderingHint(Key arg0) {
return rhints.get(arg0);
public Object getRenderingHint(Key hintKey) {
return rhints.get(hintKey);
}

/**
Expand All @@ -852,6 +865,9 @@ public Object getRenderingHint(Key arg0) {
public void setRenderingHints(Map<?,?> hints) {
rhints.clear();
rhints.putAll(hints);
if (dg2 != null) {
dg2.setRenderingHints(hints);
}
}

/**
Expand All @@ -860,6 +876,9 @@ public void setRenderingHints(Map<?,?> hints) {
@Override
public void addRenderingHints(Map<?,?> hints) {
rhints.putAll(hints);
if (dg2 != null) {
dg2.addRenderingHints(hints);
}
}

/**
Expand Down
15 changes: 15 additions & 0 deletions itext/src/main/java/com/itextpdf/testutils/CompareTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand All @@ -91,6 +92,7 @@
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand All @@ -104,6 +106,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

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

TransformerFactory tFactory = TransformerFactory.newInstance();
try {
tFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (Exception exc) {}
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
DOMSource source = new DOMSource(xmlReport);
Expand Down Expand Up @@ -1193,6 +1200,7 @@ public boolean compareXmls(byte[] xml1, byte[] xml2) throws ParserConfigurationE
dbf.setIgnoringElementContentWhitespace(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());

org.w3c.dom.Document doc1 = db.parse(new ByteArrayInputStream(xml1));
doc1.normalizeDocument();
Expand Down Expand Up @@ -1343,6 +1351,7 @@ public boolean compareXmls(String xml1, String xml2) throws ParserConfigurationE
dbf.setIgnoringElementContentWhitespace(true);
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());

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

}

private static class SafeEmptyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
}


}
2 changes: 1 addition & 1 deletion itext/src/main/java/com/itextpdf/text/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public final class Version {
* This String contains the version number of this iText release.
* For debugging purposes, we request you NOT to change this constant.
*/
private String release = "5.5.11";
private String release = "5.5.12";
/**
* This String contains the iText version as shown in the producer line.
* iText is a product developed by iText Group NV.
Expand Down
Loading

0 comments on commit 3ca54cc

Please sign in to comment.