jfree / orsonpdf Goto Github PK
View Code? Open in Web Editor NEWA fast, lightweight PDF generator for the Java platform
Home Page: https://github.com/jfree/orsonpdf
License: Other
A fast, lightweight PDF generator for the Java platform
Home Page: https://github.com/jfree/orsonpdf
License: Other
Hello,
I have an issue with fonts. Generally I use Dialog font but also some system fonts that are not default Java fonts but this library seems to support only default fonts (12 of 14 in fact). Exotic fonts are replaced by Courier, that is not good for me.
There is a way to embed them automatically ?
In code, The Pages.findOrCreateFontReference() method and its call to FontMApper.mapToBaseFont() seems to be the origin of font selection but I don't know how PDF format works.
Best regards,
I can't get Orson PDF to display non-English letters contained in the text when not rendering the text as vector graphic. I only get '???' where it should say "ØÆÅ". I have checked that the Font supports this letter using Font#canDisplay()
and it is of course installed on the system (checked using Font#getFamily()
being not equal to DIALOGUE
).
Font f = new Font("DejaVu Serif", PLAIN, 16);
graphics2D.setFont(f);
System.out.println("family" + f.getFamily() + " " + f.getName());
System.out.println("Can display Ø:" + f.canDisplay('Ø') );
//vector works
graphics2D.setRenderingHint(PDFHints.KEY_DRAW_STRING_TYPE, PDFHints.VALUE_DRAW_STRING_TYPE_VECTOR);
graphics2D.drawString("VECTOR: æøå ØÅÆ", 0, 20);
//normal text doesn't
graphics2D.setRenderingHint(PDFHints.KEY_DRAW_STRING_TYPE, PDFHints.VALUE_DRAW_STRING_TYPE_STANDARD);
graphics2D.drawString("TEXT: æøå ØÅÆ", 300, 20);
After calling Graphics2D tempGraphics = (Graphics2D) g2d.create();
and doing transformations on the tempGraphics object (see method code below), there is some unexpected behaviour.
When drawing again on the original g2d object, the drawing is done at wrong scale (and place).
In other words: the "Transform" of the original Graphics2D object gets changed by its copy.
private void drawString(Graphics2D g2d, String lb, double mmX, double mmY) {
float sf = 10; //fontscalefactor
AffineTransform scaled = AffineTransform.getScaleInstance(1d / sf, 1d / sf);
Graphics2D tempGraphics = (Graphics2D) g2d.create();
tempGraphics.transform(scaled);
tempGraphics.drawString(lb, (float)mmX * sf, (float)mmY * sf);
tempGraphics.dispose(); // Release system ressources
}
It seems that PDFGraphics2D.create() passes over the GraphicsStream object gs to the new Graphics object. So the original and new Graphics objects share gs. Maybe this is the reason transformations apply to both objects.
Note: jFreeSvg does not have this issue
In OrsonPDF Version 1.7 (downloaded from Object Refinery ), I tried to run the demo programs (under src/main/java/com/orsonpdf/demo) to verify that JFreeCharts indeed render as vector format pdfs.
PDFBarChartDemo1 seems to render a very beautiful PDF, so what I did is I copied the createChart()
and createDataset()
methods from it and put them in SwingUIToPDFDemo. Then I modified the createContent()
method, and changed the following line:
tabs.add("Tab 2", new JButton("Second Tab"));
to look as follows:
tabs.add("Tab 2", new ChartPanel(createChart(createDataset())));
When I run the SwingUIToPDFDemo now, on Tab 2 I get the same JFreeChart as I got when running the Bar Chart demo, yet when I press the "Save to PDF" button, the pdf that I get renders the chart as a raster chart rather than a vector chart.
Is there a workaround for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.