Skip to content

Commit 4f6eef4

Browse files
committed
Examples for GroupDocs.Conversion for .NET 20.1
1 parent 8605add commit 4f6eef4

File tree

13 files changed

+315
-4
lines changed

13 files changed

+315
-4
lines changed

Examples/GroupDocs.Conversion.Examples.CSharp.Core/GroupDocs.Conversion.Examples.CSharp.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="AWSSDK.S3" Version="3.3.109" />
17-
<PackageReference Include="GroupDocs.Conversion" Version="19.12.1" />
17+
<PackageReference Include="GroupDocs.Conversion" Version="20.1.0" />
1818
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
1919
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
2020
</ItemGroup>

Examples/GroupDocs.Conversion.Examples.CSharp.Core/RunExamples.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ static void Main()
2626

2727
#region Basic Usage
2828

29+
GetAllPossibleConversions.Run();
30+
GetPossibleConversionsForSpecifiedDocumentExtension.Run();
2931
GetPossibleConversions.Run();
3032
GetSourceDocumentInfo.Run();
3133

@@ -76,6 +78,7 @@ static void Main()
7678

7779
AddWatermark.Run();
7880
ConvertSpecificPages.Run();
81+
GetDefaultConvertOptionsForDesiredTargetFormat.Run();
7982

8083
#endregion
8184

@@ -115,6 +118,7 @@ static void Main()
115118

116119
ConvertEmailWithAlteringFieldsVisibility.Run();
117120
ConvertEmailWithTimezoneOffset.Run();
121+
ConvertEmailWithAttachments.Run();
118122

119123
#endregion
120124

Examples/GroupDocs.Conversion.Examples.CSharp.Framework/GroupDocs.Conversion.Examples.CSharp.Framework.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<Version>3.3.104.21</Version>
6565
</PackageReference>
6666
<PackageReference Include="GroupDocs.Conversion">
67-
<Version>19.12.1</Version>
67+
<Version>20.1.0</Version>
6868
</PackageReference>
6969
<PackageReference Include="StackExchange.Redis">
7070
<Version>2.0.601</Version>

Examples/GroupDocs.Conversion.Examples.CSharp.Framework/RunExamples.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ static void Main()
2626

2727
#region Basic Usage
2828

29+
GetAllPossibleConversions.Run();
30+
GetPossibleConversionsForSpecifiedDocumentExtension.Run();
2931
GetPossibleConversions.Run();
3032
GetSourceDocumentInfo.Run();
3133

@@ -76,6 +78,7 @@ static void Main()
7678

7779
AddWatermark.Run();
7880
ConvertSpecificPages.Run();
81+
GetDefaultConvertOptionsForDesiredTargetFormat.Run();
7982

8083
#endregion
8184

@@ -115,6 +118,7 @@ static void Main()
115118

116119
ConvertEmailWithAlteringFieldsVisibility.Run();
117120
ConvertEmailWithTimezoneOffset.Run();
121+
ConvertEmailWithAttachments.Run();
118122

119123
#endregion
120124

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.IO;
3+
4+
namespace GroupDocs.Conversion.Examples.CSharp.AdvancedUsage
5+
{
6+
/// <summary>
7+
/// This example demonstrates how to get default convert options for desired target format
8+
/// </summary>
9+
internal static class GetDefaultConvertOptionsForDesiredTargetFormat
10+
{
11+
public static void Run()
12+
{
13+
string outputFolder = Constants.GetOutputDirectoryPath();
14+
string outputFile = Path.Combine(outputFolder, "converted.pdf");
15+
16+
using (Converter converter = new Converter(Constants.SAMPLE_DOCX))
17+
{
18+
var possibleConversion = converter.GetPossibleConversions();
19+
var convertOptions = possibleConversion["pdf"].ConvertOptions;
20+
converter.Convert(outputFile, convertOptions);
21+
}
22+
23+
Console.WriteLine("\nDocument converted successfully. \nCheck output in {0}", outputFolder);
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.IO;
3+
using GroupDocs.Conversion.Options.Convert;
4+
using GroupDocs.Conversion.Options.Load;
5+
6+
namespace GroupDocs.Conversion.Examples.CSharp.AdvancedUsage
7+
{
8+
/// <summary>
9+
/// This example demonstrates how to convert an email document along with all attachments
10+
/// </summary>
11+
internal static class ConvertEmailWithAttachments
12+
{
13+
public static void Run()
14+
{
15+
string outputFolder = Constants.GetOutputDirectoryPath();
16+
#if NETCOREAPP
17+
Func<LoadOptions> getLoadOptions = () => new EmailLoadOptions
18+
{
19+
ConvertAttachments = true
20+
};
21+
#else
22+
Contracts.Func<LoadOptions> getLoadOptions = () => new EmailLoadOptions
23+
{
24+
ConvertAttachments = true
25+
};
26+
#endif
27+
using (Converter converter = new Converter(Constants.SAMPLE_EML_WITH_ATTACHMENT, getLoadOptions))
28+
{
29+
int index = 1;
30+
PdfConvertOptions options = new PdfConvertOptions();
31+
converter.Convert(() =>
32+
{
33+
string fileName = index == 1 ? "converted.pdf" : $"converted-attachment-{index - 1}.pdf";
34+
index++;
35+
string outputFile = Path.Combine(outputFolder, fileName);
36+
return new FileStream(outputFile, FileMode.Create);
37+
}, options);
38+
}
39+
40+
Console.WriteLine("\nEmail document converted successfully. \nCheck output in {0}", outputFolder);
41+
}
42+
}
43+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace GroupDocs.Conversion.Examples.CSharp.BasicUsage
4+
{
5+
/// <summary>
6+
/// This example demonstrates how to get all possible conversions
7+
/// </summary>
8+
internal static class GetAllPossibleConversions
9+
{
10+
public static void Run()
11+
{
12+
var possibleConversions = Converter.GetAllPossibleConversions();
13+
foreach(var conversions in possibleConversions)
14+
{
15+
Console.WriteLine("{0} could be converted to:", conversions.Source.Extension);
16+
17+
foreach (var conversion in conversions.All)
18+
{
19+
Console.WriteLine("\t {0} as {1} conversion.", conversion.Format, conversion.IsPrimary?"primary": "secondary");
20+
}
21+
22+
}
23+
24+
Console.WriteLine("\nPossible conversions retrieved successfully.");
25+
}
26+
}
27+
}

Examples/GroupDocs.Conversion.Examples.CSharp/BasicUsage/GetPossibleConversions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static void Run()
1818

1919
foreach (var conversion in conversions.All)
2020
{
21-
Console.WriteLine("\t {0} as {1} conversion.", conversion.Key, conversion.Value?"primary": "secondary");
21+
Console.WriteLine("\t {0} as {1} conversion.", conversion.Format, conversion.IsPrimary?"primary": "secondary");
2222
}
2323

2424
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using GroupDocs.Conversion.Contracts;
3+
4+
namespace GroupDocs.Conversion.Examples.CSharp.BasicUsage
5+
{
6+
/// <summary>
7+
/// This example demonstrates how to get to what formats an source document format could be converted
8+
/// </summary>
9+
internal static class GetPossibleConversionsForSpecifiedDocumentExtension
10+
{
11+
public static void Run()
12+
{
13+
PossibleConversions conversions = Converter.GetPossibleConversions("docx");
14+
15+
Console.WriteLine("{0} could be converted to:", conversions.Source.Extension);
16+
17+
foreach (var conversion in conversions.All)
18+
{
19+
Console.WriteLine("\t {0} as {1} conversion.", conversion.Format,
20+
conversion.IsPrimary ? "primary" : "secondary");
21+
}
22+
23+
24+
Console.WriteLine("\nPossible conversions retrieved successfully.");
25+
}
26+
}
27+
}

Examples/GroupDocs.Conversion.Examples.CSharp/BasicUsage/GetSourceDocumentInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void Run()
2424
Console.WriteLine("Width: {0}", pdfInfo.Width);
2525
Console.WriteLine("Height: {0}", pdfInfo.Height);
2626
Console.WriteLine("Is landscaped: {0}", pdfInfo.IsLandscape);
27-
Console.WriteLine("Is Encrypted: {0}", pdfInfo.IsEncrypted);
27+
Console.WriteLine("Is Password Protected: {0}", pdfInfo.IsPasswordProtected);
2828
}
2929

3030
Console.WriteLine("\nDocument info retrieved successfully.");

0 commit comments

Comments
 (0)