Class SaveOptions
Namespace: Aspose.Note.Saving
Assembly: Aspose.Note.dll (25.6.0)
An abstract base class which represents document saving options for a particular format.
public abstract class SaveOptions
{
private readonly bool _isEmbedded;
private readonly string _fileName;
private readonly SaveFormat _format;
private readonly Aspose.Words.SaveFormat _saveFormat;
private readonly Encoding _encoding;
private readonly bool _keepIrrelevantSectionProperties;
private readonly bool _keepFontTags;
private readonly bool _keepTextWithNoFont;
private readonly bool _keepWhiteSpaceOnlyNodes;
private readonly bool _addBookmarkStartsToAnchorNodes;
private readonly bool _useCompatibilityBreakingApiChanges;
private readonly int _pageHeight;
private readonly int _pageWidth;
private readonly double _leftMargin;
private readonly double _rightMargin;
private readonly double _topMargin;
private readonly double _bottomMargin;
private readonly bool _headerFooter;
private readonly HeaderFooterOptions _headersAndFooters;
private readonly bool _useFlatOpcXmlData;
private readonly float _zoom;
private readonly bool _optimizeForBrowser;
private readonly bool _runAsposeLinkAnnotations;
private readonly bool _useSharedTables;
private readonly bool _keepTableRowsTogether;
private readonly bool _keepColumnsTogether;
private readonly bool _addMissingBookmarkStarts;
private readonly bool _removeEmptyParagraphs;
private readonly bool _runFormatText;
private readonly bool _runDiagnosticChecking;
private readonly bool _useFixedFontSizeInPoint;
private readonly bool _keepTextInFootnotesTogether;
private readonly bool _useOpcXmlData;
private readonly string _outputFilePath;
public SaveOptions(bool isEmbedded, SaveFormat format)
{
_isEmbedded = isEmbedded;
_format = format;
}
public void SetFileName(string fileName)
{
_fileName = fileName;
}
public void SetSaveFormat(Aspose.Words.SaveFormat saveFormat)
{
_saveFormat = saveFormat;
}
public void SetEncoding(Encoding encoding)
{
_encoding = encoding;
}
public void SetKeepIrrelevantSectionProperties(bool keepIrrelevantSectionProperties)
{
_keepIrrelevantSectionProperties = keepIrrelevantSectionProperties;
}
public void SetKeepFontTags(bool keepFontTags)
{
_keepFontTags = keepFontTags;
}
public void SetKeepTextWithNoFont(bool keepTextWithNoFont)
{
_keepTextWithNoFont = keepTextWithNoFont;
}
public void SetKeepWhiteSpaceOnlyNodes(bool keepWhiteSpaceOnlyNodes)
{
_keepWhiteSpaceOnlyNodes = keepWhiteSpaceOnlyNodes;
}
public void SetAddBookmarkStartsToAnchorNodes(bool addBookmarkStartsToAnchorNodes)
{
_addBookmarkStartsToAnchorNodes = addBookmarkStartsToAnchorNodes;
}
public void SetUseCompatibilityBreakingApiChanges(bool useCompatibilityBreakingApiChanges)
{
_useCompatibilityBreakingApiChanges = useCompatibilityBreakingApiChanges;
}
public void SetPageHeight(int pageHeight)
{
_pageHeight = pageHeight;
}
public void SetPageWidth(int pageWidth)
{
_pageWidth = pageWidth;
}
public void SetLeftMargin(double leftMargin)
{
_leftMargin = leftMargin;
}
public void SetRightMargin(double rightMargin)
{
_rightMargin = rightMargin;
}
public void SetTopMargin(double topMargin)
{
_topMargin = topMargin;
}
public void SetBottomMargin(double bottomMargin)
{
_bottomMargin = bottomMargin;
}
public void SetHeaderFooter(bool headerFooter)
{
_headerFooter = headerFooter;
}
public void SetHeadersAndFooters(HeaderFooterOptions headersAndFooters)
{
_headersAndFooters = headersAndFooters;
}
public void SetUseFlatOpcXmlData(bool useFlatOpcXmlData)
{
_useFlatOpcXmlData = useFlatOpcXmlData;
}
public void SetZoom(float zoom)
{
_zoom = zoom;
}
public void SetOptimizeForBrowser(bool optimizeForBrowser)
{
_optimizeForBrowser = optimizeForBrowser;
}
public void SetRunAsposeLinkAnnotations(bool runAsposeLinkAnnotations)
{
_runAsposeLinkAnnotations = runAsposeLinkAnnotations;
}
public void SetUseSharedTables(bool useSharedTables)
{
_useSharedTables = useSharedTables;
}
public void SetKeepTableRowsTogether(bool keepTableRowsTogether)
{
_keepTableRowsTogether = keepTableRowsTogether;
}
public void SetKeepColumnsTogether(bool keepColumnsTogether)
{
_keepColumnsTogether = keepColumnsTogether;
}
public void SetAddMissingBookmarkStarts(bool addMissingBookmarkStarts)
{
_addMissingBookmarkStarts = addMissingBookmarkStarts;
}
public void SetRemoveEmptyParagraphs(bool removeEmptyParagraphs)
{
_removeEmptyParagraphs = removeEmptyParagraphs;
}
public void SetRunFormatText(bool runFormatText)
{
_runFormatText = runFormatText;
}
public void SetRunDiagnosticChecking(bool runDiagnosticChecking)
{
_runDiagnosticChecking = runDiagnosticChecking;
}
public void SetUseFixedFontSizeInPoint(bool useFixedFontSizeInPoint)
{
_useFixedFontSizeInPoint = useFixedFontSizeInPoint;
}
public void SetKeepTextInFootnotesTogether(bool keepTextInFootnotesTogether)
{
_keepTextInFootnotesTogether = keepTextInFootnotesTogether;
}
public void SetUseOpcXmlData(bool useOpcXmlData)
{
_useOpcXmlData = useOpcXmlData;
}
public void SetOutputFilePath(string outputFilePath)
{
_outputFilePath = outputFilePath;
}
}
Inheritance
Derived
HtmlSaveOptions , ImageSaveOptions , OneSaveOptions , PdfSaveOptions
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
SaveOptions(SaveFormat)
Initializes a new instance of the Aspose.Note.Saving.SaveOptions class.
protected void SaveOptions(Aspose.Words.SaveFormat saveFormat)
{
_saveFormat = saveFormat;
_isHtml = (saveFormat == Aspose.Words.SaveFormat.Html);
_isFixedLayout = (saveFormat == Aspose.Words.SaveFormat.Pdf || saveFormat == Aspose.Words.SaveFormat.FlatOpcXml);
}
Parameters
saveFormat
SaveFormat
The save Format.
Properties
FontsSubsystem
Gets or sets font’s settings to be used while saving
public FontsSubsystem FontsSubsystem { get; set; }
Property Value
Examples
Shows how to save a document in pdf format using specified default font.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string dataDir_save = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
oneFile.Save(
dataDir_save,
new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
}
);
Shows how to save a document in pdf format using default font from a file.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string dataDirWithOutputPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
oneFile.Save(dataDirWithOutputPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
Shows how to save a document in pdf format using default font from a stream.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string saveFilePath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(saveFilePath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
PageCount
Gets or sets the number of pages to save. By default is System.Int32.MaxValuewhich means all pages of the document will be rendered.
public int PageCount
{
get;
private set;
}
Property Value
Examples
Shows how to save a document in pdf format.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
PageIndex = 0,
PageCount = 1
};
string dataDirWithOutputPath = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDirWithOutputPath, opts);
Shows how to save a document in pdf format using specific settings.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions
{
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
JpegQuality = 90
};
dataDir += "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
Shows how to create a document and save in html format specified range of pages.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText()
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText()
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText()
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir += "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
PageIndex
Gets or sets the index of the first page to save. By default is 0.
public int PageIndex
{
get;
private set;
}
Property Value
Examples
Shows how to save a document in png format.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
ImageSaveOptions opts = new ImageSaveOptions(SaveFormat.Png)
{
PageIndex = 1
};
dataDir += "ConvertSpecificPageToImage_out.png";
oneFile.Save(dataDir, opts);
Shows how to save a document in pdf format.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions
{
PageIndex = 0,
PageCount = 1
};
string dataDirWithOutputPath = dataDir + "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDirWithOutputPath, opts);
Shows how to save a document in pdf format using specific settings.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
ImageCompression = Saving.Pdf.PdfImageCompression.Jpeg,
JpegQuality = 90
};
dataDir += "Document.SaveWithOptions_out.pdf";
doc.Save(dataDir, opts);
Shows how to create a document and save in html format specified range of pages.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText()
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText()
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText()
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir += "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
Shows how to create a document with formatted rich text.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page();
Title title = new Title();
ParagraphStyle defaultTextStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText titleText = new RichText() { ParagraphStyle = defaultTextStyle }.Append("Title!");
Outline outline = new Outline()
{
VerticalOffset = 100,
HorizontalOffset = 100
};
OutlineElement outlineElem = new OutlineElement();
TextStyle textStyleForHelloWord = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10
};
TextStyle textStyleForOneNoteWord = new TextStyle
{
FontColor = Color.Green,
FontName = "Calibri",
FontSize = 10,
IsItalic = true
};
TextStyle textStyleForTextWord = new TextStyle
{
FontColor = Color.Blue,
FontName = "Arial",
FontSize = 15,
IsBold = true,
IsItalic = true
};
RichText text = new RichText()
.Append("Hello", textStyleForHelloWord)
.Append(" OneNote", textStyleForOneNoteWord)
.Append(" text", textStyleForTextWord)
.Append("!", TextStyle.Default);
title.TitleText = titleText;
page.Title = title;
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "CreateDocWithFormattedRichText_out.one";
doc.Save(dataDir);
SaveFormat
Gets the format in which the document is saved.
public SaveFormat GetSaveFormat()
{
return this.SaveFormat;
}