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


Java Document.save方法代码示例

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


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

示例1: convertPDF

import com.aspose.words.Document; //导入方法依赖的package包/类
@Override
public File convertPDF(File theFile, String md5UploadedFile) throws PDFConverterException {
	try {
		// TEST ONLY!
		// License license = new License();
		// license.setLicense("");
		String outFileName = this.getOutputFileName(md5UploadedFile);
		File pdfOutput = new File(Config.getString("application.staticFiles"), outFileName);
		Document doc = new Document(new FileInputStream(theFile));
		doc.save(pdfOutput.getCanonicalPath());
		return pdfOutput;
	} catch (Exception e) {
		log.error("Fail to create PDF in AsposeWords Converter", e);
		throw new PDFConverterException("Fail to create PDF in AsposeWords Converter", e);
	}
}
 
开发者ID:LeoFCardoso,项目名称:tudoToPDF,代码行数:17,代码来源:AsposeWordsConverter.java

示例2: exportToDoc

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void exportToDoc(File tempDocFile, byte[] bytes)
		throws PortalException, SystemException {
	try {

		InputStream is = new ByteArrayInputStream(bytes);
		LoadOptions loadOptions = new LoadOptions();
		loadOptions.setLoadFormat(LoadFormat.HTML);

		Document doc = new Document(is, loadOptions);

		doc.save(new FileOutputStream(tempDocFile),
				com.aspose.words.SaveFormat.DOC);

	} catch (Exception e) {
		String msg = "Aspose: Unable to export to ms word format.. some error occured: "
				+ e.getMessage();

		s_log.error(msg, e);

		throw new PortalException(
				"Aspose: Unable to export to ms word format.. some error occured",
				e);
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Liferay,代码行数:25,代码来源:AsposExportHelper.java

示例3: exportToPdf

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void exportToPdf(File tempPdfFile, byte[] bytes)
		throws PortalException, SystemException {
	try {

		InputStream is = new ByteArrayInputStream(bytes);
		LoadOptions loadOptions = new LoadOptions();
		loadOptions.setLoadFormat(LoadFormat.HTML);

		Document doc = new Document(is, loadOptions);

		doc.save(new FileOutputStream(tempPdfFile),
				com.aspose.words.SaveFormat.PDF);

	} catch (Exception e) {
		String msg = "Aspose: Unable to export to PDF format.. some error occured: "
				+ e.getMessage();

		s_log.error(msg, e);

		throw new PortalException(
				"Aspose: Unable to export PDF format.. some error occured",
				e);
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Liferay,代码行数:25,代码来源:AsposExportHelper.java

示例4: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithimages/insertimage/data/";

	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);

	builder.insertImage(dataPath + "background.jpg");
	builder.insertImage(dataPath + "background.jpg",
	        RelativeHorizontalPosition.MARGIN,
	        100,
	        RelativeVerticalPosition.MARGIN,
	        200,
	        200,
	        100,
	        WrapType.SQUARE);
	
	doc.save(dataPath + "Aspose_InsertImage_Out.docx");
	
       System.out.println("Process Completed Successfully");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Words_for_Apache_POI,代码行数:22,代码来源:AsposeInsertImage.java

示例5: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/joiningtables/data/";
	
	// Load the document.
	Document doc = new Document(dataPath + "tableDoc.doc");

	// Get the first and second table in the document.
	// The rows from the second table will be appended to the end of the first table.
	Table firstTable = (Table)doc.getChild(NodeType.TABLE, 0, true);
	Table secondTable = (Table)doc.getChild(NodeType.TABLE, 1, true);

	// Append all rows from the current table to the next.
	// Due to the design of tables even tables with different cell count and widths can be joined into one table.
	while (secondTable.hasChildNodes())
	    firstTable.getRows().add(secondTable.getFirstRow());

	// Remove the empty table container.
	secondTable.remove();

	doc.save(dataPath + "AsposeJoinTables.doc");
	
	System.out.println("Done.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Words_for_Apache_POI,代码行数:25,代码来源:AsposeJoiningTables.java

示例6: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdocuments/createnewdocument/data/";
	
	Document doc = new Document();
	// DocumentBuilder provides members to easily add content to a document.
	
	DocumentBuilder builder = new DocumentBuilder(doc);
	// Write a new paragraph in the document with some text as "Sample Content..."
	
	builder.setBold(true);
	
	builder.writeln("Aspose Sample Content for Word file.");
	
	// Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
	// Aspose.Words supports saving any document in many more formats.
	doc.save(dataPath + "Aspose_NewDoc_Out.docx",SaveFormat.DOCX);
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Words_for_Apache_POI,代码行数:19,代码来源:AsposeNewDocument.java

示例7: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithdocument/insertpicture/data/";
	
	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);

	builder.insertImage(dataPath + "background.jpg");
	builder.insertImage(dataPath + "background.jpg",
	        RelativeHorizontalPosition.MARGIN,
	        100,
	        RelativeVerticalPosition.MARGIN,
	        200,
	        200,
	        100,
	        WrapType.SQUARE);
	
	doc.save(dataPath + "AsposeImageInDoc.docx");
	
	System.out.println("Done.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:22,代码来源:AsposeInsertImage.java

示例8: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
  {
String dataPath = "src/asposefeatures/workingwithtext/insertcomments/data/";
	
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("Some text is added.");
	
Comment comment = new Comment(doc, "Aspose", "As", new Date());
builder.getCurrentParagraph().appendChild(comment);
comment.getParagraphs().add(new Paragraph(doc));
comment.getFirstParagraph().getRuns().add(new Run(doc, "Comment text."));
	
doc.save(dataPath + "AsposeComments.docx");
	
System.out.println("Done.");
  }
 
开发者ID:asposemarketplace,项目名称:Aspose_Words_for_Apache_POI,代码行数:18,代码来源:AsposeInsertComments.java

示例9: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdocuments/workingwithcomments/data/";
	
	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);
	builder.write("Some text is added.");

	Comment comment = new Comment(doc, "Aspose", "As", new Date());
	builder.getCurrentParagraph().appendChild(comment);
	comment.getParagraphs().add(new Paragraph(doc));
	comment.getFirstParagraph().getRuns().add(new Run(doc, "Comment text."));

	doc.save(dataPath + "Aspose_Comments.docx");
	System.out.println("Done.");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:17,代码来源:AsposeComments.java

示例10: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/asposefeatures/workingwithtables/autofitsettingstotable/data/";

	// Open the document
	Document doc = new Document(dataPath + "tableDoc.doc");
	
	Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
	// Autofit the first table to the page width.
	table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);

	Table table2 = (Table)doc.getChild(NodeType.TABLE, 1, true);
	// Auto fit the table to the cell contents
	table2.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);

	// Save the document to disk.
	doc.save(dataPath + "AsposeAutoFitTable_Out.doc");
	
	System.out.println("Process Completed Successfully");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:21,代码来源:AsposeTableAutoFitSettings.java

示例11: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
   {
String dataPath = "src/asposefeatures/workingwithtext/removecomments/data/";

Document doc = new Document(dataPath + "AsposeComments.docx");

// Collect all comments in the document
NodeCollection comments = doc.getChildNodes(NodeType.COMMENT, true);
// Look through all comments and remove those written by the authorName author.
for (int i = comments.getCount() - 1; i >= 0; i--)
{
    Comment comment = (Comment) comments.get(i);
    if (comment.getAuthor().equalsIgnoreCase("Aspose"))
	System.out.println("Aspose comment removed");
	comment.remove();
}

doc.save(dataPath + "AsposeCommentsRemoved.docx");
System.out.println("Done...");
   }
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:21,代码来源:AsposeRemoveComments.java

示例12: doInBackground

import com.aspose.words.Document; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(String... params)
{
	try
	{
		Document doc = new Document(inputPath);				
		doc.save(outputPath, outputFormat);
		
		return true;
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Android,代码行数:17,代码来源:AsposeConverterActivity.java

示例13: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);
	
	// We call this method to start building the table.
	builder.startTable();
	builder.insertCell();
	builder.write("Row 1, Cell 1 Content.");
	
	// Build the second cell
	builder.insertCell();
	builder.write("Row 1, Cell 2 Content.");
	// Call the following method to end the row and start a new row.
	builder.endRow();
	
	// Build the first cell of the second row.
	builder.insertCell();
	builder.write("Row 2, Cell 1 Content");
	
	// Build the second cell.
	builder.insertCell();
	builder.write("Row 2, Cell 2 Content.");
	builder.endRow();
	
	// Signal that we have finished building the table.
	builder.endTable();
	
	// Save the document to disk.
	doc.save("data/Aspose_CreateTable.doc");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:32,代码来源:AsposeCreateTable.java

示例14: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
       // Load the document from disk.
       Document doc = new Document("data/document.doc");
       
       doc.save("data/html/Aspose_DocToHTML.html",SaveFormat.HTML); //Save the document in HTML format.
       doc.save("data/Aspose_DocToPDF.pdf",SaveFormat.PDF); //Save the document in PDF format.
       doc.save("data/Aspose_DocToTxt.txt",SaveFormat.TEXT); //Save the document in TXT format.
       doc.save("data/Aspose_DocToJPG.jpg",SaveFormat.JPEG); //Save the document in JPEG format.
       
       System.out.println("Aspose - Doc file converted in specified formats");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:13,代码来源:AsposeConvertToFormats.java

示例15: main

import com.aspose.words.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithheaderfooter/addfooter/data/";
	
	Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    Section currentSection = builder.getCurrentSection();
    PageSetup pageSetup = currentSection.getPageSetup();

    // Specify if we want headers/footers of the first page to be different from other pages.
    // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
    // different headers/footers for odd and even pages.
    pageSetup.setDifferentFirstPageHeaderFooter(true);

    // --- Create header for the first page. ---
    pageSetup.setHeaderDistance(20);
    builder.moveToHeaderFooter(HeaderFooterType.FOOTER_FIRST);
    builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

    // Set font properties for header text.
    builder.getFont().setName("Arial");
    builder.getFont().setBold(true);
    builder.getFont().setSize(14);
    
    // Specify header title for the first page.
    builder.write("(C) 2001 Aspose Pty Ltd. All rights reserved.");

    // Save the resulting document.
    doc.save(dataPath + "AsposeFooter.doc");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Java_for_Docx4j,代码行数:32,代码来源:AsposeFooters.java


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