-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from Venkateshmuruganandam/main
Add Sample for Convert Word to PDF in Linux
- Loading branch information
Showing
48 changed files
with
877 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...-Word-to-image/Linux/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>Convert_Word_Document_to_Image</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.2" /> | ||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.2" /> | ||
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+136 KB
...age-conversion/Convert-Word-to-image/Linux/Convert-Word-Document-to-Image/Data/Input.docx
Binary file not shown.
38 changes: 38 additions & 0 deletions
38
...to-Image-conversion/Convert-Word-to-image/Linux/Convert-Word-Document-to-Image/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using Syncfusion.DocIO; | ||
using Syncfusion.DocIO.DLS; | ||
using System.IO; | ||
using static System.Collections.Specialized.BitVector32; | ||
using Syncfusion.DocIORenderer; | ||
|
||
|
||
namespace Convert_Word_Document_to_Image | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Open the file as Stream | ||
using (FileStream docStream = new FileStream("Data/Input.docx", FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Loads an existing Word document | ||
using (WordDocument wordDocument = new WordDocument(docStream, FormatType.Docx)) | ||
{ | ||
//Instantiation of DocIORenderer for Word to image conversion | ||
using (DocIORenderer render = new DocIORenderer()) | ||
{ | ||
//Convert the first page of the Word document into an image. | ||
Stream imageStream = wordDocument.RenderAsImages(0, ExportImageFormat.Jpeg); | ||
//Reset the stream position. | ||
imageStream.Position = 0; | ||
//Create FileStream to save the image file. | ||
using (FileStream fileStreamOutput = new FileStream("WordToImage.Jpeg", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) | ||
{ | ||
imageStream.CopyTo(fileStreamOutput); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...Conversion/Convert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
Binary file added
BIN
+3.94 MB
...onversion/Convert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/Adventure.docx
Binary file not shown.
22 changes: 22 additions & 0 deletions
22
...DF-Conversion/Convert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:3.1-alpine3.12 AS base | ||
RUN apk update && apk upgrade && apk add fontconfig | ||
RUN apk add --update ttf-dejavu fontconfig | ||
WORKDIR /app | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:3.1-alpine3.12 AS build | ||
WORKDIR /src | ||
COPY ["WordToPDFDockerSample.csproj", "."] | ||
RUN dotnet restore "./WordToPDFDockerSample.csproj" | ||
COPY . . | ||
WORKDIR "/src/." | ||
RUN dotnet build "WordToPDFDockerSample.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "WordToPDFDockerSample.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "WordToPDFDockerSample.dll"] |
34 changes: 34 additions & 0 deletions
34
...DF-Conversion/Convert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.IO; | ||
using Syncfusion.DocIO; | ||
using Syncfusion.DocIO.DLS; | ||
using Syncfusion.DocIORenderer; | ||
using Syncfusion.Pdf; | ||
|
||
namespace WordToPDFDockerSample | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Open the file as Stream | ||
FileStream docStream = new FileStream(@"Adventure.docx", FileMode.Open, FileAccess.Read); | ||
//Loads file stream into Word document | ||
WordDocument wordDocument = new WordDocument(docStream, Syncfusion.DocIO.FormatType.Automatic); | ||
docStream.Dispose(); | ||
//Instantiation of DocIORenderer for Word to PDF conversion | ||
DocIORenderer render = new DocIORenderer(); | ||
//Converts Word document into PDF document | ||
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument); | ||
//Releases all resources used by the Word document and DocIO Renderer objects | ||
render.Dispose(); | ||
wordDocument.Dispose(); | ||
//Saves the PDF file | ||
FileStream outputStream = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); | ||
pdfDocument.Save(outputStream); | ||
//Closes the instance of PDF document object | ||
pdfDocument.Close(); | ||
outputStream.Dispose(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...t-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"WordToPDFDockerSample": { | ||
"commandName": "Project" | ||
}, | ||
"Docker": { | ||
"commandName": "Docker" | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/WordToPDFDockerSample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<DockerfileContext>.</DockerfileContext> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.14" /> | ||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" /> | ||
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="19.2.0.55" /> | ||
</ItemGroup> | ||
|
||
</Project> |
25 changes: 25 additions & 0 deletions
25
...onvert-Word-document-to-PDF/Docker/Alpine/WordToPDFDockerSample/WordToPDFDockerSample.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31424.327 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordToPDFDockerSample", "WordToPDFDockerSample.csproj", "{E233EA39-3496-4CDB-A8B1-90779722AE70}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {257DD3A5-A234-4E31-92C3-E010FEDB8CC5} | ||
EndGlobalSection | ||
EndGlobal |
25 changes: 25 additions & 0 deletions
25
...Conversion/Convert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
Binary file added
BIN
+3.94 MB
...onversion/Convert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/Adventure.docx
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
...DF-Conversion/Convert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM centos:8 | ||
|
||
Run dnf install dotnet-sdk-3.1 -y | ||
RUN dnf install dotnet-runtime-3.1 -y | ||
|
||
RUN dnf install fontconfig -y | ||
|
||
ENTRYPOINT ["dotnet" "WordToPDFDockerSample.dll"] |
34 changes: 34 additions & 0 deletions
34
...DF-Conversion/Convert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.IO; | ||
using Syncfusion.DocIO; | ||
using Syncfusion.DocIO.DLS; | ||
using Syncfusion.DocIORenderer; | ||
using Syncfusion.Pdf; | ||
|
||
namespace WordToPDFDockerSample | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
//Open the file as Stream | ||
FileStream docStream = new FileStream(@"Adventure.docx", FileMode.Open, FileAccess.Read); | ||
//Loads file stream into Word document | ||
WordDocument wordDocument = new WordDocument(docStream, Syncfusion.DocIO.FormatType.Automatic); | ||
docStream.Dispose(); | ||
//Instantiation of DocIORenderer for Word to PDF conversion | ||
DocIORenderer render = new DocIORenderer(); | ||
//Converts Word document into PDF document | ||
PdfDocument pdfDocument = render.ConvertToPDF(wordDocument); | ||
//Releases all resources used by the Word document and DocIO Renderer objects | ||
render.Dispose(); | ||
wordDocument.Dispose(); | ||
//Saves the PDF file | ||
FileStream outputStream = new FileStream("Output.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite); | ||
pdfDocument.Save(outputStream); | ||
//Closes the instance of PDF document object | ||
pdfDocument.Close(); | ||
outputStream.Dispose(); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...t-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"profiles": { | ||
"WordToPDFDockerSample": { | ||
"commandName": "Project" | ||
}, | ||
"Docker": { | ||
"commandName": "Docker" | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/WordToPDFDockerSample.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> | ||
<DockerfileContext>.</DockerfileContext> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.14" /> | ||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2" /> | ||
<PackageReference Include="Syncfusion.DocIORenderer.Net.Core" Version="19.2.0.55" /> | ||
</ItemGroup> | ||
|
||
</Project> |
25 changes: 25 additions & 0 deletions
25
...onvert-Word-document-to-PDF/Docker/CentOS/WordToPDFDockerSample/WordToPDFDockerSample.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31424.327 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WordToPDFDockerSample", "WordToPDFDockerSample.csproj", "{E233EA39-3496-4CDB-A8B1-90779722AE70}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E233EA39-3496-4CDB-A8B1-90779722AE70}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {257DD3A5-A234-4E31-92C3-E010FEDB8CC5} | ||
EndGlobalSection | ||
EndGlobal |
25 changes: 25 additions & 0 deletions
25
...Conversion/Convert-Word-document-to-PDF/Docker/Debian/WordToPDFDockerSample/.dockerignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md |
Binary file added
BIN
+3.94 MB
...onversion/Convert-Word-document-to-PDF/Docker/Debian/WordToPDFDockerSample/Adventure.docx
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
...DF-Conversion/Convert-Word-document-to-PDF/Docker/Debian/WordToPDFDockerSample/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. | ||
|
||
FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim AS base | ||
RUN apt-get update -y && apt-get install fontconfig -y | ||
WORKDIR /app | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:3.1-buster-slim AS build | ||
WORKDIR /src | ||
COPY ["WordToPDFDockerSample.csproj", "."] | ||
RUN dotnet restore "./WordToPDFDockerSample.csproj" | ||
COPY . . | ||
WORKDIR "/src/." | ||
RUN dotnet build "WordToPDFDockerSample.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "WordToPDFDockerSample.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "WordToPDFDockerSample.dll"] |
Oops, something went wrong.