Feature #6557
closed
Add rendered metadata as pdf file in Morpho export
Added by Matt Jones over 10 years ago.
Updated about 10 years ago.
Description
Morpho currently exports metadata both as xml and html. Users have requested the rendered metadata also be provided in PDF format. Add stylesheets for rendering as PDF and include this in the export file.
The stylesheets for generating PDF can probably be general enough to be included in the EML package for many to use, and then simply imported and used within Morpho.
See related issue #6053 in Metacat for delivering Bagit packages. Ideally, Morpho's export would produce a Bagit compatible zip file equivalent to what one gets from Metacat.
Files
A couple comments/questions:
Using Apache FOP would be nice since we are going from XML->PDF. There's a ton in the FO spec for laying out the document format and the sky is kind of the limit on how we want it to look.
Do we want it to be exactly like the existing HTML metadata outputs?
Should it skinnable with the ability to add header graphics, change fonts, etc?
Super simple code to do the transformation:
public void export(String inputFile, String outputFile) throws IOException, DocumentException {
OutputStream os = new FileOutputStream(outputFile);
String tidyFile = inputFile + ".tidy";
OutputStream tidyOut = new FileOutputStream(tidyFile);
Tidy tidy = new Tidy();
tidy.setXHTML(true);
tidy.parse(new FileInputStream(inputFile), tidyOut);
String url = new File(tidyFile).toURI().toURL().toString();
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);
os.close();
}
I've added a class and corresponding test to the EML project that renders a sample EML file as both HTML and PDF using the default CSS. 'ant runonetest' will allow you to run it (HtmlToPdfTest is the default class to run). The output will be in build/tests/eml-sample.xml.html and build/tests/eml-sample.xml.pdf
- Project changed from Morpho to EML
- Assignee changed from ben leinfelder to Lauren Walker
Hoping Lauren can do a bit of work on the layout to make it narrow enough to fit on a page.
- Status changed from In Progress to Resolved
I styled the EML -> HTML output a bit to make it more modern and simple, and made sure that it converts to a PDF without running off the page.
Attached is a test EML->HTML->PDF that was generated using the ant runonetest HtmlToPdfTest
- Project changed from EML to Morpho
- Target version set to 1.10.3
Moving to Morpho release for feature tracking even though it is implemented in utilities project.
Also available in: Atom
PDF