Class Document
名称: Aspose.Note 合計: Aspose.Note.dll (25.4.0)
Aspose.Note ドキュメントを表示します。
public class Document : CompositeNode<Page>, INode, ICompositeNode<Page>, ICompositeNode, IEnumerable<Page>, IEnumerable, INotebookChildNode
{
}
Inheritance
object
←
Node
←
CompositeNodeBase
←
CompositeNode
Implements
INode
,
ICompositeNode
相続人
CompositeNode
Examples
デフォルトオプションで標準 Windows 対話を使用してプリンターに文書を送信する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
文書を保存する方法を教えてください。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
暗号化された文書の仕組みを示す。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
LoadOptions loadOptions = new LoadOptions { DocumentPassword = "password" };
Document doc = new Document(dataDir + "Sample1.one", loadOptions);
暗号化で文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_NoteBook();
Document document = new Document();
document.Save(dataDir + "CreatingPasswordProtectedDoc_out.one", new OneSaveOptions { DocumentPassword = "pass" });
SaveFormat リストを使用してドキュメントを保存する方法を示します。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingSaveFormat_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, SaveFormat.One);
OneSaveOptions を使用してドキュメントを保存する方法を示します。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingOneSaveOptions_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, new OneSaveOptions());
文書のページ数を取得する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Document oneFile = new Document(dataDir + "Aspose.one");
int count = oneFile.Count();
Console.WriteLine(count);
PDF形式のドキュメントをデフォルト設定で保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveWithDefaultSettings_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
GIF形式でドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToImageDefaultOptions_out.gif";
oneFile.Save(dataDir, SaveFormat.Gif);
JPEG形式で画像としてドキュメントを保存する際に画像の品質を設定する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Quality = 100 });
画像としてドキュメントを保存する際に画像解像度を設定する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
int resolution = 220;
dataDir = dataDir + "SetOutputImageResolution_out.jpg";
doc.Save(dataDir, new ImageSaveOptions(SaveFormat.Jpeg) { Resolution = resolution });
文書のファイル形式を取得する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
switch (document.FileFormat)
{
case FileFormat.OneNote2010:
break;
case FileFormat.OneNoteOnline:
break;
}
画像にハイパーリンクを結びつける方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg") { HyperlinkUrl = "http://image.com" };
page.AppendChildLast(image);
document.AppendChildLast(page);
document.Save(dataDir + "Image with Hyperlink_out.one");
文書をストリームに保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
dstStream.Seek(0, SeekOrigin.Begin);
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
新しいセクションをノートブックに追加する方法を示します。
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));
dataDir += @"\AddChildNode_out.onetoc2";
notebook.Save(dataDir);
OneNote 2007 フォーマットがサポートされていないため、ドキュメントのロードが失敗しているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "OneNote2007.one");
try
{
new Document(fileName);
}
catch (UnsupportedFileFormatException e)
{
if (e.FileFormat == FileFormat.OneNote2007)
{
Console.WriteLine("It looks like the provided file is in OneNote 2007 format that is not supported.");
}
else
{
throw;
}
}
ページの以前のバージョンを復元する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
Page previousPageVersion = document.GetPageHistory(page).Last();
document.RemoveChild(page);
document.AppendChildLast(previousPageVersion);
document.Save(dataDir + "RollBackRevisions_out.one");
ページをクローンする方法を教えてください。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone());
cloned = new Document();
cloned.AppendChildLast(document.FirstChild.Clone(true));
すべてのリソース(css/fonts/images)を別々のファイルに保存することによって、HTML形式の文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportAsStream,
ExportFonts = ResourceExportType.ExportAsStream,
ExportImages = ResourceExportType.ExportAsStream,
FontFaceTypes = FontFaceType.Ttf
};
document.Save(dataDir + "document_out.html", options);
すべてのリソース(css/fonts/images)を組み込むHTML形式のストリームに文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
var options = new HtmlSaveOptions()
{
ExportCss = ResourceExportType.ExportEmbedded,
ExportFonts = ResourceExportType.ExportEmbedded,
ExportImages = ResourceExportType.ExportEmbedded,
FontFaceTypes = FontFaceType.Ttf
};
var r = new MemoryStream();
document.Save(r, options);
画像のためのテキスト説明を設定する方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
var document = new Document();
var page = new Page(document);
var image = new Image(document, dataDir + "image.jpg")
{
AlternativeTextTitle = "This is an image's title!",
AlternativeTextDescription = "And this is an image's description!"
};
page.AppendChildLast(image);
document.AppendChildLast(page);
dataDir += "ImageAlternativeText_out.one";
document.Save(dataDir);
ページに関するメタ情報を取得する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Aspose.Words.Document oneFile = new Aspose.Words.Document(dataDir + "Aspose.one");
foreach (Aspose.Words.Page page in oneFile)
{
Console.WriteLine("LastModifiedTime: {0}", page.LastModifiedTime);
Console.WriteLine("CreationTime: {0}", page.CreationTime);
Console.WriteLine("Title: {0}", page.Title);
Console.WriteLine("Level: {0}", page.Level);
Console.WriteLine("Author: {0}", page.Author);
Console.WriteLine();
}
長い OneNote ページが PDF 形式で保存されている場合、ページに分けられます. サンプルでは、そのページのブレイクに位置するオブジェクトの分割論理を設定する方法を示しています。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(100);
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(400);
dataDir = dataDir + "PageSplittUsingKeepPartAndCloneSolidObjectToNextPageAlgorithm_out.pdf";
doc.Save(dataDir, pdfSaveOptions);
png形式で文書を保存する方法を示します。
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);
ページの歴史を編集する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
var pageHistory = document.GetPageHistory(page);
pageHistory.RemoveRange(0, 1);
pageHistory[0] = new Page(document);
if (pageHistory.Count > 1)
{
pageHistory[1].Title.TitleText.Text = "New Title";
pageHistory.Add(new Page(document));
pageHistory.Insert(1, new Page(document));
document.Save(dataDir + "ModifyPageHistory_out.one");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
ドキュメントにダークテーマスタイルを適用する方法を示します。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<Aspose.Words.RichText>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));
ノートブックのコンテンツを通過する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = "Open Notebook.onetoc2";
try
{
var notebook = new Notebook(dataDir + fileName);
foreach (var notebookChildNode in notebook)
{
Console.WriteLine(notebookChildNode.DisplayName);
if (notebookChildNode is Document)
{
}
else if (notebookChildNode is Notebook)
{
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
文書から画像を取得する方法を示す。
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
IList<aspose.note.Image> nodes = oneFile.GetChildNodes<aspose.note.Image>();
foreach (var image in nodes)
{
using (MemoryStream stream = new MemoryStream(image.Bytes))
{
using (Bitmap bitMap = new Bitmap(stream))
{
bitMap.Save(Path.Combine(dataDir, Path.GetFileName(image.FileName)));
}
}
}
PDF形式で文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
PageIndex = 0,
PageCount = 1,
};
dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
特定の設定を使用してPDF形式の文書を保存する方法を示します。
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);
指定されたオプションを含む標準 Windows 対話を使用してプリンターに文書を送信する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
var printerSettings = new PrinterSettings()
{
FromPage = 0,
ToPage = 10
};
printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
document.Print(new PrintOptions()
{
PrinterSettings = printerSettings,
Resolution = 1200,
PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
DocumentName = "Test.one"
});
付属ファイルのコンテンツを取得する方法を示します。
string dataDir = RunExamples.GetDataDir_Attachments();
Document oneFile = new Document(dataDir + "Sample1.one");
IList<attachedfile> nodes = oneFile.GetChildNodes<attachedfile>();
foreach (AttachedFile file in nodes)
{
using (Stream outputStream = new MemoryStream(file.Bytes))
{
using (System.IO.FileStream fileStream = System.IO.File.OpenWrite(String.Format(dataDir + file.FileName)))
{
CopyStream(outputStream, fileStream);
}
}
}
画像のメタ情報を取得する方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
Document oneFile = new Document(dataDir + "Aspose.one");
IList<aspose.note.Image> images = oneFile.GetChildNodes<aspose.note.Image>();
foreach (Aspose.Note.Image image in images)
{
Console.WriteLine("Width: {0}", image.Width);
Console.WriteLine("Height: {0}", image.Height);
Console.WriteLine("OriginalWidth: {0}", image.OriginalWidth);
Console.WriteLine("OriginalHeight: {0}", image.OriginalHeight);
Console.WriteLine("FileName: {0}", image.FileName);
Console.WriteLine("LastModifiedTime: {0}", image.LastModifiedTime);
Console.WriteLine();
}
ページの歴史を得る方法を示す。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
Page firstPage = document.FirstChild;
foreach (Page pageRevision in document.GetPageHistory(firstPage))
{
Console.WriteLine("LastModifiedTime: {0}", pageRevision.LastModifiedTime);
Console.WriteLine("CreationTime: {0}", pageRevision.CreationTime);
Console.WriteLine("Title: {0}", pageRevision.Title);
Console.WriteLine("Level: {0}", pageRevision.Level);
Console.WriteLine("Author: {0}", pageRevision.Author);
Console.WriteLine();
}
ファイルパスを使用して文書にファイルを追加する方法を示します。
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");
outlineElem.AppendChildLast(attachedFile);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileByPath_out.one";
doc.Save(dataDir);
ドキュメントを作成し、デフォルトオプションを使用して html 形式で保存する方法を示します。
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 = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
ページが紛争ページであるかどうかを確認する方法を示します(すなわち、OneNote が自動的に合併できない変更があります)。
string dataDir = RunExamples.GetDataDir_Pages();
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write("{0}. Author: {1}, {2:dd.MM.yyyy hh.mm.ss}",
i,
historyPage.PageContentRevisionSummary.AuthorMostRecent,
historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
ユーザーが定義した属性を持つ文書にファイルから画像を追加する方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document(dataDir + "Aspose.one");
Aspose.Note.Page page = doc.FirstChild;
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Width = 100,
Height = 100,
HorizontalOffset = 100,
VerticalOffset = 400,
Alignment = HorizontalAlignment.Right
};
page.AppendChildLast(image);
ストリームからドキュメントにファイルを追加する方法を示します。
string dataDir = RunExamples.GetDataDir_Attachments();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
using (var stream = File.OpenRead(dataDir + "icon.jpg"))
{
AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);
outlineElem.AppendChildLast(attachedFile);
}
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "AttachFileAndSetIcon_out.one";
doc.Save(dataDir);
長い OneNote ページが PDF 形式で保存されている場合、それらはページに分けられます. 例では、ページのブレイクに位置するオブジェクトの分割論理を設定する方法を示しています。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
var pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.PageSplittingAlgorithm = new AlwaysSplitObjectsAlgorithm();
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm();
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm();
float heightLimitOfClonedPart = 500;
pdfSaveOptions.PageSplittingAlgorithm = new KeepPartAndCloneSolidObjectToNextPageAlgorithm(heightLimitOfClonedPart);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(heightLimitOfClonedPart);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(100);
pdfSaveOptions.PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(400);
dataDir = dataDir + "UsingKeepSOlidObjectsAlgorithm_out.pdf";
doc.Save(dataDir, pdfSaveOptions);
文書を作成する方法を示し、特定のページ範囲をHTML形式で保存します。
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 = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
タイトルページを持つ文書を作成する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
doc.AppendChildLast(page);
dataDir += "CreateDocWithPageTitle_out.one";
doc.Save(dataDir);
ストリームからドキュメントに画像を追加する方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline1 = new Outline(doc);
OutlineElement outlineElem1 = new OutlineElement(doc);
using (FileStream fs = File.OpenRead(dataDir + "image.jpg"))
{
Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins.jpg", fs)
{
Alignment = HorizontalAlignment.Right
};
outlineElem1.AppendChildLast(image1);
}
outline1.AppendChildLast(outlineElem1);
page.AppendChildLast(outline1);
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
doc.Save(dataDir);
ファイルから文書に画像を追加する方法を示します。
string dataDir = RunExamples.GetDataDir_Images();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg")
{
Alignment = HorizontalAlignment.Right
};
outlineElem.AppendChildLast(image);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "BuildDocAndInsertImage_out.one";
doc.Save(dataDir);
テキストで文書を作成する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText text = new RichText(doc)
{
Text = "Hello OneNote text!",
ParagraphStyle = textStyle
};
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "CreateDocWithSimpleRichText_out.one";
doc.Save(dataDir);
さまざまなフォーマットで文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
doc.AppendChildLast(page);
doc.Save(dataDir + "ConsequentExportOperations_out.html");
doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
textStyle.FontSize = 11;
doc.DetectLayoutChanges();
doc.Save(dataDir + "ConsequentExportOperations_out.bmp");
すべてのリソース(css/fonts/images)を保存することによって html 形式のドキュメントを保管する方法を表示し、ユーザーによって定義された通話バックを使用します。
using System.IO;
using Aspose.Words;
var savingCallbacks = new UserSavingCallbacks
{
RootFolder = "documentFolder",
CssFolder = "css",
KeepCssStreamOpened = true,
ImagesFolder = "images",
FontsFolder = "fonts"
};
var options = new HtmlSaveOptions
{
FontFaceTypes = FontFaceType.Ttf,
CssSavingCallback = savingCallbacks,
FontSavingCallback = savingCallbacks,
ImageSavingCallback = savingCallbacks
};
if (!Directory.Exists(savingCallbacks.RootFolder))
{
Directory.CreateDirectory(savingCallbacks.RootFolder);
}
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Document(Path.Combine(dataDir, "Aspose.one"));
using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
{
document.Save(stream, options);
}
using (var writer = new StreamWriter(savingCallbacks.CssStream))
{
writer.WriteLine();
writer.WriteLine("/* This line is appended to stream manually by user */");
}
テキストにハイパーリンクを結びつける方法を示します。
string dataDir = RunExamples.GetDataDir_Tasks();
Document doc = new Document();
RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
Outline outline = new Outline()
{
MaxWidth = 200,
MaxHeight = 200,
VerticalOffset = 100,
HorizontalOffset = 100
};
TextStyle textStyleRed = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10
};
TextStyle textStyleHyperlink = new TextStyle
{
IsHyperlink = true,
HyperlinkAddress = "www.google.com"
};
RichText text = new RichText()
.Append("This is ", textStyleRed)
.Append("hyperlink", textStyleHyperlink)
.Append(". This text is not a hyperlink.", TextStyle.Default);
OutlineElement outlineElem = new OutlineElement();
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
Title title = new Title() { TitleText = titleText };
Page page = new Note.Page() { Title = title };
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
訪問者を使用して文書のコンテンツにアクセスする方法を示します。
public static void Run()
{
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
doc.Accept(myConverter);
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
NodeCount = 0;
IsSkipText = false;
Builder = new StringBuilder();
}
public string GetText()
{
return Builder.ToString();
}
private void AppendText(string text)
{
if (!IsSkipText)
{
Builder.AppendLine(text);
}
}
public override void VisitRichTextStart(RichText run)
{
++NodeCount;
AppendText(run.Text);
}
public override void VisitDocumentStart(Document document)
{
++NodeCount;
}
public override void VisitPageStart(Page page)
{
++NodeCount;
AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
public override void VisitPageEnd(Page page)
{
AppendText(string.Empty);
}
public override void VisitTitleStart(Title title)
{
++NodeCount;
}
public override void VisitImageStart(Image image)
{
++NodeCount;
}
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++NodeCount;
}
public override void VisitOutlineStart(Outline outline)
{
++NodeCount;
}
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++NodeCount;
}
public Int32 NodeCount
{
get { return this.nodeCount; }
}
private readonly StringBuilder Builder;
private bool IsSkipText;
private int nodeCount;
}
Constructors
文書( )
Aspose.Note.ドキュメントクラスの新しいインスタンスを開始します。白い OneNote ドキュメントを作成します。
public Document()
{
}
ドキュメンタリー(ストリング)
Aspose.Note.ドキュメントクラスの新しいインスタンスを開始します。ファイルから既存の OneNote ドキュメントを開きます。
public Document(string filePath)
{
}
Parameters
filePath
string
ファイルパス
Exceptions
UnsupportedFileFormatException
文書形式は認められず、サポートされていません。
文書は腐敗しているようですし、充電することはできません。
文書は暗号化され、パスワードを開く必要がありますが、間違ったパスワードを提供しました。
文書に問題があり、 Aspose.Note 開発者に報告されるべきです。
入力・出力の例外があります。
ドキュメント(ストリング、LoadOptions)
Aspose.Note.ドキュメントクラスの新しいインスタンスを開始します。ファイルから既存の OneNote ドキュメントを開きます. 暗号化パスワードなどの追加のオプションを指定することを可能にします。
public Document(string filePath, LoadOptions loadOptions)
{
}
Parameters
filePath
string
ファイルパス
loadOptions
LoadOptions
ドキュメントをアップロードするために使用されるオプションは、ゼロかもしれません。
Exceptions
UnsupportedFileFormatException
文書形式は認められず、サポートされていません。
文書は腐敗しているようですし、充電することはできません。
文書は暗号化され、パスワードを開く必要がありますが、間違ったパスワードを提供しました。
文書に問題があり、 Aspose.Note 開発者に報告されるべきです。
入力・出力の例外があります。
ドキュメント(ストリーム)
Aspose.Note.ドキュメントクラスの新しいインスタンスを開始します。ストリームから既存の OneNote ドキュメントを開きます。
public Document(Stream inStream)
{
}
Parameters
inStream
Stream
流れです。
Exceptions
UnsupportedFileFormatException
文書形式は認められず、サポートされていません。
文書は腐敗しているようですし、充電することはできません。
文書は暗号化され、パスワードを開く必要がありますが、間違ったパスワードを提供しました。
文書に問題があり、 Aspose.Note 開発者に報告されるべきです。
入力・出力の例外があります。
ストリームは読書をサポートしません、ゼロです、またはすでに閉鎖されています。
ドキュメント(ストリーム、ロードオプション)
Aspose.Note.ドキュメントクラスの新しいインスタンスを開始します。ストリームから既存の OneNote ドキュメントを開きます. 暗号化パスワードなどの追加のオプションを指定することを可能にします。
public Document(Stream inStream, LoadOptions loadOptions)
{
}
Parameters
inStream
Stream
流れです。
loadOptions
LoadOptions
ドキュメントをアップロードするために使用されるオプションは、ゼロかもしれません。
Exceptions
UnsupportedFileFormatException
文書形式は認められず、サポートされていません。
文書は腐敗しているようですし、充電することはできません。
文書は暗号化され、パスワードを開く必要がありますが、間違ったパスワードを提供しました。
文書に問題があり、 Aspose.Note 開発者に報告されるべきです。
入力・出力の例外があります。
ストリームは読書をサポートしません、ゼロです、またはすでに閉鎖されています。
Properties
AutomaticLayoutChangesDetectionEnabled
Aspose.Note が自動的に配置の変更を検出するかどうかを示す値を取得または設定します.デフォルト値は「真実」です。
public bool AutomaticLayoutChangesDetectionEnabled
{
get;
set;
}
不動産価値
Examples
さまざまなフォーマットで文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title(doc)
{
TitleText = new RichText(doc) { Text = "Title text.", ParagraphStyle = textStyle },
TitleDate = new RichText(doc) { Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle },
TitleTime = new RichText(doc) { Text = "12:34", ParagraphStyle = textStyle }
};
doc.AppendChildLast(page);
doc.Save(dataDir + "ConsequentExportOperations_out.html");
doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
textStyle.FontSize = 11;
doc.DetectLayoutChanges();
doc.Save(dataDir + "ConsequentExportOperations_out.bmp");
Color
色を入れるか、色を入れるか。
public Color Color
{
get { return this.Color; }
set { this.Color = value; }
}
不動産価値
CreationTime
創造の時間を得たり設定したりする。
public DateTime CreationTime
{
get;
set;
}
不動産価値
DisplayName
受信または表示名を設定します。
public string DisplayName
{
get;
set;
}
不動産価値
FileFormat
ファイル形式を取得する(OneNote 2010, OneNota Online)
public FileFormat FileFormat
{
get;
}
不動産価値
Examples
文書のファイル形式を取得する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
switch (document.FileFormat)
{
case Aspose.Words.FileFormat.OneNote2010:
break;
case Aspose.Words.FileFormat.OneNoteOnline:
break;
}
Guid
オブジェクトのグローバルでユニークなIDを取得します。
public Guid Guid
{
get;
}
不動産価値
Methods
受け入れ(ドキュメント訪問者)
ノードの訪問者を受け入れる。
public override void Accept(DocumentVisitor visitor)
{
}
Parameters
visitor
DocumentVisitor
クラスのオブジェクトは Aspose.Note.DocumentVisitor から引き出されます。
Examples
訪問者を使用して文書のコンテンツにアクセスする方法を示します。
public static void Run()
{
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MyOneNoteToTxtWriter myConverter = new MyOneNoteToTxtWriter();
doc.Accept(myConverter);
Console.WriteLine(myConverter.GetText());
Console.WriteLine(myConverter.NodeCount);
}
public class MyOneNoteToTxtWriter : DocumentVisitor
{
public MyOneNoteToTxtWriter()
{
nodecount = 0;
mIsSkipText = false;
mBuilder = new StringBuilder();
}
public string GetText()
{
return mBuilder.ToString();
}
private void AppendText(string text)
{
if (!mIsSkipText)
{
mBuilder.AppendLine(text);
}
}
public override void VisitRichTextStart(RichText run)
{
++nodecount;
AppendText(run.Text);
}
public override void VisitDocumentStart(Document document)
{
++nodecount;
}
public override void VisitPageStart(Page page)
{
++nodecount;
this.AppendText($"*** Page '{page.Title?.TitleText?.Text ?? "(no title)"}' ***");
}
public override void VisitPageEnd(Page page)
{
this.AppendText(string.Empty);
}
public override void VisitTitleStart(Title title)
{
++nodecount;
}
public override void VisitImageStart(Image image)
{
++nodecount;
}
public override void VisitOutlineGroupStart(OutlineGroup outlineGroup)
{
++nodecount;
}
public override void VisitOutlineStart(Outline outline)
{
++nodecount;
}
public override void VisitOutlineElementStart(OutlineElement outlineElement)
{
++nodecount;
}
public Int32 NodeCount
{
get { return this.nodecount; }
}
private readonly StringBuilder mBuilder;
private bool mIsSkipText;
private Int32 nodecount;
}
レイアウト変更( )
以前の Aspose.Note.Document.DetectLayoutChanges の呼び出し以来、ドキュメントの配置にすべての変更を検出します。Aspose.Note.Document.AutomaticLayoutChangesDetectionEnabled が正確に設定され、ドキュメント輸出の開始時に自動的に使用されます。
public void DetectLayoutChanges()
{
}
Examples
さまざまなフォーマットで文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document() { AutomaticLayoutChangesDetectionEnabled = false };
Aspose.Note.Page page = new Aspose.Note.Page(doc);
ParagraphStyle textStyle = new ParagraphStyle()
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title(doc)
{
TitleText = new RichText(doc)
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText(doc)
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText(doc)
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
doc.AppendChildLast(page);
doc.Save(dataDir + "ConsequentExportOperations_out.html");
doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
textStyle.FontSize = 11;
doc.DetectLayoutChanges();
doc.Save(dataDir + "ConsequentExportOperations_out.bmp");
GetPageHistory(ページ)
Aspose.Note.PageHistory は、文書に掲載されている各ページの完全な歴史を含みます(インデックス0で最初のページ)。現在のページ修正は Aspose.Note.PageHistory.Current としてアクセスすることができ、歴史的なバージョンのコレクションから別々に含まれています。
public PageHistory GetPageHistory(Page page)
{
}
I have reformatted the given C# code by:
- Properly indented the method body and comments.
- Added a single space between the opening brace, method name, and opening parenthesis.
- Added a single line between the method signature and its implementation.
- Added two spaces for each level of nesting within the method body for improved readability.
Parameters
page
Page
ページの現在の修正
Returns
タイトル:Note.PageHistory
Examples
ページの以前のバージョンを復元する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
Page previousPageVersion = document.GetPageHistory(page).Last();
document.RemoveChild(page);
document.AppendChildLast(previousPageVersion);
document.Save(dataDir + "RollBackRevisions_out.one");
ページの歴史を編集する方法を示します。
string dataDir = RunExamples.GetDataDir_Pages();
Document document = new Document(dataDir + "Aspose.one");
Page page = document.FirstChild;
var pageHistory = document.GetPageHistory(page);
pageHistory.RemoveRange(0, 1);
pageHistory[0] = new Page(document);
if (pageHistory.Count > 1)
{
pageHistory[1].Title.TitleText.Text = "New Title";
pageHistory.Add(new Page(document));
pageHistory.Insert(1, new Page(document));
document.Save(dataDir + "ModifyPageHistory_out.one");
}
ページが紛争ページであるかどうかを確認する方法を示します(すなわち、OneNote が自動的に合併できない変更があります)。
string dataDir = RunExamples.GetDataDir_Pages();
Document doc = new Document(dataDir + "Aspose.one", new LoadOptions { LoadHistory = true });
var history = doc.GetPageHistory(doc.FirstChild);
for (int i = 0; i < history.Count; i++)
{
var historyPage = history[i];
Console.Write(" {0}. Author: ", i);
Console.Write("{1}, ", historyPage.PageContentRevisionSummary.AuthorMostRecent);
Console.WriteLine("{2:dd.MM.yyyy hh.mm.ss}", historyPage.PageContentRevisionSummary.LastModifiedTime);
Console.WriteLine(historyPage.IsConflictPage ? ", IsConflict: true" : string.Empty);
if (historyPage.IsConflictPage)
historyPage.IsConflictPage = false;
}
doc.Save(dataDir + "ConflictPageManipulation_out.one", SaveFormat.One);
輸入(ストリーム、PdfImportOptions、メルゲオプション)
提供された PDF ドキュメントからページのセットをインポートします。
public Document Import(Stream stream, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
{
}
Parameters
stream
Stream
PDFドキュメントを含むストリーム。
importOptions
PdfImportOptions
PDF ドキュメントからページをインポートする方法のオプションを指定します。
mergeOptions
MergeOptions
提供されたページを組み合わせる方法のオプションを指定します。
Returns
文書への参照を返します。
輸入(ストリング、PdfImportOptions、メルゲオプション)
提供された PDF ドキュメントからページのセットをインポートします。
public Document Import(string file, PdfImportOptions importOptions = null, MergeOptions mergeOptions = null)
{
}
Parameters
file
string
PDFドキュメントを含むファイルです。
importOptions
PdfImportOptions
PDF ドキュメントからページをインポートする方法のオプションを指定します。
mergeOptions
MergeOptions
提供されたページを組み合わせる方法のオプションを指定します。
Returns
文書への参照を返します。
Examples
ページごとにPDFドキュメントページからすべてのページをインポートする方法を示します。
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
d.Import(Path.Combine(dataDir, "sampleText.pdf"))
.Import(Path.Combine(dataDir, "sampleImage.pdf"))
.Import(Path.Combine(dataDir, "sampleTable.pdf"));
d.Save(Path.Combine(dataDir, "sample_SimpleMerge.one"));
PDF ドキュメントのセットからすべてのページをインポートする方法を示し、トップレベルの OneNote ページの子供として各 PDF のページを入力します。
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
foreach (var file in new[] { "sampleText.pdf", "sampleImage.pdf", "sampleTable.pdf" })
{
d.AppendChildLast(new Page())
.Title
.SetTitleText(new RichText() { ParagraphStyle = ParagraphStyle.Default }
.Append(file));
d.Import(Path.Combine(dataDir, file), new PdfImportOptions(), new MergeOptions() { InsertAt = int.MaxValue, InsertAsChild = true });
}
d.Save(Path.Combine(dataDir, "sample_StructuredMerge.one"));
PDF ドキュメントのセットからすべてのコンテンツをインポートする方法を示し、各 PDF のページを単一の OneNote ページに統合します。
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
var importOptions = new PdfImportOptions();
var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };
d.Import(Path.Combine(dataDir, "sampleText.pdf"), importOptions, mergeOptions)
.Import(Path.Combine(dataDir, "sampleImage.pdf"), importOptions, mergeOptions)
.Import(Path.Combine(dataDir, "sampleTable.pdf"), importOptions, mergeOptions);
d.Save(Path.Combine(dataDir, "sample_SinglePageMerge.one"));
輸入(ストリーム、HtmlImportOptions、メルゲオプション)
提供された HTML ドキュメントからページのセットをインポートします。
public Document Import(
Stream stream,
HtmlImportOptions importOptions,
MergeOptions mergeOptions = null)
{
}
Parameters
stream
Stream
HTMLドキュメントを含むストリーム。
importOptions
HtmlImportOptions
HTML ドキュメントからページをインポートする方法のオプションを指定します。
mergeOptions
MergeOptions
提供されたページを組み合わせる方法のオプションを指定します。
Returns
文書への参照を返します。
輸入(ストリング、HtmlImportOptions、メルゲオプション)
提供された HTML ドキュメントからページのセットをインポートします。
public Document Import(string file, HtmlImportOptions importOptions, MergeOptions mergeOptions = null)
{
}
Parameters
file
string
HTML ドキュメントを含むファイル。
importOptions
HtmlImportOptions
HTML ドキュメントからページをインポートする方法のオプションを指定します。
mergeOptions
MergeOptions
提供されたページを組み合わせる方法のオプションを指定します。
Returns
文書への参照を返します。
IsEncrypted(ストリーム、LoadOptions、オフドキュメント)
流れからの文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(Stream stream, LoadOptions options, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream, options);
return document.IsEncrypted;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return false;
}
Parameters
stream
Stream
流れです。
options
LoadOptions
負荷の選択肢
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ストリーム、ストリップ、オフドキュメント)
流れからの文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(Stream stream, string password, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream, Aspose.Words.FileFormatUtil.DetectEncryptionType(stream), password);
}
catch (Exception ex)
{
return false;
}
return true;
}
Parameters
stream
Stream
流れです。
password
string
パスワードがドキュメントを解読します。
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ストリーム、外ドキュメント)
流れからの文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(Stream stream, out Document document)
{
document = null;
try
{
document = new Document();
document.Load(stream);
return document.EncryptionSettings != null && document.EncryptionSettings.IsEncrypted;
}
catch
{
document = null;
throw;
}
}
Parameters
stream
Stream
流れです。
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ストリング、LoadOptions、オフドキュメント)
ファイルから文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(string filePath, LoadOptions options, out Document document)
{
document = null;
try
{
using (var doc = new Document(File.OpenRead(filePath), options))
{
document = doc;
return false;
}
}
catch (InvalidPasswordException ex)
{
document = null;
return true;
}
}
Parameters
filePath
string
ファイルパス
options
LoadOptions
負荷の選択肢
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ストリング、外ドキュメント)
ファイルから文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(string filePath, out Document document)
{
document = null;
try
{
Aspose.Words.Document asposeDoc = new Aspose.Words.Document(filePath);
document = asposeDoc;
return asposeDoc.ProtectionSettings.EncryptionInfo != null;
}
catch (Exception ex)
{
}
document = null;
return false;
}
Parameters
filePath
string
ファイルパス
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
IsEncrypted(ストリング、ストリング、オフドキュメント)
ファイルから文書が暗号化されているかどうかを確認します。それを確認するには、この文書を完全に積み重ねる必要があります. この方法は、パフォーマンス罰金を引き起こす可能性があります。
public static bool IsEncrypted(string filePath, string password, out Document document)
{
}
Parameters
filePath
string
ファイルパス
password
string
パスワードがドキュメントを解読します。
document
Document
充電された文書です。
Returns
文書が暗号化された場合に真実を返します。
Examples
文書がパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (!Document.IsEncrypted(fileName, out document))
{
Console.WriteLine("The document is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Provide a password.");
}
文書が特定のパスワードで保護されているかどうかを確認する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fileName = Path.Combine(dataDir, "Aspose.one");
Document document;
if (Document.IsEncrypted(fileName, "VerySecretPassword", out document))
{
if (document != null)
{
Console.WriteLine("The document is decrypted. It is loaded and ready to be processed.");
}
else
{
Console.WriteLine("The document is encrypted. Invalid password was provided.");
}
}
else
{
Console.WriteLine("The document is NOT encrypted. It is loaded and ready to be processed.");
}
合計(無数)メルジオプション)
文書に一連のページを挿入します。
public Document Merge(IEnumerable<Page> pages, MergeOptions mergeOptions = null)
{
}
Parameters
pages
IEnumerable
<
Page
>
一連のページ。
mergeOptions
MergeOptions
提供されたページを組み合わせる方法のオプションを指定します。
Returns
文書への参照を返します。
Examples
すべてのページを PDF ドキュメントから、5 ページごとに 1 つの OneNote のページにグループする方法を示します。
string dataDir = RunExamples.GetDataDir_Import();
var d = new Document();
var mergeOptions = new MergeOptions() { ImportAsSinglePage = true, PageSpacing = 100 };
IEnumerable<Page> pages = PdfImporter.Import(Path.Combine(dataDir, "SampleGrouping.pdf"));
while (pages.Any())
{
d.Merge(pages.Take(5), mergeOptions);
pages = pages.Skip(5);
}
d.Save(Path.Combine(dataDir, "sample_CustomMerge.one"));
印刷( )
デフォルトプリンターを使用して文書を印刷します。
public void Print()
{
}
Examples
デフォルトオプションで標準 Windows 対話を使用してプリンターに文書を送信する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
document.Print();
指定されたオプションを含む標準 Windows 対話を使用してプリンターに文書を送信する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
var document = new Aspose.Note.Document(dataDir + "Aspose.one");
var printerSettings = new PrinterSettings()
{
FromPage = 0,
ToPage = 10
};
printerSettings.DefaultPageSettings.Landscape = true;
printerSettings.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(50, 50, 150, 50);
document.Print(new PrintOptions()
{
PrinterSettings = printerSettings,
Resolution = 1200,
PageSplittingAlgorithm = new KeepSolidObjectsAlgorithm(),
DocumentName = "Test.one"
});
印刷(プリントオプション)
デフォルトプリンターを使用して文書を印刷します。
public void Print(PrintOptions options)
{
}
Parameters
options
PrintOptions
文書を印刷するために使用されるオプションは、ゼロかもしれません。
リリース(ストリング)
OneNote ドキュメントをファイルに保存します。
public void Save(string fileName)
{
}
Parameters
fileName
string
ファイルの完全名:指定された完全名前を含むファイルがすでに存在する場合、既存のファイルは書き換えられます。
Examples
文書を保存する方法を教えてください。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormat_out.one";
Document doc = new Document(dataDir + inputFile);
doc.Save(dataDir + outputFile);
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。
ストリーム(Save)
OneNote ドキュメントをストリームに保存します。
public void Save(Stream stream)
{
}
Parameters
stream
Stream
ドキュメントが保存されるシステム.IO.ストリーム。
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。
Save(ストリング、SaveFormat)
OneNote ドキュメントを指定された形式のファイルに保存します。
public void Save(string fileName, Aspose.Words.SaveFormat format)
{
}
Parameters
fileName
string
ファイルの完全名:指定された完全名前を含むファイルがすでに存在する場合、既存のファイルは書き換えられます。
format
SaveFormat
文書を保存するための形式
Examples
SaveFormat リストを使用してドキュメントを保存する方法を示します。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingSaveFormat_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, SaveFormat.One);
GIF形式でドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToImageDefaultOptions_out.gif";
oneFile.Save(dataDir, SaveFormat.Gif);
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。
Save(ストリーム、SaveFormat)
OneNote ドキュメントを指定された形式のストリームに保存します。
public void Save(Stream stream, SaveFormat format)
{
}
Parameters
stream
Stream
ドキュメントが保存されるシステム.IO.ストリーム。
format
SaveFormat
文書を保存するための形式
Examples
PDF形式のドキュメントをデフォルト設定で保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
string dataDirWithFileName = dataDir + "SaveWithDefaultSettings_out.pdf";
oneFile.Save(dataDirWithFileName, SaveFormat.Pdf);
文書をストリームに保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document(dataDir + "Aspose.one");
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
dstStream.Seek(0, SeekOrigin.Begin);
ドキュメントにダークテーマスタイルを適用する方法を示します。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<Aspose.Words.RichText>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。
Save(ストリング、SaveOptions)
OneNote ドキュメントを指定された保存オプションを使用してファイルに保存します。
public void Save(string fileName, SaveOptions options)
{
}
Parameters
fileName
string
ファイルの完全名:指定された完全名前を含むファイルがすでに存在する場合、既存のファイルは書き換えられます。
options
SaveOptions
ドキュメントがファイルに保存されている方法のオプションを指定します。
Examples
OneSaveOptions を使用してドキュメントを保存する方法を示します。
string inputFile = "Sample1.one";
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string outputFile = "SaveDocToOneNoteFormatUsingOneSaveOptions_out.one";
Document document = new Document(dataDir + inputFile);
document.Save(dataDir + outputFile, new OneSaveOptions());
SaveFormat を使用して JPEG 形式で画像としてドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToJpegImageUsingSaveFormat_out.jpg";
oneFile.Save(dataDir, SaveFormat.Jpeg);
ImageSaveOptions を使用して Bmp 形式で画像としてドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBmpImageUsingImageSaveOptions_out.bmp";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));
手紙ページの配置でPDF形式で文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingLetterPageSettings.pdf");
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.Letter });
高さ制限なしで A4 ページ配置で PDF 形式のドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "OneNote.one");
var dst = Path.Combine(dataDir, "SaveToPdfUsingA4PageSettingsWithoutHeightLimit.pdf");
oneFile.Save(dst, new PdfSaveOptions() { PageSettings = PageSettings.A4NoHeightLimit });
グレイスケール画像として文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveAsGrayscaleImage_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.GrayScale
});
PackBits 圧縮を使用して Tiff 形式の画像としてドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingPackBitsCompression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.PackBits
});
Jpeg 圧縮を使用して Tiff 形式の画像としてドキュメントを保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
TiffCompression = TiffCompression.Jpeg,
Quality = 93
});
CCITT グループ 3 ファックス 圧縮を使用して Tiff 形式の画像として文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
{
ColorMode = ColorMode.BlackAndWhite,
TiffCompression = TiffCompression.Ccitt3
});
PDF形式で文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
PdfSaveOptions opts = new PdfSaveOptions()
{
PageIndex = 0,
PageCount = 1,
};
dataDir += "SaveRangeOfPagesAsPDF_out.pdf";
oneFile.Save(dataDir, opts);
特定の設定を使用してPDF形式の文書を保存する方法を示します。
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);
Otsuの方法を使用して文書をバイナリーイメージとして保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBinaryImageUsingOtsuMethod_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.Otsu,
}
});
固定限界を使用して文書をバイナリーイメージとして保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(dataDir + "Aspose.one");
dataDir += "SaveToBinaryImageUsingFixedThreshold_out.png";
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
{
ColorMode = ColorMode.BlackAndWhite,
BinarizationOptions = new ImageBinarizationOptions()
{
BinarizationMethod = BinarizationMethod.FixedThreshold,
BinarizationThreshold = 123
}
});
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。
Save(ストリーム、Saveオプション)
OneNote ドキュメントを指定された保存オプションを使用してストリームに保存します。
public void Save(Stream stream, SaveOptions options)
{
}
Parameters
stream
Stream
ドキュメントが保存されるシステム.IO.ストリーム。
options
SaveOptions
文書が流れに保存される方法のオプションを指定します。
Examples
PDF形式で文書を保存する方法を指定したデフォルトフォントで表示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string dataDirWithOutputPath = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontName_out.pdf";
oneFile.Save(dataDirWithOutputPath, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFont("Times New Roman")
});
ファイルからデフォルトフォントを使用してPDF形式の文書を保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string outputFile = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromFile_out.pdf";
oneFile.Save(outputFile, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromFile(fontFile)
});
PDF形式のドキュメントをストリームからデフォルトフォントを使用して保存する方法を示します。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
string fontFile = Path.Combine(dataDir, "geo_1.ttf");
Document oneFile = new Document(Path.Combine(dataDir, "missing-font.one"));
string fullDataDir = dataDir + "SaveUsingDocumentFontsSubsystemWithDefaultFontFromStream_out.pdf";
using (var stream = File.Open(fontFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
oneFile.Save(fullDataDir, new PdfSaveOptions()
{
FontsSubsystem = DocumentFontsSubsystem.UsingDefaultFontFromStream(stream)
});
}
Exceptions
IncorrectDocumentStructureException
文書構造は規格に違反する。
UnsupportedSaveFormatException
リクエストされた保存形式はサポートされません。