// Path: src/main/java/org/docx4j/convert/out/XSLFO/XSLFOExporterNonXSLT.java
// public class XSLFOExporterNonXSLT {
// 	private static Logger log = LoggerFactory.getLogger(XSLFOExporterNonXSLT.class);
// 	protected static final int DEFAULT_OUTPUT_SIZE = 102400;
// 
// 	FOSettings foSettings = null;
// 	
// 	public XSLFOExporterNonXSLT(WordprocessingMLPackage wmlPackage, 
// 			FOSettings  pdfSettings) {
// 
// 		foSettings = pdfSettings;
// 		if ((foSettings.getWmlPackage() == null) && (wmlPackage != null)) {
// 			foSettings.setWmlPackage(wmlPackage);
// 		}
// 	}
// 	
// 	/**
// 	 * Generate XSL FO for the entire MainDocumentPart.
// 	 * @return
// 	 */
// 	public org.w3c.dom.Document export() throws Docx4JException {
// 	ByteArrayOutputStream outStream = new ByteArrayOutputStream(DEFAULT_OUTPUT_SIZE);
// 	Document ret = null;
// 		foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);
// 		try {
// 			Docx4J.toFO(foSettings, outStream, Docx4J.FLAG_EXPORT_PREFER_NONXSL);
// 			ret = XmlUtils.getNewDocumentBuilder().parse(new ByteArrayInputStream(outStream.toByteArray()));
// 		} catch (Docx4JException e) {
// 			log.error("Exception exporting document: " + e.getMessage(), e);
// 		} catch (SAXException e) {
// 			log.error("Exception parsing document: " + e.getMessage(), e);
// 		} catch (IOException e) {
// 			log.error("Exception parsing document: " + e.getMessage(), e);
// 		}
// 		return ret;
// 	}
// 	
// 
// // ========================================================================	
// 	public void output(Document xslfo, OutputStream os, Configuration fopConfigZZZ) throws Docx4JException {
// 	FORenderer renderer = FORendererApacheFOP.getInstance();
// 	String foDocument = XmlUtils.w3CDomNodeToString(xslfo);
// 		renderer.render(foDocument, foSettings, false, null, os);
// 	}
// }


import java.io.OutputStream;
import org.docx4j.XmlUtils;
import org.docx4j.convert.out.FOSettings;
import org.docx4j.convert.out.XSLFO.XSLFOExporterNonXSLT;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.w3c.dom.Document;
/*
 *  Copyright 2012, Plutext Pty Ltd.
 *   
 *  This file is part of docx4j.

    docx4j is licensed under the Apache License, Version 2.0 (the "License"); 
    you may not use this file except in compliance with the License. 

    You may obtain a copy of the License at 

        http://www.apache.org/licenses/LICENSE-2.0 

    Unless required by applicable law or agreed to in writing, software 
    distributed under the License is distributed on an "AS IS" BASIS, 
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    See the License for the specific language governing permissions and 
    limitations under the License.

 */
package org.docx4j.samples;



/**
 * 
 * Running Xalan extension functions on Android is problematic:
 * 
 *   http://stackoverflow.com/questions/10579339/is-it-possible-to-call-a-java-extension-function-from-xalan-on-android
 * 
 * and generating the XSL FO via Xalan + extension functions 
 * is a bit slow,   
 * so this uses TraversalUtils to generate XSL FO output
 * without any need for Xalan or XSLT.
 * 
 */
public class FONonXSLT {
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		String inputfilepath;	
		String outputfilepath;		

		inputfilepath = System.getProperty("user.dir")
//				+ "/hlink.docx";
//		+ "/OpenXML_1ed_Part4.docx";
//		+ "/sample-docs/word/sample-docx.docx";
//		+ "/sample-docs/word/2003/word2003-vml.docx";
//				+ "/table-nested.docx";
//		+ "/sample-docs/word/headers.docx";
		+ "/sample-docs/word/sample-docxv2.docx";		
		
		WordprocessingMLPackage wmlPackage = WordprocessingMLPackage
				.load(new java.io.File(inputfilepath));
		
		FOSettings pdfSettings = new FOSettings();
		pdfSettings.setWmlPackage(wmlPackage);
		
		
// Path: src/main/java/org/docx4j/convert/out/XSLFO/XSLFOExporterNonXSLT.java
// public class XSLFOExporterNonXSLT {
// 	private static Logger log = LoggerFactory.getLogger(XSLFOExporterNonXSLT.class);
// 	protected static final int DEFAULT_OUTPUT_SIZE = 102400;
// 
// 	FOSettings foSettings = null;
// 	
// 	public XSLFOExporterNonXSLT(WordprocessingMLPackage wmlPackage, 
// 			FOSettings  pdfSettings) {
// 
// 		foSettings = pdfSettings;
// 		if ((foSettings.getWmlPackage() == null) && (wmlPackage != null)) {
// 			foSettings.setWmlPackage(wmlPackage);
// 		}
// 	}
// 	
// 	/**
// 	 * Generate XSL FO for the entire MainDocumentPart.
// 	 * @return
// 	 */
// 	public org.w3c.dom.Document export() throws Docx4JException {
// 	ByteArrayOutputStream outStream = new ByteArrayOutputStream(DEFAULT_OUTPUT_SIZE);
// 	Document ret = null;
// 		foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);
// 		try {
// 			Docx4J.toFO(foSettings, outStream, Docx4J.FLAG_EXPORT_PREFER_NONXSL);
// 			ret = XmlUtils.getNewDocumentBuilder().parse(new ByteArrayInputStream(outStream.toByteArray()));
// 		} catch (Docx4JException e) {
// 			log.error("Exception exporting document: " + e.getMessage(), e);
// 		} catch (SAXException e) {
// 			log.error("Exception parsing document: " + e.getMessage(), e);
// 		} catch (IOException e) {
// 			log.error("Exception parsing document: " + e.getMessage(), e);
// 		}
// 		return ret;
// 	}
// 	
// 
// // ========================================================================	
// 	public void output(Document xslfo, OutputStream os, Configuration fopConfigZZZ) throws Docx4JException {
// 	FORenderer renderer = FORendererApacheFOP.getInstance();
// 	String foDocument = XmlUtils.w3CDomNodeToString(xslfo);
// 		renderer.render(foDocument, foSettings, false, null, os);
// 	}
// }


// Path: src/samples/docx4j/org/docx4j/samples/FONonXSLT.java
import java.io.OutputStream;
import org.docx4j.XmlUtils;
import org.docx4j.convert.out.FOSettings;
import org.docx4j.convert.out.XSLFO.XSLFOExporterNonXSLT;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.w3c.dom.Document;

/*
 *  Copyright 2012, Plutext Pty Ltd.
 *   
 *  This file is part of docx4j.

    docx4j is licensed under the Apache License, Version 2.0 (the "License"); 
    you may not use this file except in compliance with the License. 

    You may obtain a copy of the License at 

        http://www.apache.org/licenses/LICENSE-2.0 

    Unless required by applicable law or agreed to in writing, software 
    distributed under the License is distributed on an "AS IS" BASIS, 
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
    See the License for the specific language governing permissions and 
    limitations under the License.

 */
package org.docx4j.samples;



/**
 * 
 * Running Xalan extension functions on Android is problematic:
 * 
 *   http://stackoverflow.com/questions/10579339/is-it-possible-to-call-a-java-extension-function-from-xalan-on-android
 * 
 * and generating the XSL FO via Xalan + extension functions 
 * is a bit slow,   
 * so this uses TraversalUtils to generate XSL FO output
 * without any need for Xalan or XSLT.
 * 
 */
public class FONonXSLT {
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		String inputfilepath;	
		String outputfilepath;		

		inputfilepath = System.getProperty("user.dir")
//				+ "/hlink.docx";
//		+ "/OpenXML_1ed_Part4.docx";
//		+ "/sample-docs/word/sample-docx.docx";
//		+ "/sample-docs/word/2003/word2003-vml.docx";
//				+ "/table-nested.docx";
//		+ "/sample-docs/word/headers.docx";
		+ "/sample-docs/word/sample-docxv2.docx";		
		
		WordprocessingMLPackage wmlPackage = WordprocessingMLPackage
				.load(new java.io.File(inputfilepath));
		
		FOSettings pdfSettings = new FOSettings();
		pdfSettings.setWmlPackage(wmlPackage);
		
		
		XSLFOExporterNonXSLT withoutXSLT = new XSLFOExporterNonXSLT(wmlPackage, 