Giter VIP home page Giter VIP logo

Comments (3)

rototor avatar rototor commented on May 24, 2024

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.

c4da avatar c4da commented on May 24, 2024

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.

rototor avatar rototor commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.