-
Notifications
You must be signed in to change notification settings - Fork 1.6k
How to export to PDF or SVG
sheymann edited this page Jan 4, 2015
·
1 revision
This Toolkit Example is part of the toolkit-demos project, that can be downloaded from the website.
Preview is the last step before export and allows display customization and aesthetics refinements. It works with the current workspace. The example below shows how to change edge coloring mode, edge thickness and label font size. See PreviewAPI documentation.
//Preview
PreviewModel model = Lookup.getDefault().lookup(PreviewController.class).getModel();
PreviewProperties prop = model.getProperties();
prop.putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);
prop.putValue(PreviewProperty.EDGE_COLOR, new EdgeColor(Color.GRAY));
prop.putValue(PreviewProperty.EDGE_THICKNESS, new Float(0.1f));
prop.putValue(PreviewProperty.NODE_LABEL_FONT, prop.getFontValue(PreviewProperty.NODE_LABEL_FONT).deriveFont(8));
The PDF and SVG exporter works with settings made in Preview. As with all exporters, it is possible to write the result in a Writer or OutputStream. In the exemple below the PDFExporter is retrieved and configured.
//Simple PDF export
ExportController ec = Lookup.getDefault().lookup(ExportController.class);
try {
ec.exportFile(new File("simple.pdf"));
} catch (IOException ex) {
ex.printStackTrace();
return;
}
//PDF Exporter config and export to Byte array
PDFExporter pdfExporter = (PDFExporter) ec.getExporter("pdf");
pdfExporter.setPageSize(PageSize.A0);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ec.exportStream(baos, pdfExporter);
byte[] pdf = baos.toByteArray();
- Developer Handbook
- Build
- Code Style
- Localization
- Datasets
- Import CSV Data
- Import Dynamic Data
- Scripting Plugin
- Quick Start
- Démarrage rapide (FR)
- Layout
- Spatialisations (FR)
- Statistics
- Import
- Spigot importer with Wizard
- Export
- Generator
- Filter
- Extend Data Laboratory
- Preview renderer
- Add a module panel
- Add a submenu
- Build a plugin without Gephi source code
- Update a plugin
- Code Sharing Strategy
- Graph Streaming