package de.superx.bin; import java.io.File; import de.memtext.util.GetOpts; import de.memtext.util.StringUtils; import de.memtext.util.TransletUtils; import de.superx.servlet.XmlTransformer; public class ExcelPdfCreator { /** * @param args */ public static void main(String[] args) { try { System.out.println("Wenn Grafiken in PDF eingebunden werden sollen, muss in (tabelle_fo_pdf_kopffusszeile.xsl)\n"+ "Richtige Pfade für Standalonebetrieb eingestellt werden, beispielweise in eigener pageComponents_html_final.xsl"); GetOpts.setOpts(args); String isdrin = GetOpts.isAllRequiredOptionsPresent("-in,-xsl,-out"); if (isdrin != null) { System.err.println("-fopxconf (Pfad dazu - optional) -in -xsl -out Endung auf .xsl=Excel .pdf=PDF"); System.exit(1); } System.out.println("Lokalisierung per sx_captions derzeit nicht unterstuetzt!"); String in = GetOpts.getValue("-in"); String xsl = GetOpts.getValue("-xsl"); String out = GetOpts.getValue("-out"); TransletUtils.initFactory("net.sf.saxon.TransformerFactoryImpl", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); XmlTransformer xt = new XmlTransformer(null, null, null, null, null); if (out.endsWith(".xls") || out.endsWith(".xlsx")) { xt.createExcelStandalone(StringUtils.readFile(new File(in)), xsl, out); System.out.println("Datei erzeugt"); } if (out.endsWith(".pdf")) { File conf=null; if (GetOpts.isPresent("-fopxconf")) conf=new File(GetOpts.getOpt("-fopxconf").replaceAll("-fopxconf:", "")); xt.createPdfStandalone(conf,StringUtils.readFile(new File(in)), xsl, out); System.out.println("Datei erzeugt"); } } catch (Exception e) { System.out.println("Fehler : " + e); e.printStackTrace(); } } }