Skip to content

Commit d849ffb

Browse files
author
Alexei Soloview
committed
Merge branch 'Samples20.11' into masterMain
2 parents 5316c89 + d1a88b0 commit d849ffb

9 files changed

+258
-14
lines changed

Examples/CSharp/CSharp.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<StartupObject>Aspose.Note.Examples.CSharp.RunExamples</StartupObject>
3737
</PropertyGroup>
3838
<ItemGroup>
39-
<Reference Include="Aspose.Note, Version=20.9.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
40-
<HintPath>..\packages\Aspose.Note.20.9.0\lib\net4.0\Aspose.Note.dll</HintPath>
39+
<Reference Include="Aspose.Note, Version=20.11.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Aspose.Note.20.11.0\lib\net4.0\Aspose.Note.dll</HintPath>
4141
</Reference>
4242
<Reference Include="System" />
4343
<Reference Include="System.Core" />
@@ -55,6 +55,11 @@
5555
<Compile Include="Attachments\AttachFileAndSetIcon.cs" />
5656
<Compile Include="Attachments\AttachFileByPath.cs" />
5757
<Compile Include="Attachments\RetrieveAttachedFiles.cs" />
58+
<Compile Include="Loading-and-Saving\SaveToBinaryImageUsingFixedThreshold.cs" />
59+
<Compile Include="Loading-and-Saving\SaveToBinaryImageUsingOtsuMethod.cs" />
60+
<Compile Include="Loading-and-Saving\SaveToBmpImageUsingImageSaveOptions.cs" />
61+
<Compile Include="Loading-and-Saving\SaveToGrayscaleImage.cs" />
62+
<Compile Include="Loading-and-Saving\SaveToJpegImageUsingSaveFormat.cs" />
5863
<Compile Include="Text\HighlightAllRecentChanges.cs" />
5964
<Compile Include="Images\BuildDocAndInsertImageUsingImageStream.cs" />
6065
<Compile Include="Images\BuildDocAndInsertImage.cs" />
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="SaveToBinaryImageUsingFixedThreshold.cs" company="Aspose Pty Ltd">
3+
// Copyright (c) 2002-2020 Aspose Pty Ltd. All Rights Reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Aspose.Note.Examples.CSharp.Loading_and_Saving
8+
{
9+
using System;
10+
11+
using Aspose.Note.Saving;
12+
13+
class SaveToBinaryImageUsingFixedThreshold
14+
{
15+
public static void Run()
16+
{
17+
// ExStart:SaveToBinaryImageUsingFixedThreshold
18+
// ExFor:Document.Save(System.String, Aspose.Note.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExFor:ImageSaveOptions.ColorMode
22+
// ExFor:ImageSaveOptions.BinarizationOptions
23+
// ExFor:ColorMode
24+
// ExFor:ImageBinarizationOptions
25+
// ExFor:ImageBinarizationOptions.BinarizationMethod
26+
// ExFor:ImageBinarizationOptions.BinarizationThreshold
27+
// ExFor:BinarizationMethod
28+
// ExSummary:Shows how to save a document as binary image using fixed threshold.
29+
30+
// The path to the documents directory.
31+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
32+
33+
// Load the document into Aspose.Note.
34+
Document oneFile = new Document(dataDir + "Aspose.one");
35+
36+
dataDir = dataDir + "SaveToBinaryImageUsingFixedThreshold_out.png";
37+
38+
// Save the document as gif.
39+
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
40+
{
41+
ColorMode = ColorMode.BlackAndWhite,
42+
BinarizationOptions = new ImageBinarizationOptions()
43+
{
44+
BinarizationMethod = BinarizationMethod.FixedThreshold,
45+
BinarizationThreshold = 123
46+
}
47+
});
48+
49+
// ExEnd:SaveToBinaryImageUsingFixedThreshold
50+
51+
Console.WriteLine("\nOneNote document converted successfully to binary image using fixed threshold.\nFile saved at " + dataDir);
52+
}
53+
}
54+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="SaveToBinaryImageUsingOtsuMethod.cs" company="Aspose Pty Ltd">
3+
// Copyright (c) 2002-2020 Aspose Pty Ltd. All Rights Reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Aspose.Note.Examples.CSharp.Loading_and_Saving
8+
{
9+
using System;
10+
11+
using Aspose.Note.Saving;
12+
13+
class SaveToBinaryImageUsingOtsuMethod
14+
{
15+
public static void Run()
16+
{
17+
// ExStart:SaveToBinaryImageUsingOtsuMethod
18+
// ExFor:Document.Save(System.String, Aspose.Note.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExFor:ImageSaveOptions.ColorMode
22+
// ExFor:ImageSaveOptions.BinarizationOptions
23+
// ExFor:ColorMode
24+
// ExFor:ImageBinarizationOptions
25+
// ExFor:ImageBinarizationOptions.BinarizationMethod
26+
// ExFor:BinarizationMethod
27+
// ExSummary:Shows how to save a document as binary image using Otsu's method.
28+
29+
// The path to the documents directory.
30+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
31+
32+
// Load the document into Aspose.Note.
33+
Document oneFile = new Document(dataDir + "Aspose.one");
34+
35+
dataDir = dataDir + "SaveToBinaryImageUsingOtsuMethod_out.png";
36+
37+
// Save the document as gif.
38+
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
39+
{
40+
ColorMode = ColorMode.BlackAndWhite,
41+
BinarizationOptions = new ImageBinarizationOptions()
42+
{
43+
BinarizationMethod = BinarizationMethod.Otsu,
44+
}
45+
});
46+
47+
// ExEnd:SaveToBinaryImageUsingOtsuMethod
48+
49+
Console.WriteLine("\nOneNote document converted successfully to binary image using Otsu's method.\nFile saved at " + dataDir);
50+
}
51+
}
52+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="SaveToBmpImageUsingImageSaveOptions.cs" company="Aspose Pty Ltd">
3+
// Copyright (c) 2002-2020 Aspose Pty Ltd. All Rights Reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Aspose.Note.Examples.CSharp.Loading_and_Saving
8+
{
9+
using System;
10+
11+
using Aspose.Note.Saving;
12+
13+
class SaveToBmpImageUsingImageSaveOptions
14+
{
15+
public static void Run()
16+
{
17+
// ExStart:SaveToBmpImageUsingImageSaveOptions
18+
// ExFor:Document.Save(System.String, Aspose.Note.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExFor:ImageSaveOptions.ColorMode
22+
// ExFor:ColorMode
23+
// ExSummary:Shows how to save a document as grayscale image.
24+
25+
// The path to the documents directory.
26+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
27+
28+
// Load the document into Aspose.Note.
29+
Document oneFile = new Document(dataDir + "Aspose.one");
30+
31+
dataDir = dataDir + "SaveToBmpImageUsingImageSaveOptions_out.bmp";
32+
33+
// Save the document as gif.
34+
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));
35+
36+
// ExEnd:SaveToBmpImageUsingImageSaveOptions
37+
38+
Console.WriteLine("\nOneNote document converted successfully to image in Bmp.\nFile saved at " + dataDir);
39+
}
40+
}
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="SaveToGrayscaleImage.cs" company="Aspose Pty Ltd">
3+
// Copyright (c) 2002-2020 Aspose Pty Ltd. All Rights Reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Aspose.Note.Examples.CSharp.Loading_and_Saving
8+
{
9+
using System;
10+
11+
using Aspose.Note.Saving;
12+
13+
class SaveToGrayscaleImage
14+
{
15+
public static void Run()
16+
{
17+
// ExStart:SaveAsGrayscaleImage
18+
// ExFor:Document.Save(System.String, Aspose.Note.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExFor:ImageSaveOptions.ColorMode
22+
// ExFor:ColorMode
23+
// ExSummary:Shows how to save a document as grayscale image.
24+
25+
// The path to the documents directory.
26+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
27+
28+
// Load the document into Aspose.Note.
29+
Document oneFile = new Document(dataDir + "Aspose.one");
30+
31+
dataDir = dataDir + "SaveAsGrayscaleImage_out.png";
32+
33+
// Save the document as gif.
34+
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
35+
{
36+
ColorMode = ColorMode.GrayScale
37+
});
38+
39+
// ExEnd:SaveAsGrayscaleImage
40+
41+
Console.WriteLine("\nOneNote document converted successfully to grayscale image.\nFile saved at " + dataDir);
42+
}
43+
}
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="SaveToJpegImageUsingSaveFormat.cs" company="Aspose Pty Ltd">
3+
// Copyright (c) 2002-2020 Aspose Pty Ltd. All Rights Reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Aspose.Note.Examples.CSharp.Loading_and_Saving
8+
{
9+
using System;
10+
11+
using Aspose.Note.Saving;
12+
13+
class SaveToJpegImageUsingSaveFormat
14+
{
15+
public static void Run()
16+
{
17+
// ExStart:SaveToJpegImageUsingSaveFormat
18+
// ExFor:Document.Save(System.String, Aspose.Note.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExFor:ImageSaveOptions.ColorMode
22+
// ExFor:ColorMode
23+
// ExSummary:Shows how to save a document as grayscale image.
24+
25+
// The path to the documents directory.
26+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
27+
28+
// Load the document into Aspose.Note.
29+
Document oneFile = new Document(dataDir + "Aspose.one");
30+
31+
dataDir = dataDir + "SaveToJpegImageUsingSaveFormat_out.jpg";
32+
33+
// Save the document as gif.
34+
oneFile.Save(dataDir, SaveFormat.Jpeg);
35+
36+
// ExEnd:SaveToJpegImageUsingSaveFormat
37+
38+
Console.WriteLine("\nOneNote document converted successfully to image in Jpeg.\nFile saved at " + dataDir);
39+
}
40+
}
41+
}

Examples/CSharp/RunExamples.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
namespace Aspose.Note.Examples.CSharp
2121
{
22+
using Aspose.Note.Examples.CSharp.Loading_and_Saving;
23+
2224
class RunExamples
2325
{
2426
[STAThread]
@@ -60,8 +62,13 @@ public static void Main()
6062
//SaveDocToOneNoteFormat.Run();
6163
//SaveDocToOneNoteFormatUsingOnesaveoptions.Run();
6264
//SaveDocToOneNoteFormatUsingSaveFormat.Run();
63-
SaveRangeOfPagesAsPDF.Run();
65+
//SaveRangeOfPagesAsPDF.Run();
6466
//SaveToImageDefaultOptions.Run();
67+
//SaveToGrayscaleImage.Run();
68+
//SaveToBinaryImageUsingFixedThreshold.Run();
69+
//SaveToBinaryImageUsingOtsuMethod.Run();
70+
//SaveToBmpImageUsingImageSaveOptions.Run();
71+
//SaveToJpegImageUsingSaveFormat.Run();
6572
//SaveToStream.Run();
6673
//SaveWithDefaultSettings.Run();
6774
//SpecifySaveOptions.Run();

Examples/CSharp/Text/HighlightAllRecentChanges.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ public static void Run()
3131
// Get RichText nodes modified last week.
3232
var richTextNodes = document.GetChildNodes<RichText>().Where(e => e.LastModifiedTime >= DateTime.Today.Subtract(TimeSpan.FromDays(7)));
3333

34-
//foreach (var node in richTextNodes)
35-
//{
36-
// // Set highlight color
37-
// node.ParagraphStyle.Highlight = Color.DarkGreen;
38-
// foreach (TextStyle style in node.Styles)
39-
// {
40-
// // Set highlight color
41-
// style.Highlight = Color.DarkSeaGreen;
42-
// }
43-
//}
34+
foreach (var node in richTextNodes)
35+
{
36+
// Set highlight color
37+
node.ParagraphStyle.Highlight = Color.DarkGreen;
38+
foreach (TextStyle style in node.Styles)
39+
{
40+
// Set highlight color
41+
style.Highlight = Color.DarkSeaGreen;
42+
}
43+
}
4444

4545
document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));
4646

Examples/CSharp/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Aspose.Note" version="20.9.0" targetFramework="net40" />
3+
<package id="Aspose.Note" version="20.11.0" targetFramework="net40" />
44
</packages>

0 commit comments

Comments
 (0)