pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1674145 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java
Date Thu, 16 Apr 2015 20:19:08 GMT
Author: tilman
Date: Thu Apr 16 20:19:07 2015
New Revision: 1674145

URL: http://svn.apache.org/r1674145
Log:
PDFBOX-2760: avoid NPE by checking that textLineMatrix exists

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java?rev=1674145&r1=1674144&r2=1674145&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/contentstream/operator/text/MoveText.java
Thu Apr 16 20:19:07 2015
@@ -18,6 +18,8 @@ package org.apache.pdfbox.contentstream.
 
 import java.util.List;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.contentstream.operator.MissingOperandException;
 import org.apache.pdfbox.contentstream.operator.Operator;
 import org.apache.pdfbox.contentstream.operator.OperatorProcessor;
@@ -32,6 +34,8 @@ import org.apache.pdfbox.util.Matrix;
  */
 public class MoveText extends OperatorProcessor
 {
+    private static final Log LOG = LogFactory.getLog(MoveText.class);
+
     @Override
     public void process(Operator operator, List<COSBase> arguments) throws MissingOperandException
     {
@@ -39,13 +43,19 @@ public class MoveText extends OperatorPr
         {
             throw new MissingOperandException(operator, arguments);
         }
+        Matrix textLineMatrix = context.getTextLineMatrix();
+        if (textLineMatrix == null)
+        {
+            LOG.warn("TextLineMatrix is null, " + getName() + " operator will be ignored");
+            return;
+        }        
         
         COSNumber x = (COSNumber)arguments.get( 0 );
         COSNumber y = (COSNumber)arguments.get( 1 );
 
         Matrix matrix = new Matrix(1, 0, 0, 1, x.floatValue(), y.floatValue());
-        context.getTextLineMatrix().concatenate(matrix);
-        context.setTextMatrix(context.getTextLineMatrix().clone());
+        textLineMatrix.concatenate(matrix);
+        context.setTextMatrix(textLineMatrix.clone());
     }
 
     @Override



Mime
View raw message