本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
示例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.");
}
示例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);
}
示例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.");
}
示例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.");
}
示例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.");
}
示例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");
}
示例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...");
}
示例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;
}
}
示例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");
}
示例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");
}
示例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");
}