Comments (3)
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.
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.
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)
- Improve javadoc HOT 1
- Deprecate VectorGraphics2D.getBytes() HOT 1
- Remove interface CommandHandler HOT 1
- Update wiki documentation HOT 1
- Move compression property from Processors to Documents HOT 1
- Remove close method from Document HOT 1
- Filters should operate on CommandSequence HOT 1
- Replace StreamingFilter with simpler implementation
- Improve structure of PDFDocument
- support alternative (non-base64) url for image data HOT 1
- Fix number handling for PDF output HOT 2
- Flate compression for PDF is not working
- vg2d.getCommands(); is undefined for type Graphics2D HOT 1
- bad /BBox in font 'Dialog.plain' HOT 2
- Managing GraphicsState with a Stack is unsafe HOT 3
- Bug in pdfProcessor when the PageSize starting y axis differs from zero? HOT 1
- Can multiple graphics be saved in a single PDF file? HOT 3
- Casting error
- this software is only licensed under GPL? HOT 1
- Set an automatic module name in the Jar MANIFEST HOT 2
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 vectorgraphics2d.