You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.1 KiB
55 lines
2.1 KiB
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 <xsl:template name=\"kopf_zeile\"> (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(); |
|
|
|
} |
|
} |
|
}
|
|
|