שמור מסמך

רוב המשימות שאתה צריך לבצע Aspose.Words כרוך בהצלת מסמך. להציל מסמך Aspose.Words מספק Save שיטת Document מעמד. ניתן לשמור את המסמך בכל פורמט הצלה נתמך על ידי Aspose.Words. לרשימה של כל הפורמטים הנתמכות, ראה את SaveFormat אזהרה.

שמור לקובץ

פשוט להשתמש Save שיטה עם שם קובץ Aspose.Words יקבע את תבנית החסכון מסיומת הקובץ שאתה מציין.

הדוגמה הבאה של הקוד מראה כיצד לטעון ולחסוך מסמך לקובץ:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(LoadAndSave.class);
Document doc = new Document(dataDir+ "Test File (doc).doc");
// Save the finished document to disk.
doc.save(dataDir + "Test File (doc)_out.doc", SaveFormat.PNG);

לשמור על זרם

לעבור אובייקט זרימה Save שיטה. יש צורך לציין את תבנית החיסכון במפורש בעת שמירת זרם.

הדוגמה הבאה של הקוד מראה כיצד לטעון ולחסוך מסמך לזרם:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(LoadAndSaveToStream.class);
String inputFile = "Test File (doc).doc";
String outputFile = "output.png";
InputStream in = new FileInputStream(dataDir + inputFile);
OutputStream out = new FileOutputStream(dataDir + outputFile);
Document doc = new Document(in);
// Save the finished document to disk.
doc.save(out, SaveFormat.PNG);

ניתן להוריד את קובץ התבנית של דוגמה זו Aspose.Words GitHub.

לשמור על PCL

Aspose.Words תומך בשמירת מסמך ל- PCL (שפת פיקוד הדפסה). Aspose.Words ניתן לחסוך מסמכים בפורמט PCL 6 (PCL 6 Enhanced או PCL XL). The The The PclSaveOptions ניתן להשתמש בכיתה כדי לציין אפשרויות נוספות בעת שמירת מסמך לתוך פורמט PCL.

הדוגמה הבאה של הקוד מראה כיצד לחסוך מסמך ל- PCL באמצעות אפשרויות הצלה:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ConvertDocumentToPCL.class);
// Load the document from disk.
Document doc = new Document(dataDir + "Document.doc");
PclSaveOptions saveOptions = new PclSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PCL);
saveOptions.setRasterizeTransformedElements(false);
// Export the document as an PCL file.
doc.save(dataDir + "Document.PclConversion_out.pcl", saveOptions);