Git Product home page Git Product logo

Comments (3)

seifertm avatar seifertm commented on June 3, 2024

It's always nice to hear feedback from the users, thanks!
That's correct, VG2D enforces millimeters as units and there is clearly a need to specify measurements in other units.

I think this is closely related to the missing support for setting the DPI (or PPI) of a document (see issue #16). Currently, the pixel density is a constant value, which makes it difficult if you want to specify the size in pixels for example. If DPI can be adjusted, the VectorGraphics2D API could offer different means to set the size. From my current point of view, this approach would be preferable over multiple VG2D implementations. I cannot make any promises on when we will get around to implementing it, though. Sorry :/

from vectorgraphics2d.

nairnj avatar nairnj commented on June 3, 2024

I fixed it by scaling the graphics as shown below. The output PDF then had size in inches assuming pixels in java were 72 DPI (a hard coded number). On MacOS 10.8 with Java 6, this caused some setClip errors failing to validate rectangle, but I could not detect any consequences of those errors. On MacOS 10.11 (El Capitan) and Java 8, those errors went away (although now every time I open a PDF file in Adobe, it complains of problem with bounding box for 'Lucinda Grande" font even though I never use that font? Opening in Apple's Preview does not complain?)

Here is code snippet to create scaled PDF:

Dimension psize = plot2DView.getSize();
double scale = 25.4/72.;
double pwidth = scale*psize.width;
double pheight = scale*psize.height;
PDFGraphics2D g = new PDFGraphics2D(0.0, 0.0, pwidth, pheight);
AffineTransform savedState=g.getTransform();
g.scale(scale, scale);
plot2DView.paintComponent(g);
g.setTransform(savedState);

from vectorgraphics2d.

eseifert avatar eseifert commented on June 3, 2024

Thanks a lot for sharing your code @nairnj. That's definitely the workaround until a solution for issue #16 can be implemented.

Please, open new issues for the errors you mentioned, so we can solve them quickly.

from vectorgraphics2d.

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.