RED-8800: revert cropbox adjustment
This commit is contained in:
parent
785ff0dc4b
commit
da8854ba37
@ -82,6 +82,7 @@ public class LegacyPDFStreamEngine extends PDFStreamEngine {
|
|||||||
|
|
||||||
private int pageRotation;
|
private int pageRotation;
|
||||||
private PDRectangle pageSize;
|
private PDRectangle pageSize;
|
||||||
|
private Matrix translateMatrix;
|
||||||
private final GlyphList glyphList;
|
private final GlyphList glyphList;
|
||||||
private final Map<COSDictionary, Float> fontHeightMap = new WeakHashMap<COSDictionary, Float>();
|
private final Map<COSDictionary, Float> fontHeightMap = new WeakHashMap<COSDictionary, Float>();
|
||||||
|
|
||||||
@ -133,6 +134,12 @@ public class LegacyPDFStreamEngine extends PDFStreamEngine {
|
|||||||
this.pageRotation = page.getRotation();
|
this.pageRotation = page.getRotation();
|
||||||
this.pageSize = page.getCropBox();
|
this.pageSize = page.getCropBox();
|
||||||
|
|
||||||
|
if (pageSize.getLowerLeftX() == 0 && pageSize.getLowerLeftY() == 0) {
|
||||||
|
translateMatrix = null;
|
||||||
|
} else {
|
||||||
|
// translation matrix for cropbox
|
||||||
|
translateMatrix = Matrix.getTranslateInstance(-pageSize.getLowerLeftX(), -pageSize.getLowerLeftY());
|
||||||
|
}
|
||||||
super.processPage(page);
|
super.processPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,13 +264,22 @@ public class LegacyPDFStreamEngine extends PDFStreamEngine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// adjust for cropbox if needed
|
||||||
|
Matrix translatedTextRenderingMatrix;
|
||||||
|
if (translateMatrix == null) {
|
||||||
|
translatedTextRenderingMatrix = textRenderingMatrix;
|
||||||
|
} else {
|
||||||
|
translatedTextRenderingMatrix = Matrix.concatenate(translateMatrix, textRenderingMatrix);
|
||||||
|
nextX -= pageSize.getLowerLeftX();
|
||||||
|
nextY -= pageSize.getLowerLeftY();
|
||||||
|
}
|
||||||
|
|
||||||
// This is a hack for unicode letter with 2 chars e.g. RA see unicodeProblem.pdf
|
// This is a hack for unicode letter with 2 chars e.g. RA see unicodeProblem.pdf
|
||||||
if (unicodeMapping.length() == 2) {
|
if (unicodeMapping.length() == 2) {
|
||||||
processTextPosition(new TextPosition(pageRotation,
|
processTextPosition(new TextPosition(pageRotation,
|
||||||
pageSize.getWidth(),
|
pageSize.getWidth(),
|
||||||
pageSize.getHeight(),
|
pageSize.getHeight(),
|
||||||
textRenderingMatrix,
|
translatedTextRenderingMatrix,
|
||||||
nextX,
|
nextX,
|
||||||
nextY,
|
nextY,
|
||||||
Math.abs(dyDisplay),
|
Math.abs(dyDisplay),
|
||||||
@ -277,7 +293,7 @@ public class LegacyPDFStreamEngine extends PDFStreamEngine {
|
|||||||
processTextPosition(new TextPosition(pageRotation,
|
processTextPosition(new TextPosition(pageRotation,
|
||||||
pageSize.getWidth(),
|
pageSize.getWidth(),
|
||||||
pageSize.getHeight(),
|
pageSize.getHeight(),
|
||||||
textRenderingMatrix,
|
translatedTextRenderingMatrix,
|
||||||
nextX,
|
nextX,
|
||||||
nextY,
|
nextY,
|
||||||
Math.abs(dyDisplay),
|
Math.abs(dyDisplay),
|
||||||
@ -293,7 +309,7 @@ public class LegacyPDFStreamEngine extends PDFStreamEngine {
|
|||||||
processTextPosition(new TextPosition(pageRotation,
|
processTextPosition(new TextPosition(pageRotation,
|
||||||
pageSize.getWidth(),
|
pageSize.getWidth(),
|
||||||
pageSize.getHeight(),
|
pageSize.getHeight(),
|
||||||
textRenderingMatrix,
|
translatedTextRenderingMatrix,
|
||||||
nextX,
|
nextX,
|
||||||
nextY,
|
nextY,
|
||||||
Math.abs(dyDisplay),
|
Math.abs(dyDisplay),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user