Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Most of the tasks you need to perform with Aspose.Words involve saving a document. To save a document Aspose.Words provides the save method of the Document class. There are overloads that allow saving a document to a file or stream. The document can be saved in any save format supported by Aspose.Words. For the list of all supported save formats, see the SaveFormat enumeration.
Simply use the save method with a file name. Aspose.Words will determine the save format from the file extension that you specify.
The following code example shows how to load and save a document to a file:
Pass a stream object to the save method. It’s necessary to specify the save format explicitly when saving to a stream.
The following code example shows how to load and save a document to a stream:
You can download the template file of this example from Aspose.Words GitHub.
Aspose.Words supports saving a document into PCL (Printer Command Language). Aspose.Words can save documents into PCL 6 (PCL 6 Enhanced or PCL XL) format. The PclSaveOptions class can be used to specify additional options when saving a document into the PCL format.
The following code example shows how to save a document to PCL using save options:
Q: How does Aspose.Words decide which format to use when I call document.save("output.docx")?
A: When saving to a file, Aspose.Words infers the format from the file extension. The extension “.docx” maps to SaveFormat.DOCX, “.pdf” to SaveFormat.PDF, and so on.
Q: Do I need to specify a SaveFormat when saving a document to a stream?
A: Yes. When the destination is a stream, the format cannot be inferred, so you must pass the desired SaveFormat (e.g., SaveFormat.PDF) as the second argument to save.
Q: Can I save a document directly to a memory stream for further processing?
A: Absolutely. Create a MemoryStream (or io.BytesIO in Python), call document.save(stream, SaveFormat.PDF), and then use the stream’s contents as needed, such as sending it over a network or attaching it to an email.
Q: What options are available when saving a document to PCL?
A: Use the PclSaveOptions class to control PCL‑specific settings, such as rasterizing transformed elements, setting the resolution, or specifying whether to embed fonts. Pass an instance of this class to document.save(stream, pcl_save_options).
Q: Is it possible to change the font size of the entire document while saving?
A: Font size changes must be applied to the document’s content before calling save. You can iterate through all Run nodes, modify their Font.Size property, and then save the document in the desired format.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.