[
https://issues.apache.org/jira/browse/PDFBOX-2141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14031228#comment-14031228
]
Petr Slaby commented on PDFBOX-2141:
------------------------------------
The following seems to make the trick, tested on a single file so far, though:
{noformat}
private void writeFont(final AffineTransform at, final GlyphVector glyphs)
{
// Convert from PDF, where glyphs are upright when direction is from
// bottom to top, to AWT, where this is the other way around
at.scale(1, -1);
for(int i=0; i<glyphs.getNumGlyphs(); i++)
{
AffineTransform glyphTransform = glyphs.getGlyphTransform(i);
Point2D glyphPos = glyphs.getGlyphPosition(i);
AffineTransform applyTransform;
if(glyphTransform != null || glyphPos.getX() != 0 ||
glyphPos.getY() != 0) {
AffineTransform translate =
AffineTransform.getTranslateInstance(glyphPos.getX(), glyphPos.getY());
if(glyphTransform != null)
{
translate.concatenate(glyphTransform);
}
translate.preConcatenate(at);
applyTransform = translate;
glyphs.setGlyphPosition(i, new Point2D.Float(0, 0));
}
else
{
applyTransform = at;
}
glyphs.setGlyphTransform(i, applyTransform);
}
graphics.drawGlyphVector(glyphs, 0, 0);
}
{noformat}
> Shading not applied to text
> ---------------------------
>
> Key: PDFBOX-2141
> URL: https://issues.apache.org/jira/browse/PDFBOX-2141
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.0
> Reporter: Petr Slaby
> Priority: Minor
> Attachments: 000004_ShadingPatternTextPDF.pdf, PDFBOX-1917.pdf-1.png,
> PDFBOX-1917.pdf-1.png-diff.png, PDFBOX-1917.pdf-9.png,
> PDFBOX-1917.pdf-9.png-diff.png, PDFBOX-2135.pdf-2.png,
> PDFBOX-2135.pdf-2.png-diff.png, PageDrawer.writeFont.java.patch
>
>
> The attached PDF draws a text filled with horizontal shading going from red
> to blue. When rendered via PDFBox, the text is completely filled with red.
> The problem is that AxialShadingContext#getRaster() gets called with
> positions that completely fell outside of the range stored in its coords[]
> field. The fix seems to be to set glyph transform rather than graphics2d
> transform in PageDrawer#writeText() as shown in the attached patch.
--
This message was sent by Atlassian JIRA
(v6.2#6252)