Comments (3)
You can always force drawing text with shape by using the default TextDrawer, or setting it to PdfBoxGraphics2DFontTextDrawer, i.e.
gfx.setFontTextDrawer(new PdfBoxGraphics2DFontTextDrawer());
But you could instead just use a normal transform on the Graphics2D to rotate the text:
AffineTransform saveTF = gfx.getTransform();
AffineTransform at = AffineTransform.getTranslateInstance(100, 150);
at.rotate(Math.toRadians(-90), 0, 0);
gfx.setColor(Color.RED);
gfx.setFont(horizontalFont);
gfx.setTransform(at);
gfx.drawString("Some sample text", 0, 0);
gfx.setTransform(saveTF);
I.e. you do a:
- save the current (transform) state
- move to the place where the text should be drawn
- now rotate
- draw the text
- restore the current (transform) state
But I'll try to look into this. Maybe this can be made work with font files.
from pdfbox-graphics2d.
Thanks for the answer, I did just what you have suggested, which was rotating the gc -90 deg and back.
I have tried setting PdfBoxGraphics2DFontTextDrawer which also worked, it may be good to access the used FontTextDrawer, sou you could switch them back and forth as you go.
Is there a reason why you havent accesed the get method for used FontTextDrawer? Im just curious.
BTW, I really appreciate that you have answered on sunday!
from pdfbox-graphics2d.
The gfx has currently no getFontTextDrawer() method, and I'm not sure if this is method is really needed. I got your basic sample working with fonts, I'm just need to debug the case with attributed text, thats not really working yet.
Well on sundays it's more likely that I've time for this project ;-)
from pdfbox-graphics2d.
Related Issues (20)
- fontRenderingContext is not good for vector drawing HOT 2
- Adding jaxb-api in the pom of extended-tests HOT 6
- Adding test scope to outer dependencies in the pom of extended-tests HOT 1
- PdfBoxGraphics2DFontTextDrawer.getFontMetrics always floors the width HOT 3
- stop-opacity on linearGradient stops are not rendered HOT 3
- Document how to reuse / share images inside a document across different Graphics2D
- Correctly support embedding the same image with different KEY_INTERPOLATION values. HOT 1
- mapColor parameters in RGBtoCMYKColorMapper HOT 1
- What is a good way to handle "Page N of M" drawing? HOT 2
- TestPPTXRendering.testPPTXRendering failing with libapache-poi-java from Debian 12 HOT 2
- RadialGradientPaint incorrect focal point location and transition direction HOT 1
- drawIssue with incorrect argument HOT 1
- drawRect does not properly close rectangle HOT 2
- Exception in RadialGradientPaint HOT 4
- System.err in PdfBoxGraphics2DFontTextDrawer HOT 8
- Draw Attributed text only supports Font, while Family/Weight/Posture is an alternate way. HOT 4
- add pdfbox 3.0.0 support HOT 3
- InternalDeprecatedCOSCloner causing JPMS module issues HOT 3
- Reuse PDFCloneUtilities.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdfbox-graphics2d.