Skip to content

Commit 533ec2c

Browse files
author
Alexei Soloview
committed
Samples to save Document as image in different formats
1 parent 5023f6d commit 533ec2c

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

Examples/CSharp/CSharp.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
<Compile Include="Attachments\RetrieveAttachedFiles.cs" />
5858
<Compile Include="Loading-and-Saving\SaveToBinaryImageUsingFixedThreshold.cs" />
5959
<Compile Include="Loading-and-Saving\SaveToBinaryImageUsingOtsuMethod.cs" />
60+
<Compile Include="Loading-and-Saving\SaveToBmpImageUsingImageSaveOptions.cs" />
6061
<Compile Include="Loading-and-Saving\SaveToGrayscaleImage.cs" />
62+
<Compile Include="Loading-and-Saving\SaveToJpegImageUsingSaveFormat.cs" />
6163
<Compile Include="Text\HighlightAllRecentChanges.cs" />
6264
<Compile Include="Images\BuildDocAndInsertImageUsingImageStream.cs" />
6365
<Compile Include="Images\BuildDocAndInsertImage.cs" />
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.Saving.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExSummary:Shows how to save a document as image in Bmp format using ImageSaveOptions.
22+
23+
// The path to the documents directory.
24+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
25+
26+
// Load the document into Aspose.Note.
27+
Document oneFile = new Document(dataDir + "Aspose.one");
28+
29+
dataDir = dataDir + "SaveToBmpImageUsingImageSaveOptions_out.bmp";
30+
31+
// Save the document.
32+
oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Bmp));
33+
34+
// ExEnd:SaveToBmpImageUsingImageSaveOptions
35+
36+
Console.WriteLine("\nOneNote document converted successfully to image in Bmp format.\nFile saved at " + dataDir);
37+
}
38+
}
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.Saving.SaveOptions)
19+
// ExFor:SaveFormat
20+
// ExFor:ImageSaveOptions
21+
// ExSummary:Shows how to save a document as image in Jpeg format using SaveFormat.
22+
23+
// The path to the documents directory.
24+
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
25+
26+
// Load the document into Aspose.Note.
27+
Document oneFile = new Document(dataDir + "Aspose.one");
28+
29+
dataDir = dataDir + "SaveToJpegImageUsingSaveFormat_out.jpg";
30+
31+
// Save the document.
32+
oneFile.Save(dataDir, SaveFormat.Jpeg);
33+
34+
// ExEnd:SaveToJpegImageUsingSaveFormat
35+
36+
Console.WriteLine("\nOneNote document converted successfully to image in Jpeg format.\nFile saved at " + dataDir);
37+
}
38+
}
39+
}

Examples/CSharp/RunExamples.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public static void Main()
6767
//SaveToGrayscaleImage.Run();
6868
//SaveToBinaryImageUsingFixedThreshold.Run();
6969
//SaveToBinaryImageUsingOtsuMethod.Run();
70+
//SaveToBmpImageUsingImageSaveOptions.Run();
71+
//SaveToJpegImageUsingSaveFormat.Run();
7072
//SaveToStream.Run();
7173
//SaveWithDefaultSettings.Run();
7274
//SpecifySaveOptions.Run();

0 commit comments

Comments
 (0)