SaveFile
bool SaveFile(nType: int, sPath: String^, sParams: String^)
Description
Saves the file after all the changes are made. The type of the file which will be saved needs to be set.
Parameters
- nType
int
The type of the file to be saved set as a hexadecimal integer for the .Net code. For the
.docbuilder
script file the following values are possible:docx
,odt
,rtf
,txt
,pptx
,xlsx
,ods
,csv
,pdf
(see OFFICESTUDIO_FILE_XXX values).- sPath
String^
The path to the file to be saved together with its name and extension.
- sParams
String^
The parameters needed for the correct file saving (most commonly, the encoding is used for the
txt
andcsv
file types or the delimiter for thecsv
files, for other file types this is just an empty string). The parameters are added in the form of XML tags, wherem_nCsvTxtEncoding
is used for the text encoding andm_nCsvDelimiter
is used for thecsv
delimiter. You can find all the supported values for the encoding in this file. The supported values for thecsv
delimiters include:0
- no delimiter;1
- tab;2
- semicolon;3
- colon;4
- comma;5
- space.
When saving into an image file (
png
orjpg
) for creating thumbnails, the additional parameters are used. See below to find them out.
Example
.Net
string workDirectory = "C:/Program Files/ONLYOFFICE/DocumentBuilder";
string resultPath = "result.docx";
var doctype = (int)OfficeFileTypes.Document.DOCX;
CDocBuilder.Initialize(workDirectory);
CDocBuilder oBuilder = new CDocBuilder();
oBuilder.SaveFile(doctype, resultPath);
CDocBuilder.Destroy();
.docbuilder
builder.SaveFile("docx", "result.docx")
Saving into images
ONLYOFFICE Document Builder allows to save your document files into image files creating thumbnails of the first page or of all the pages in the document. This is done using the parameters of the SaveFile()
method. The parameters are added in the form of XML tags, where the following tags can be used:
m_oThumbnail
- the core tag showing that the inner nodes will be used to create a thumbnail out of the document file;format
- the image file format used to create a thumbnail (can be of the following values:3
- for a JPG file,4
- for a PNG file);aspect
- the image aspect when creating a thumbnail from the document file (can be of the following values:1
- will keep the original aspect,0
- will stretch the image to fit the width and the height set below);first
- whether only the first page or all the pages should be converted into a thumbnail (can be of the following values:true
- only the first page will be converted,false
- all the document pages will be used to create thumbnails, in this case the file will be saved as an archive of images, one for each page);width
- the image width in pixels;height
- the image height in pixels.
Example
.Net
oBuilder.SaveFile(OFFICESTUDIO_FILE_IMAGE, L"thumbnail.png", "<m_oThumbnail><format>4</format><aspect>1</aspect><first>false</first><width>1000</width><height>1000</height></m_oThumbnail>");
.docbuilder
builder.SaveFile("image", "./thumbnail.png", "<m_oThumbnail><format>4</format><aspect>1</aspect><first>false</first><width>1000</width><height>1000</height></m_oThumbnail>")