diff --git a/README.md b/README.md index 1526076..27b19a9 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ Also, you can run the Docker container along with the license key using this doc docker run -d -p 6001:80 –e SYNCFUSION_LICENSE_KEY=YOUR_LICENSE_KEY syncfusion/pdfviewer-server:latest ``` -For Ex: docker run -d -p 6001:80 –e SYNCFUSION_LICENSE_KEY=Mzg1ODMzQDMxMzgyZTM0MmUzMGdFRGJvUno1MUx4Tit4S09CeS9xRHZzZU4ySVBjQVFuT0VpdWpHUWJ6aXM9 syncfusion/pdfviewer-server:latest +For Ex: docker run -d -p 6001:80 –e + +pdfviewer-server:latest Now the PDF Viewer server Docker instance runs in the localhost with the provided port number http://localhost:6001. Open this link in the browser and navigate to the PDF Viewer Web API control http://localhost:6001/api/pdfviewer. It returns the default get method response. diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/.dockerignore b/Ubuntu-Focal/PdfViewerWebService_6.0/.dockerignore new file mode 100644 index 0000000..bdca33b --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/.dockerignore @@ -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 \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/PDFViewerController.cs b/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/PDFViewerController.cs new file mode 100644 index 0000000..ead1446 --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/PDFViewerController.cs @@ -0,0 +1,291 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; +using Newtonsoft.Json; +using Syncfusion.EJ2.PdfViewer; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; + +namespace PdfViewerWebService_6._0.Controllers +{ + [Route("[controller]")] + [ApiController] + public class PDFViewerController : ControllerBase + { + private IWebHostEnvironment _hostingEnvironment; +        //Initialize the memory cache object   +        public IMemoryCache _cache; + public PDFViewerController(IWebHostEnvironment hostingEnvironment, IMemoryCache cache) + { + _hostingEnvironment = hostingEnvironment; + _cache = cache; + Console.WriteLine("PdfViewerController initialized"); + } + + [HttpPost("Load")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/Load")] +        //Post action for Loading the PDF documents   +        public IActionResult Load([FromBody] Dictionary jsonObject) + { + Console.WriteLine("Load called"); + //Initialize the PDF viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + MemoryStream stream = new MemoryStream(); + object jsonResult = new object(); + if (jsonObject != null && jsonObject.ContainsKey("document")) + { + if (bool.Parse(jsonObject["isFileName"])) + { + string documentPath = GetDocumentPath(jsonObject["document"]); + if (!string.IsNullOrEmpty(documentPath)) + { + byte[] bytes = System.IO.File.ReadAllBytes(documentPath); + stream = new MemoryStream(bytes); + } + else + { + string fileName = jsonObject["document"].Split(new string[] { "://" }, StringSplitOptions.None)[0]; + + if (fileName == "http" || fileName == "https") + { + WebClient WebClient = new WebClient(); + byte[] pdfDoc = WebClient.DownloadData(jsonObject["document"]); + stream = new MemoryStream(pdfDoc); + } + + else + { + return this.Content(jsonObject["document"] + " is not found"); + } + } + } + else + { + byte[] bytes = Convert.FromBase64String(jsonObject["document"]); + stream = new MemoryStream(bytes); + } + } + jsonResult = pdfviewer.Load(stream, jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + + [AcceptVerbs("Post")] + [HttpPost("Bookmarks")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/Bookmarks")] +        //Post action for processing the bookmarks from the PDF documents +        public IActionResult Bookmarks([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + var jsonResult = pdfviewer.GetBookmarks(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + + [AcceptVerbs("Post")] + [HttpPost("RenderPdfPages")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/RenderPdfPages")] +        //Post action for processing the PDF documents  +        public IActionResult RenderPdfPages([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + object jsonResult = pdfviewer.GetPage(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + + [AcceptVerbs("Post")] + [HttpPost("RenderPdfTexts")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/RenderPdfTexts")] +        //Post action for processing the PDF texts  +        public IActionResult RenderPdfTexts([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + object jsonResult = pdfviewer.GetDocumentText(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + + [AcceptVerbs("Post")] + [HttpPost("RenderThumbnailImages")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/RenderThumbnailImages")] +        //Post action for rendering the ThumbnailImages +        public IActionResult RenderThumbnailImages([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + object result = pdfviewer.GetThumbnailImages(jsonObject); + return Content(JsonConvert.SerializeObject(result)); + } + [AcceptVerbs("Post")] + [HttpPost("RenderAnnotationComments")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/RenderAnnotationComments")] +        //Post action for rendering the annotations +        public IActionResult RenderAnnotationComments([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + object jsonResult = pdfviewer.GetAnnotationComments(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + [AcceptVerbs("Post")] + [HttpPost("ExportAnnotations")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/ExportAnnotations")] +        //Post action to export annotations +        public IActionResult ExportAnnotations([FromBody] Dictionary jsonObject) + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + string jsonResult = pdfviewer.ExportAnnotation(jsonObject); + return Content(jsonResult); + } + [AcceptVerbs("Post")] + [HttpPost("ImportAnnotations")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/ImportAnnotations")] +        //Post action to import annotations +        public IActionResult ImportAnnotations([FromBody] Dictionary jsonObject) + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + string jsonResult = string.Empty; + object JsonResult; + if (jsonObject != null && jsonObject.ContainsKey("fileName")) + { + string documentPath = GetDocumentPath(jsonObject["fileName"]); + if (!string.IsNullOrEmpty(documentPath)) + { + jsonResult = System.IO.File.ReadAllText(documentPath); + } + else + { + return this.Content(jsonObject["document"] + " is not found"); + } + } + else + { + string extension = Path.GetExtension(jsonObject["importedData"]); + if (extension != ".xfdf") + { + JsonResult = pdfviewer.ImportAnnotation(jsonObject); + return Content(JsonConvert.SerializeObject(JsonResult)); + } + else + { + string documentPath = GetDocumentPath(jsonObject["importedData"]); + if (!string.IsNullOrEmpty(documentPath)) + { + byte[] bytes = System.IO.File.ReadAllBytes(documentPath); + jsonObject["importedData"] = Convert.ToBase64String(bytes); + JsonResult = pdfviewer.ImportAnnotation(jsonObject); + return Content(JsonConvert.SerializeObject(JsonResult)); + } + else + { + return this.Content(jsonObject["document"] + " is not found"); + } + } + } + return Content(jsonResult); + } + + [AcceptVerbs("Post")] + [HttpPost("ExportFormFields")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/ExportFormFields")] + public IActionResult ExportFormFields([FromBody] Dictionary jsonObject) + + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + string jsonResult = pdfviewer.ExportFormFields(jsonObject); + return Content(jsonResult); + } + + [AcceptVerbs("Post")] + [HttpPost("ImportFormFields")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/ImportFormFields")] + public IActionResult ImportFormFields([FromBody] Dictionary jsonObject) + { + PdfRenderer pdfviewer = new PdfRenderer(_cache); + jsonObject["data"] = GetDocumentPath(jsonObject["data"]); + object jsonResult = pdfviewer.ImportFormFields(jsonObject); + return Content(JsonConvert.SerializeObject(jsonResult)); + } + + [AcceptVerbs("Post")] + [HttpPost("Unload")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/Unload")] +        //Post action for unloading and disposing the PDF document resources  +        public IActionResult Unload([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + pdfviewer.ClearCache(jsonObject); + return this.Content("Document cache is cleared"); + } + + + [HttpPost("Download")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/Download")] +        //Post action for downloading the PDF documents +        public IActionResult Download([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); + return Content(documentBase); + } + + [HttpPost("PrintImages")] + [Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")] + [Route("[controller]/PrintImages")] +        //Post action for printing the PDF documents +        public IActionResult PrintImages([FromBody] Dictionary jsonObject) + { + //Initialize the PDF Viewer object with memory cache object + PdfRenderer pdfviewer = new PdfRenderer(_cache); + object pageImage = pdfviewer.GetPrintImage(jsonObject); + return Content(JsonConvert.SerializeObject(pageImage)); + } + + //Gets the path of the PDF document + private string GetDocumentPath(string document) + { + string documentPath = string.Empty; + if (!System.IO.File.Exists(document)) + { + var path = _hostingEnvironment.ContentRootPath; + if (System.IO.File.Exists(path + "/Data/" + document)) + documentPath = path + "/Data/" + document; + } + else + { + documentPath = document; + } + Console.WriteLine(documentPath); + return documentPath; + } + // GET api/values + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/values/5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + } +} diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/WeatherForecastController.cs b/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..c507bc5 --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace PdfViewerWebService_6._0.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Data/PDF_Succinctly.pdf b/Ubuntu-Focal/PdfViewerWebService_6.0/Data/PDF_Succinctly.pdf new file mode 100644 index 0000000..19b4956 Binary files /dev/null and b/Ubuntu-Focal/PdfViewerWebService_6.0/Data/PDF_Succinctly.pdf differ diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Dockerfile b/Ubuntu-Focal/PdfViewerWebService_6.0/Dockerfile new file mode 100644 index 0000000..745d3ab --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/Dockerfile @@ -0,0 +1,28 @@ +#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:6.0 AS base +RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so + +# install System.Drawing native dependencies +RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev +RUN ln -s libgdiplus.so gdiplus.dll + +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /src +COPY ["PdfViewerWebService_6.0.csproj", "."] +RUN dotnet restore "./PdfViewerWebService_6.0.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "PdfViewerWebService_6.0.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "PdfViewerWebService_6.0.csproj" -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "PdfViewerWebService_6.0.dll"] \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj new file mode 100644 index 0000000..f03c2c1 --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + enable + enable + PdfViewerWebService_6._0 + 2d4560e3-d841-47f3-bba6-2635cd2552e3 + Linux + . + + + + + + + + + diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj.user b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj.user new file mode 100644 index 0000000..763f3ab --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.csproj.user @@ -0,0 +1,6 @@ + + + + Docker + + \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.sln b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.sln new file mode 100644 index 0000000..eea972e --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/PdfViewerWebService_6.0.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32328.378 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfViewerWebService_6.0", "PdfViewerWebService_6.0.csproj", "{31E1823C-F334-4259-BF90-FAFE3ACBB261}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {31E1823C-F334-4259-BF90-FAFE3ACBB261}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31E1823C-F334-4259-BF90-FAFE3ACBB261}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31E1823C-F334-4259-BF90-FAFE3ACBB261}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31E1823C-F334-4259-BF90-FAFE3ACBB261}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {458E8869-A861-463A-9CEB-FC901D84C005} + EndGlobalSection +EndGlobal diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Program.cs b/Ubuntu-Focal/PdfViewerWebService_6.0/Program.cs new file mode 100644 index 0000000..68e35bb --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/Program.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.ResponseCompression; +using Newtonsoft.Json.Serialization; + +var builder = WebApplication.CreateBuilder(args); +var MyAllowSpecificOrigins = "MyPolicy"; +builder.Services.AddControllers().AddNewtonsoftJson(options => +{ + // Use the default property (Pascal) casing + options.SerializerSettings.ContractResolver = new DefaultContractResolver(); +}); +builder.Services.AddCors(options => +{ + options.AddPolicy(name: MyAllowSpecificOrigins, + builder => { + builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + }); +}); + +builder.Services.AddMemoryCache(); +builder.Services.AddEndpointsApiExplorer(); + +builder.Services.Configure(options => options.Level = System.IO.Compression.CompressionLevel.Optimal); +builder.Services.AddResponseCompression(); + +var app = builder.Build(); + +//Register Syncfusion license +string licenseKey = string.Empty; +Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(licenseKey); + +app.UseHttpsRedirection(); +app.UseCors(MyAllowSpecificOrigins); +app.UseAuthorization(); + +app.UseResponseCompression(); +app.MapControllers(); + +app.Run(); \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/Properties/launchSettings.json b/Ubuntu-Focal/PdfViewerWebService_6.0/Properties/launchSettings.json new file mode 100644 index 0000000..ec667e5 --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "pdfviewer", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "PDFViewerWebService": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "pdfviewer", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/pdfviewer", + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:65530", + "sslPort": 44399 + } + } +} \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/WeatherForecast.cs b/Ubuntu-Focal/PdfViewerWebService_6.0/WeatherForecast.cs new file mode 100644 index 0000000..69a02aa --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PdfViewerWebService_6._0 +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.Development.json b/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.json b/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Ubuntu-Focal/PdfViewerWebService_6.0/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Dockerfile b/Ubuntu/Dockerfile similarity index 97% rename from Dockerfile rename to Ubuntu/Dockerfile index 6e6e72a..2870789 100644 --- a/Dockerfile +++ b/Ubuntu/Dockerfile @@ -1,28 +1,28 @@ -FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base - -RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so - -# install System.Drawing native dependencies -RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev -RUN ln -s libgdiplus.so gdiplus.dll - -WORKDIR /app -EXPOSE 80 -ENV SYNCFUSION_LICENSE_KEY="" -ENV DOCUMENT_SLIDING_EXPIRATION_TIME="10" -ENV REDIS_CACHE_CONNECTION_STRING="" -FROM microsoft/dotnet:2.1-sdk AS build -WORKDIR /source -COPY ["src/ej2-pdfviewer-server/ej2-pdfviewer-server.csproj", "./ej2-pdfviewer-server/ej2-pdfviewer-server.csproj"] -RUN dotnet restore "./ej2-pdfviewer-server/ej2-pdfviewer-server.csproj" -COPY . . -WORKDIR "/source/src" -RUN dotnet build -c Release -o /app - -FROM build AS publish -RUN dotnet publish -c Release -o /app - -FROM base AS final -WORKDIR /app -COPY --from=publish /app . +FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base + +RUN ln -s /lib/x86_64-linux-gnu/libdl-2.24.so /lib/x86_64-linux-gnu/libdl.so + +# install System.Drawing native dependencies +RUN apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev +RUN ln -s libgdiplus.so gdiplus.dll + +WORKDIR /app +EXPOSE 80 +ENV SYNCFUSION_LICENSE_KEY="" +ENV DOCUMENT_SLIDING_EXPIRATION_TIME="10" +ENV REDIS_CACHE_CONNECTION_STRING="" +FROM microsoft/dotnet:2.1-sdk AS build +WORKDIR /source +COPY ["src/ej2-pdfviewer-server/ej2-pdfviewer-server.csproj", "./ej2-pdfviewer-server/ej2-pdfviewer-server.csproj"] +RUN dotnet restore "./ej2-pdfviewer-server/ej2-pdfviewer-server.csproj" +COPY . . +WORKDIR "/source/src" +RUN dotnet build -c Release -o /app + +FROM build AS publish +RUN dotnet publish -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . ENTRYPOINT ["dotnet", "ej2-pdfviewer-server.dll"] \ No newline at end of file