当前位置: 首页>>代码示例>>Java>>正文


Java Docx4JException.printStackTrace方法代码示例

本文整理汇总了Java中org.docx4j.openpackaging.exceptions.Docx4JException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java Docx4JException.printStackTrace方法的具体用法?Java Docx4JException.printStackTrace怎么用?Java Docx4JException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.docx4j.openpackaging.exceptions.Docx4JException的用法示例。


在下文中一共展示了Docx4JException.printStackTrace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveDocx

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
/**
 * Saves the docx file and print xml files
 * 
 * @param wordMLPackage
 *            : object model of the file
 * @param path
 *            : path for saving the file
 * @param printXML
 *            : print xml files if true
 * @return true if successed
 */
private boolean saveDocx(org.docx4j.openpackaging.packages.WordprocessingMLPackage wordMLPackage, String path,
		boolean printXML) {
	if (wordMLPackage == null)
		return false;
	try {
		if (printXML == true)
			System.out.println(
					XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getContents(), true, true));
		wordMLPackage.save(new java.io.File(path));
		return true;
	} catch (Docx4JException e) {
		System.out.println("Error in saving docx file.");
		e.printStackTrace();
	}
	return false;
}
 
开发者ID:mjza,项目名称:MSThesis_Fidus_Docx_Converter,代码行数:28,代码来源:FidusToDocx.java

示例2: setBibliographyResources

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
/**
 * Converts recources inside of the docx to enteries in fidus
 * 
 * @param wordMLPackage
 */
private void setBibliographyResources(WordprocessingMLPackage wordMLPackage) {
	HashMap<String, org.docx4j.openpackaging.parts.CustomXmlPart> mp = wordMLPackage.getCustomXmlDataStorageParts();
	Iterator<Map.Entry<String, org.docx4j.openpackaging.parts.CustomXmlPart>> it = mp.entrySet().iterator();
	while (it.hasNext()) {
		Map.Entry<String, org.docx4j.openpackaging.parts.CustomXmlPart> pair = (Map.Entry<String, org.docx4j.openpackaging.parts.CustomXmlPart>) it
				.next();
		if (pair.getValue() instanceof org.docx4j.openpackaging.parts.WordprocessingML.BibliographyPart) {
			org.docx4j.openpackaging.parts.WordprocessingML.BibliographyPart bibliographyPart = (org.docx4j.openpackaging.parts.WordprocessingML.BibliographyPart) pair
					.getValue();
			try {
				JAXBElement<org.docx4j.bibliography.CTSources> bibliography = bibliographyPart.getContents();
				this.bibliographyResources = bibliography.getValue().getSource();
			} catch (Docx4JException e) {
				System.err.println("\nProblem in reading bibliography part.");
				e.printStackTrace();
			}
			break;
		}
	}

}
 
开发者ID:mjza,项目名称:MSThesis_Fidus_Docx_Converter,代码行数:27,代码来源:DocxToFidus.java

示例3: setPageMargins

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
private void setPageMargins() {		
	try {
		Body body = wordMLPackage.getMainDocumentPart().getContents().getBody();
		Padding padding = bean.getReportLayout().getPagePadding();
		PageDimensions page = new PageDimensions();
		PgMar pgMar = page.getPgMar();      			
		pgMar.setBottom(BigInteger.valueOf(pixelsToDxa(padding.getBottom())));
		pgMar.setTop(BigInteger.valueOf(pixelsToDxa(padding.getTop())));
		pgMar.setLeft(BigInteger.valueOf(pixelsToDxa(padding.getLeft())));
		pgMar.setRight(BigInteger.valueOf(pixelsToDxa(padding.getRight())));			
		SectPr sectPr = factory.createSectPr();   
		body.setSectPr(sectPr);                           
		sectPr.setPgMar(pgMar);  
	} catch (Docx4JException e) {			
		e.printStackTrace();
	}		
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:18,代码来源:DocxExporter.java

示例4: DocxExtractor

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
/**
 * Class constructor.
 */
public DocxExtractor(File inputFile) {
    try {
        this.loadDocument(inputFile);
    } catch (Docx4JException e) {
        e.printStackTrace();
    }
}
 
开发者ID:tokgozmusa,项目名称:docx4j-word-data-extractor,代码行数:11,代码来源:DocxExtractor.java

示例5: finishExport

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
@Override
protected void finishExport() {
	if (table != null) {			
		table.getContent().add(tableRow);
	}	
	
	if (!bean.isSubreport()) {
		
		if (table != null) {			
			wordMLPackage.getMainDocumentPart().addObject(table);
		} else {
			wordMLPackage.getMainDocumentPart().addParagraphOfText("");
		}
		
		table = null;		
		
		try {
			addPageHeaderFooter();				
			//addBackgroundImage();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		
		try {
			wordMLPackage.save(getOut());
		} catch (Docx4JException e) {			
			e.printStackTrace();
		}
	}
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:31,代码来源:DocxExporter.java

示例6: addMetadata

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
private void addMetadata() {				
	try {
		DocPropsCorePart docPropsCorePart = wordMLPackage.getDocPropsCorePart();
		CoreProperties coreProps = (CoreProperties) docPropsCorePart.getContents();
		
		org.docx4j.docProps.core.ObjectFactory CorePropsfactory = new org.docx4j.docProps.core.ObjectFactory();
		org.docx4j.docProps.core.dc.elements.ObjectFactory dcElfactory = new org.docx4j.docProps.core.dc.elements.ObjectFactory();
		
		SimpleLiteral desc = dcElfactory.createSimpleLiteral();
		desc.getContent().add("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
		coreProps.setDescription(dcElfactory.createDescription(desc));
		
		SimpleLiteral title = dcElfactory.createSimpleLiteral();
		title.getContent().add(getDocumentTitle());
		coreProps.setTitle(dcElfactory.createTitle(title));
		
		SimpleLiteral author = dcElfactory.createSimpleLiteral();
		author.getContent().add(ReleaseInfoAdapter.getCompany());
		coreProps.setCreator(author);
		
		SimpleLiteral subject = dcElfactory.createSimpleLiteral();
		subject.getContent().add("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
		coreProps.setSubject(subject);
				
		coreProps.setKeywords(ReleaseInfoAdapter.getHome());
	} catch (Docx4JException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:32,代码来源:DocxExporter.java

示例7: addCellStyle

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
private void addCellStyle(Tc tableCell, BandElement be, String content, P paragraph, Map<String, Object> style) {
	if (style != null) {
		
		// inner html text
		if (content.startsWith("<html>")) {
			try {					
				wordMLPackage.getMainDocumentPart().addAltChunk(AltChunkType.Html, content.getBytes(), tableCell);					
				tableCell.getContent().add(paragraph);					
			} catch (Docx4JException e) {					
				e.printStackTrace();
			}
			return;
		}
					
		Text text = factory.createText();
		text.setValue(content);

		R run = factory.createR();
		run.getContent().add(text);

		paragraph.getContent().add(run);
		
		setHorizontalAlignment(paragraph, style);	
				
		RPr runProperties = factory.createRPr();
		
		setFont(tableCell, style, runProperties);									
		setCellMargins(tableCell,style);			
		setBackground(tableCell, style);			
		setVerticalAlignment(tableCell, style);					
		setCellBorders(tableCell, style);
		if (be != null) {
			setTextDirection(tableCell, be.getTextRotation());
		}

		run.setRPr(runProperties);

		tableCell.getContent().add(paragraph);
	}
}
 
开发者ID:nextreports,项目名称:nextreports-engine,代码行数:41,代码来源:DocxExporter.java

示例8: addFootnoteParagraph

import org.docx4j.openpackaging.exceptions.Docx4JException; //导入方法依赖的package包/类
/**
 * Creates a paragraph that contains a footnote element
 * 
 * @return : the created paragraph
 */
private org.docx4j.wml.P addFootnoteParagraph() {
	org.docx4j.wml.CTFtnEdn ftnedn = this.wmlObjectFactory.createCTFtnEdn();
	try {
		org.docx4j.wml.CTFootnotes footnotes = this.fnp.getContents();
		footnotes.getFootnote().add(ftnedn);
	} catch (Docx4JException e) {
		System.err.println("\nome Error happen in the time of a footnote creation.");
		e.printStackTrace();
		return null;
	}
	ftnedn.setId(BigInteger.valueOf(++this.footnoteCounter));
	// Create object for p
	org.docx4j.wml.P p = this.wmlObjectFactory.createP();
	ftnedn.getContent().add(p);

	// Create object for pPr
	org.docx4j.wml.PPr ppr = this.wmlObjectFactory.createPPr();
	p.setPPr(ppr);
	// Create object for pStyle
	org.docx4j.wml.PPrBase.PStyle pprbasepstyle = this.wmlObjectFactory.createPPrBasePStyle();
	ppr.setPStyle(pprbasepstyle);
	pprbasepstyle.setVal("FootnoteText");
	// Create object for r
	org.docx4j.wml.R r = this.wmlObjectFactory.createR();
	p.getContent().add(r);
	// Create object for rPr
	org.docx4j.wml.RPr rpr = this.wmlObjectFactory.createRPr();
	r.setRPr(rpr);
	// Create object for rStyle
	org.docx4j.wml.RStyle rstyle = this.wmlObjectFactory.createRStyle();
	rpr.setRStyle(rstyle);
	rstyle.setVal("FootnoteReference");
	// Create object for footnoteRef (wrapped in JAXBElement)
	org.docx4j.wml.R.FootnoteRef rfootnoteref = this.wmlObjectFactory.createRFootnoteRef();
	JAXBElement<org.docx4j.wml.R.FootnoteRef> rfootnoterefWrapped = this.wmlObjectFactory
			.createRFootnoteRef(rfootnoteref);
	r.getContent().add(rfootnoterefWrapped);
	// Create object for r
	org.docx4j.wml.R r2 = this.wmlObjectFactory.createR();
	p.getContent().add(r2);
	// Create object for t (wrapped in JAXBElement)
	org.docx4j.wml.Text text = this.wmlObjectFactory.createText();
	JAXBElement<org.docx4j.wml.Text> textWrapped = this.wmlObjectFactory.createRT(text);
	r2.getContent().add(textWrapped);
	text.setValue(" ");
	text.setSpace("preserve");
	return p;
}
 
开发者ID:mjza,项目名称:MSThesis_Fidus_Docx_Converter,代码行数:54,代码来源:FidusToDocx.java


注:本文中的org.docx4j.openpackaging.exceptions.Docx4JException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。