Reputation: 432
I am trying to transform an xml to pdf which contains formulas. I have added jeuclid jars to handle formula. Whole xml is transformed properly except the formulas. I am getting blank where there are formulas.
public class PDFCreation {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
PDFCreation pdfCreation = new PDFCreation();
try {
pdfCreation.convertToPDF("SPE.xsl", "IPTC-19048-MS.xml", "IPTC-19048-MS.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
public void convertToPDF(String xsl, String xml, String pdf) throws IOException, FOPException, TransformerException {
File xsltFile = new File(xsl);
StreamSource xmlSource = new StreamSource(new File(xml));
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
OutputStream out;
out = new java.io.FileOutputStream(pdf);
try {
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltFile));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(xmlSource, res);
} finally {
out.close();
}
}
}
EDIT: As requested adding console log
Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../Logo/IPTC_Logo.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../Logo/Separator.jpg. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_01.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_02.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_03.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_04.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_05.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_06.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_07.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_08.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_09.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent SEVERE: Image not found. URI: ../IPTC-19048-MS_fig_10.tif. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Arial,normal,700" not found. Substituting with "any,normal,700". Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400". Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. (No context info available) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent INFO: An fo:block (No context info available) is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4) Mar 18, 2019 12:58:52 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: The contents of fo:block line 1 exceed the available area in the inline-progression direction by 5880 millipoints. (No context info available) Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #1. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #2. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #3. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #4. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #5. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #6. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #7. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #8. Mar 18, 2019 12:58:53 PM org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #9.
I have not written anything for formula in my xsl as I read JEuclid handles it.
Upvotes: 0
Views: 620
Reputation: 1
Do you have the mathml namespace on your fo:root tag? Like so:
<fo:root xmlns: fo="http://www.w3.org/1999/XSL/Format" xmlns:mathml="http://www.w3.org/1998/Math/MathML">
Upvotes: 0