Skip to content

Commit f8775f1

Browse files
Merge pull request #457 from SyncfusionExamples/ES-898646-Python-Wrapper
ES-898646- Add the sample in getting started for Python-Wrapper
2 parents ffefa47 + 54b0051 commit f8775f1

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-document", "Create-document\Create-document.csproj", "{464C25F2-0A0B-4744-AFBB-C342D2808797}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{464C25F2-0A0B-4744-AFBB-C342D2808797}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{464C25F2-0A0B-4744-AFBB-C342D2808797}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{464C25F2-0A0B-4744-AFBB-C342D2808797}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{464C25F2-0A0B-4744-AFBB-C342D2808797}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>Create_document</RootNamespace>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="29.2.4" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
using System;
4+
using System.IO;
5+
using Syncfusion.Licensing;
6+
7+
namespace Create_document
8+
{
9+
public class CreateWordDocument
10+
{
11+
public string WordDocument(string outputPath)
12+
{
13+
try
14+
{
15+
// Create a new Word document.
16+
using (WordDocument document = new WordDocument())
17+
{
18+
// Add a section and a paragraph with sample text.
19+
IWSection section = document.AddSection();
20+
IWParagraph paragraph = section.AddParagraph();
21+
paragraph.AppendText("In 2000, AdventureWorks Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the AdventureWorks Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.");
22+
23+
// Save the document to the specified path.
24+
using (FileStream outputPathStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write))
25+
{
26+
document.Save(outputPathStream, FormatType.Docx);
27+
}
28+
}
29+
30+
return "Word document created successfully at: " + outputPath;
31+
}
32+
catch (Exception ex)
33+
{
34+
return "Error: " + ex.Message;
35+
}
36+
}
37+
38+
}
39+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import clr #import clr from pythonnet
2+
import os
3+
4+
#Get the DLL and input file path in string
5+
dll_path = r'D:\Create-document\Create-document\bin\Release\netstandard2.0\Create-document.dll' #Dll of application
6+
docio_dll = r'C:\Users\Admin\.nuget\packages\syncfusion.docio.net.core\version\lib\netstandard2.0\Syncfusion.DocIO.Portable.dll'
7+
officeChart_dll = r'C:\Users\Admin\.nuget\packages\syncfusion.officechart.net.core\version\lib\netstandard2.0\Syncfusion.OfficeChart.Portable.dll'
8+
compression_dll =r'C:\Users\Admin\.nuget\packages\syncfusion.compression.net.core\version\lib\netstandard2.0\Syncfusion.Compression.Portable.dll'
9+
license_dll = r'C:\Users\Admin\.nuget\packages\syncfusion.licensing\version\lib\netstandard2.0\Syncfusion.Licensing.dll'
10+
11+
# Verify and add paths
12+
for path in [dll_path, docio_dll, officeChart_dll, compression_dll, license_dll]:
13+
if path not in os.sys.path:
14+
os.sys.path.append(path)
15+
16+
#load our dll file
17+
try:
18+
clr.AddReference(dll_path)
19+
clr.AddReference(docio_dll)
20+
clr.AddReference(officeChart_dll)
21+
clr.AddReference(compression_dll)
22+
clr.AddReference(license_dll)
23+
print ("Load success")
24+
except Exception as e:
25+
print("Fail to load")
26+
27+
#import our DocIO class from Our C# namespace DocIOLibrary
28+
from Create_document import CreateWordDocument
29+
30+
document = CreateWordDocument() #create our DocIO object
31+
32+
# Define file path
33+
output_doc = r"Create-Word-document.docx" #path of result document
34+
35+
# Call CompareDocuments method
36+
result = document.WordDocument(output_doc)
37+
38+
print("Document generated:", result)

0 commit comments

Comments
 (0)