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


Java OpcPackage类代码示例

本文整理汇总了Java中org.docx4j.openpackaging.packages.OpcPackage的典型用法代码示例。如果您正苦于以下问题:Java OpcPackage类的具体用法?Java OpcPackage怎么用?Java OpcPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createStyleElement

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
@Override
	public Element createStyleElement(OpcPackage opcPackage, Document document,
			String styleDefinition) {

		
		if ((styleDefinition != null) && (styleDefinition.length() > 0)) {
    		session.setAttribute("css", styleDefinition);
//    		System.out.println(styleDefinition);
    		
    		//<link rel="stylesheet" type="text/css" href="/docx4j-web-editor-1.0.0-SNAPSHOT/services/css/docx.css" />
    		
    		
//			Element ret = document.createElement("link");
//			ret.setAttribute("rel", "stylesheet");
//			ret.setAttribute("type", "text/css");
//			ret.setAttribute("href", Editor.getContextPath() + "/services/css/docx.css");
//    		return ret;
    		
		} else {
    		System.out.println("styleDefinition was null or empty!");			
		}
		return null;
	}
 
开发者ID:plutext,项目名称:docx-html-editor,代码行数:24,代码来源:SessionStyleHandler.java

示例2: main

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) throws Exception {

	String inputfilepath  = "data/xlsx4j/pivot.xlsm";
	
	boolean save = true;
	String outputfilepath = "data/xlsx4j/pivot-rtt-xlsx4j.xlsm";
			
	// Open a document from the file system
	// 1. Load the Package
	OpcPackage pkg = OpcPackage.load(new java.io.File(inputfilepath));
	
	// Save it
	
	if (save) {		
		SaveToZipFile saver = new SaveToZipFile(pkg);
		saver.save(outputfilepath);
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:22,代码来源:OpenSaveSpreadSheetXlsx4j.java

示例3: main

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
public static void main(String[] args) throws Exception 
{
	String dataPath = "src/featurescomparison/workingwithslides/removeslide/data/";
	
	String inputfilepath = dataPath + "presentation.pptx";
	
	PresentationMLPackage presentationMLPackage = 
		(PresentationMLPackage)OpcPackage.load(new java.io.File(inputfilepath));
	
	MainPresentationPart mpp = presentationMLPackage.getMainPresentationPart();
	
	//mpp.removeSlide(10);
	Relationship rel = mpp.getRelationshipsPart().getRelationshipByID("rId2");
	mpp.removeSlide(rel);
	
	System.out.println("\n\n saving .. \n\n");
	String outputfilepath = dataPath + "RemovedSlide-Pptx4j.pptx";
	presentationMLPackage.save(new java.io.File(outputfilepath));

	System.out.println("\n\n done .. \n\n");		
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:22,代码来源:Pptx4jRemoveSlide.java

示例4: upload

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
/**
 * Upload a wordMLPackage (or presentationML or spreadsheetML pkg) to Google
 * Drive as a docx
 * 
 * @param service
 * @param wordMLPackage
 * @param title
 * @param description
 * @param shareReadableWithEveryone
 * @throws IOException
 * @throws Docx4JException
 */
public static void upload(Drive service, OpcPackage wordMLPackage,
		String title, String description, boolean shareReadableWithEveryone)
		throws IOException, Docx4JException {

	// Insert a file
	File body = new File();
	body.setTitle(title);
	body.setDescription(description);
	body.setMimeType(DOCX_MIME);

	ByteArrayContent mediaContent = new ByteArrayContent(DOCX_MIME,
			getDocxAsByteArray(wordMLPackage));

	File file = service.files().insert(body, mediaContent).execute();

	System.out.println("File ID: " + file.getId());

	// https://developers.google.com/drive/v2/reference/permissions/insert
	if (shareReadableWithEveryone) {
		insertPermission(service, file.getId(), null, "anyone", "reader");
		System.out.println(".. shared");
	}

}
 
开发者ID:plutext,项目名称:docx4j-cloud-GoogleDrive,代码行数:37,代码来源:Docx4jUploadToGoogleDrive.java

示例5: createScriptElement

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
@Override
public Element createScriptElement(OpcPackage opcPackage, Document document, String scriptDefinition) {
	Element ret = null;
	if ((scriptDefinition != null) && (scriptDefinition.length() > 0)) {
		ret = document.createElement("script");
		ret.setAttribute("type", "text/javascript");
		ret.appendChild(document.createComment(scriptDefinition));
	}
	return ret;
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:11,代码来源:OutputConversionHTMLScriptElementHandler.java

示例6: loadWordprocessingMLPackageWithPwd

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
/**
 * @Description:加载带密码WordprocessingMLPackage
 */
public WordprocessingMLPackage loadWordprocessingMLPackageWithPwd(
        String filePath, String password) throws Exception {
    OpcPackage opcPackage = WordprocessingMLPackage.load(new java.io.File(
            filePath), password);
    WordprocessingMLPackage wordMLPackage = (WordprocessingMLPackage) opcPackage;
    return wordMLPackage;
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:11,代码来源:Docx4j_工具类_S3_Test.java

示例7: main

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithpresentations/openexisting/data/";
	
	String inputfilepath = dataPath + "presentation.pptx";
	
	PresentationMLPackage presentationMLPackage = 
		(PresentationMLPackage)OpcPackage.load(new java.io.File(inputfilepath));
			
	System.out.println("\n\n saving .. \n\n");
	presentationMLPackage.save(new java.io.File(dataPath + "Pptx4j-Duplicate.pptx"));

	System.out.println("\n\n done .. \n\n");	
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:15,代码来源:Pptx4jOpenExistingPresentations.java

示例8: getDocxAsByteArray

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
public static byte[] getDocxAsByteArray(OpcPackage opcPackage)
		throws Docx4JException {

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	Save saver = new Save(opcPackage);
	saver.save(baos);

	return baos.toByteArray();
}
 
开发者ID:plutext,项目名称:docx4j-cloud-GoogleDrive,代码行数:10,代码来源:GoogleDriveConvertFromDocxTo.java

示例9: handleHyperlink

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
@Override
public void handleHyperlink(Model hyperlinkModel, OpcPackage opcPackage, Part currentPart) throws Docx4JException {
	//do nothing
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:5,代码来源:OutputConversionHyperlinkHandler.java

示例10: createFoAttributes

import org.docx4j.openpackaging.packages.OpcPackage; //导入依赖的package包/类
private static void createFoAttributes(OpcPackage opcPackage, PPr pPr, Element foBlockElement, boolean inList, boolean ignoreBorders){
		
    	List<Property> properties = PropertyFactory.createProperties(opcPackage, pPr);
    	
    	for( Property p :  properties ) {
			if (p!=null) {
				
				if (ignoreBorders &&
						((p instanceof PBorderTop)
								|| (p instanceof PBorderBottom))) {
					continue;
				}
								
				if (inList && !(p instanceof Indent) ) { 
					// Don't set start-indent in 
					// fo:list-item-body/fo:block.
					// This has to be handled above using something like 
					//  <fo:list-block provisional-distance-between-starts="0.5in" start-indent="2in">
					p.setXslFO(foBlockElement);
				} else if (!inList) {
					p.setXslFO(foBlockElement);
				}
			}
    	}
    	
    	if (pPr==null) return;
		
    	// Special case, since bidi is translated to align right
    	// Handle interaction between w:pPr/w:bidi and w:pPr/w:jc/@w:val='right'
    	if (pPr.getBidi()!=null && pPr.getBidi().isVal()) {
    		
    		if (pPr.getJc()!=null) {
    			if (pPr.getJc().getVal().equals(JcEnumeration.RIGHT)) {
    				// set it to left!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "left");
    			} else if (pPr.getJc().getVal().equals(JcEnumeration.LEFT)) {
    				// set it to right!
    				foBlockElement.setAttribute(Justification.FO_NAME,  "right");
    			}
    		}
    	}
    	
    	// Table of contents dot leader needs text-align-last="justify"
    	// Are we in a TOC?
    	if (pPr.getTabs()!=null
    			
    			// PStyle is not included in our effective pPr!
//    			&& pPr.getPStyle()!=null 
//    			&& pPr.getPStyle().getVal()!=null
//    			&& pPr.getPStyle().getVal().startsWith("TOC")  
    			) {
    		
    		CTTabStop tabStop = pPr.getTabs().getTab().get(0);
    		if (tabStop!=null
    				//&& tabStop.getLeader().equals(STTabTlc.DOT)
    				&& tabStop.getVal().equals(STTabJc.RIGHT) ) {
    			
    			foBlockElement.setAttribute("text-align-last",  "justify");
    		}
    	}
    	
	}
 
开发者ID:plutext,项目名称:docx4j-export-FO,代码行数:63,代码来源:XsltFOFunctions.java


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