Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.docx4j.convert.out.fo;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBElement;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.fop.apps.MimeConstants;
import org.docx4j.Docx4J;
import org.docx4j.TraversalUtil;
import org.docx4j.XmlUtils;
import org.docx4j.convert.out.ConversionFeatures;
import org.docx4j.convert.out.FOSettings;
import org.docx4j.convert.out.common.ConversionSectionWrapper;
import org.docx4j.convert.out.common.ConversionSectionWrappers;
import org.docx4j.convert.out.fo.renderers.FORendererApacheFOP;
import org.docx4j.finders.SectPrFinder;
import org.docx4j.jaxb.Context;
import org.docx4j.model.structure.PageDimensions;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.wml.HpsMeasure;
import org.docx4j.wml.P;
import org.docx4j.wml.PPr;
import org.docx4j.wml.PPrBase;
import org.docx4j.wml.ParaRPr;
import org.docx4j.wml.R;
import org.docx4j.wml.RPr;
import org.docx4j.wml.SectPr;
import org.docx4j.wml.Text;
import org.plutext.jaxb.xslfo.LayoutMasterSet;
import org.plutext.jaxb.xslfo.SimplePageMaster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
/**
* Helper to correctly size header/footer areas in PDF output.
*
* @author jharrop
* @since 3.1.0
*
*/
public class FOPAreaTreeHelper {
protected static Logger log = LoggerFactory.getLogger(FOPAreaTreeHelper.class);
/**
* Since we start with headers/footers which each take up approx half the page,
* there is little room for the body content (which would result in many pages,
* and unnecessary processing).
*
* At the same time, we need enough body content to produce first page, odd page,
* and even page for each section.
*
* So this method replaces the existing body content with content which is sufficient
* for our needs. This method isn't essential, but it should make things faster.
*
* It leaves the headers/footers untouched, since it is those which we're
* most interested in at this point.
*
* @param hfPkg
*/
static void trimContent(WordprocessingMLPackage hfPkg) {
// Find the sectPrs
SectPrFinder sf = new SectPrFinder(hfPkg.getMainDocumentPart());
try {
new TraversalUtil(hfPkg.getMainDocumentPart().getContents(), sf);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
}
List sectPrList = sf.getSectPrList();
// Was there a body level one?
if (hfPkg.getMainDocumentPart().getJaxbElement().getBody().getSectPr()!=null) {
//then delete the first entry (which is where SectPrFinder put it)
sectPrList.remove(0);
}
// Now generate content; let's use
P filler = createFillerP();
List