diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln new file mode 100644 index 000000000..ba76ae46b --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client-Application", "Client-Application\Client-Application.csproj", "{BADAD8BB-DD47-4F82-8E74-302D7CD76E61}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BADAD8BB-DD47-4F82-8E74-302D7CD76E61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BADAD8BB-DD47-4F82-8E74-302D7CD76E61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BADAD8BB-DD47-4F82-8E74-302D7CD76E61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BADAD8BB-DD47-4F82-8E74-302D7CD76E61}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {11406F87-9ABB-4E04-86C0-5DD6338AC9F0} + EndGlobalSection +EndGlobal diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj new file mode 100644 index 000000000..0f4b2629c --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj @@ -0,0 +1,15 @@ + + + + Exe + net8.0 + Client_Application + enable + enable + + + + + + + diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs new file mode 100644 index 000000000..e5ff988e3 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs @@ -0,0 +1,34 @@ +class Program +{ + static async Task Main(string[] args) + { + // Create an HttpClient instance + using (HttpClient client = new HttpClient()) + { + try + { + // Send a GET request to a URL + HttpResponseMessage response = await client.GetAsync("https://localhost:7125/api/Values/api/Word"); + + // Check if the response is successful + if (response.IsSuccessStatusCode) + { + // Read the content as a string + Stream responseBody = await response.Content.ReadAsStreamAsync(); + FileStream fileStream = File.Create("../../../Output/Output.docx"); + responseBody.CopyTo(fileStream); + fileStream.Close(); + } + else + { + Console.WriteLine("HTTP error status code: " + response.StatusCode); + } + } + catch (HttpRequestException e) + { + Console.WriteLine("Request exception: " + e.Message); + } + } + } + +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document.sln b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document.sln new file mode 100644 index 000000000..7bf2093fa --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Open_and_save_Word_document", "Open_and_save_Word_document\Open_and_save_Word_document.csproj", "{F85A0851-CA1C-418D-BF88-97A9B31CED41}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F85A0851-CA1C-418D-BF88-97A9B31CED41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F85A0851-CA1C-418D-BF88-97A9B31CED41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F85A0851-CA1C-418D-BF88-97A9B31CED41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F85A0851-CA1C-418D-BF88-97A9B31CED41}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {11B82ED7-A31F-495F-B18A-4BC1E92A7574} + EndGlobalSection +EndGlobal diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/ValuesController.cs b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/ValuesController.cs new file mode 100644 index 000000000..712604080 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/ValuesController.cs @@ -0,0 +1,53 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using System.Reflection.Metadata; + +namespace Open_and_save_Word_document.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + [HttpGet] + [Route("api/Word")] + public IActionResult DownloadWordDocument() + { + try + { + var fileDownloadName = "Output.docx"; + const string contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + var stream = OpenandSaveDocument(); + stream.Position = 0; + return File(stream, contentType, fileDownloadName); + } + catch (Exception ex) + { + // Log or handle the exception + return BadRequest("Error occurred while creating Word file: " + ex.Message); + } + } + public static MemoryStream OpenandSaveDocument() + { + //Open an existing Word document. + WordDocument document = new WordDocument(Path.GetFullPath("Data/Input.docx")); + //Access the section in a Word document. + IWSection section = document.Sections[0]; + //Add a new paragraph to the section. + IWParagraph paragraph = section.AddParagraph(); + paragraph.ParagraphFormat.FirstLineIndent = 36; + paragraph.BreakCharacterFormat.FontSize = 12f; + IWTextRange text = paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works 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."); + text.CharacterFormat.FontSize = 12f; + + //Saving the Word document to the MemoryStream + MemoryStream stream = new MemoryStream(); + document.Save(stream, FormatType.Docx); + document.Close(); + //Set the position as '0'. + stream.Position = 0; + return stream; + } + } +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/WeatherForecastController.cs b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..d9e665245 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Open_and_save_Word_document.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 = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Data/Input.docx b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Data/Input.docx new file mode 100644 index 000000000..efb84ef4a Binary files /dev/null and b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Data/Input.docx differ diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.csproj b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.csproj new file mode 100644 index 000000000..ed78e364d --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.http b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.http new file mode 100644 index 000000000..e595034a7 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Open_and_save_Word_document.http @@ -0,0 +1,6 @@ +@Open_and_save_Word_document_HostAddress = http://localhost:5239 + +GET {{Open_and_save_Word_document_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Program.cs b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Program.cs new file mode 100644 index 000000000..48863a6d6 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Properties/launchSettings.json b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Properties/launchSettings.json new file mode 100644 index 000000000..4c80c577e --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:35888", + "sslPort": 44305 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5239", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7125;http://localhost:5239", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/WeatherForecast.cs b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/WeatherForecast.cs new file mode 100644 index 000000000..d5f49d275 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace Open_and_save_Word_document +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.Development.json b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.json b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.json new file mode 100644 index 000000000..10f68b8c8 --- /dev/null +++ b/Read-and-Save-document/Open-and-save-Word-document/ASP.NET-Core-Web-API/Open_and_save_Word_document/Open_and_save_Word_document/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln new file mode 100644 index 000000000..234ec99fe --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client-Application", "Client-Application\Client-Application.csproj", "{ECB9DA0B-5045-48CD-BD48-59D43107A210}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECB9DA0B-5045-48CD-BD48-59D43107A210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECB9DA0B-5045-48CD-BD48-59D43107A210}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECB9DA0B-5045-48CD-BD48-59D43107A210}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECB9DA0B-5045-48CD-BD48-59D43107A210}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {95D2CDFC-5BF6-42E8-9C97-53AF84B04938} + EndGlobalSection +EndGlobal diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj new file mode 100644 index 000000000..3d08de889 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Client_Application + enable + enable + + + diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs new file mode 100644 index 000000000..136491812 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs @@ -0,0 +1,33 @@ +class Program +{ + static async Task Main(string[] args) + { + // Create an HttpClient instance + using (HttpClient client = new HttpClient()) + { + try + { + // Send a GET request to a URL + HttpResponseMessage response = await client.GetAsync("https://localhost:7112/api/Values/api/ConvertWordToImage"); + + // Check if the response is successful + if (response.IsSuccessStatusCode) + { + // Read the content as a string + Stream responseBody = await response.Content.ReadAsStreamAsync(); + FileStream fileStream = File.Create("../../../Output/Output.jpeg"); + responseBody.CopyTo(fileStream); + fileStream.Close(); + } + else + { + Console.WriteLine("HTTP error status code: " + response.StatusCode); + } + } + catch (HttpRequestException e) + { + Console.WriteLine("Request exception: " + e.Message); + } + } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.sln b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.sln new file mode 100644 index 000000000..7ef074c07 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Word-Document-to-Image", "Convert-Word-Document-to-Image\Convert-Word-Document-to-Image.csproj", "{9AF519F5-E49C-41C4-8897-19C28E9FD735}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9AF519F5-E49C-41C4-8897-19C28E9FD735}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9AF519F5-E49C-41C4-8897-19C28E9FD735}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9AF519F5-E49C-41C4-8897-19C28E9FD735}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9AF519F5-E49C-41C4-8897-19C28E9FD735}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4893225B-0DC6-41EB-B2B1-A22EBC1E0BE2} + EndGlobalSection +EndGlobal diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/ValuesController.cs b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/ValuesController.cs new file mode 100644 index 000000000..82d54236c --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/ValuesController.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; + +namespace Convert_Word_Document_to_Image.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + [HttpGet] + [Route("api/ConvertWordToImage")] + public IActionResult ConvertWordToImage() + { + try + { + var fileDownloadName = "Output.jpeg"; + const string contentType = "image/jpeg"; + var stream = ConvertWordDocumentToImage(); + stream.Position = 0; + return File(stream, contentType, fileDownloadName); + } + catch (Exception ex) + { + return BadRequest("Error occurred while converting Word to Image: " + ex.Message); + } + } + public static Stream ConvertWordDocumentToImage() + { + //Loads the input Word document + WordDocument wordDocument = new WordDocument(Path.GetFullPath("Data/Input.docx"), FormatType.Docx); + DocIORenderer render = new DocIORenderer(); + //Convert the first page of the Word document into an image. + Stream imageStream = wordDocument.RenderAsImages(0, ExportImageFormat.Jpeg); + //close the word document. + wordDocument.Close(); + //Reset the stream position. + imageStream.Position = 0; + //Save the image file. + return imageStream; + } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/WeatherForecastController.cs b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..66454c3aa --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Convert_Word_Document_to_Image.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 = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.csproj b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.csproj new file mode 100644 index 000000000..0a9c3a01c --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + Convert_Word_Document_to_Image + + + + + + + + diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.http b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.http new file mode 100644 index 000000000..3c4556650 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image.http @@ -0,0 +1,6 @@ +@Convert_Word_Document_to_Image_HostAddress = http://localhost:5217 + +GET {{Convert_Word_Document_to_Image_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Data/Input.docx b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Data/Input.docx new file mode 100644 index 000000000..7062d6daa Binary files /dev/null and b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Data/Input.docx differ diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Program.cs b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Program.cs new file mode 100644 index 000000000..48863a6d6 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Properties/launchSettings.json b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Properties/launchSettings.json new file mode 100644 index 000000000..a8c34eda9 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:17004", + "sslPort": 44362 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5217", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7112;http://localhost:5217", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/WeatherForecast.cs b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/WeatherForecast.cs new file mode 100644 index 000000000..90175f909 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace Convert_Word_Document_to_Image +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.Development.json b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.json b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.json new file mode 100644 index 000000000..10f68b8c8 --- /dev/null +++ b/Word-to-Image-conversion/Convert-Word-to-image/ASP.NET-Core-Web-API/Convert-Word-Document-to-Image/Convert-Word-Document-to-Image/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln new file mode 100644 index 000000000..dd0b38e97 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client-Application", "Client-Application\Client-Application.csproj", "{24433651-BB7C-44F5-B681-9470139C9B8F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {24433651-BB7C-44F5-B681-9470139C9B8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24433651-BB7C-44F5-B681-9470139C9B8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24433651-BB7C-44F5-B681-9470139C9B8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24433651-BB7C-44F5-B681-9470139C9B8F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F7A92FBC-6A35-4EFA-BC94-5CFA4E20B55A} + EndGlobalSection +EndGlobal diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj new file mode 100644 index 000000000..3d08de889 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Client-Application.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Client_Application + enable + enable + + + diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs new file mode 100644 index 000000000..7b01cce01 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Client-Application/Client-Application/Program.cs @@ -0,0 +1,33 @@ +class Program +{ + static async Task Main(string[] args) + { + // Create an HttpClient instance + using (HttpClient client = new HttpClient()) + { + try + { + // Send a GET request to a URL + HttpResponseMessage response = await client.GetAsync("https://localhost:7240/api/Values/api/ConvertWordToPdf"); + + // Check if the response is successful + if (response.IsSuccessStatusCode) + { + // Read the content as a string + Stream responseBody = await response.Content.ReadAsStreamAsync(); + FileStream fileStream = File.Create("../../../Output/Output.pdf"); + responseBody.CopyTo(fileStream); + fileStream.Close(); + } + else + { + Console.WriteLine("HTTP error status code: " + response.StatusCode); + } + } + catch (HttpRequestException e) + { + Console.WriteLine("Request exception: " + e.Message); + } + } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.sln b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.sln new file mode 100644 index 000000000..be1521f58 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36518.9 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Word-Document-to-PDF", "Convert-Word-Document-to-PDF\Convert-Word-Document-to-PDF.csproj", "{F7EF181A-0400-45DE-8180-73D24F29EF7C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7EF181A-0400-45DE-8180-73D24F29EF7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7EF181A-0400-45DE-8180-73D24F29EF7C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7EF181A-0400-45DE-8180-73D24F29EF7C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7EF181A-0400-45DE-8180-73D24F29EF7C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1546EB77-7CED-45D1-B862-3A735EB98926} + EndGlobalSection +EndGlobal diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/ValuesController.cs b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/ValuesController.cs new file mode 100644 index 000000000..eb084ef39 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/ValuesController.cs @@ -0,0 +1,49 @@ +using Microsoft.AspNetCore.Mvc; +using Syncfusion.DocIO.DLS; +using Syncfusion.DocIORenderer; +using Syncfusion.Pdf; + +namespace Convert_Word_Document_to_PDF.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + [HttpGet] + [Route("api/ConvertWordToPdf")] + public IActionResult ConvertWordToPdf() + { + try + { + var fileDownloadName = "Output.pdf"; + const string contentType = "application/pdf"; + var stream = ConvertWordDocumentToPdf(); + stream.Position = 0; + return File(stream, contentType, fileDownloadName); + } + catch (Exception ex) + { + return BadRequest("Error occurred while converting Word to PDF: " + ex.Message); + } + } + + public static MemoryStream ConvertWordDocumentToPdf() + { + //Open the existing PowerPoint presentation with loaded stream. + using (WordDocument wordDocument = new WordDocument(Path.GetFullPath("Data/Template.docx"))) + { + using (DocIORenderer render = new DocIORenderer()) + { + PdfDocument pdfDocument = render.ConvertToPDF(wordDocument); + //Create the MemoryStream to save the converted PDF. + MemoryStream pdfStream = new MemoryStream(); + //Save the converted PDF document to MemoryStream. + pdfDocument.Save(pdfStream); + pdfStream.Position = 0; + //Download PDF document in the browser. + return pdfStream; + } + } + } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/WeatherForecastController.cs b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..2133671a9 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Convert_Word_Document_to_PDF.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 = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.csproj b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.csproj new file mode 100644 index 000000000..736f0b731 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.csproj @@ -0,0 +1,15 @@ + + + + net8.0 + enable + enable + Convert_Word_Document_to_PDF + + + + + + + + diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.http b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.http new file mode 100644 index 000000000..27676ca2b --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF.http @@ -0,0 +1,6 @@ +@Convert_Word_Document_to_PDF_HostAddress = http://localhost:5122 + +GET {{Convert_Word_Document_to_PDF_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Data/Template.docx b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Data/Template.docx new file mode 100644 index 000000000..7f3a39739 Binary files /dev/null and b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Data/Template.docx differ diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Program.cs b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Program.cs new file mode 100644 index 000000000..48863a6d6 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Program.cs @@ -0,0 +1,25 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Properties/launchSettings.json b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Properties/launchSettings.json new file mode 100644 index 000000000..f32c5b324 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:26365", + "sslPort": 44367 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5122", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7240;http://localhost:5122", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/WeatherForecast.cs b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/WeatherForecast.cs new file mode 100644 index 000000000..22f8dbb69 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace Convert_Word_Document_to_PDF +{ + public class WeatherForecast + { + public DateOnly Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.Development.json b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.json b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.json new file mode 100644 index 000000000..10f68b8c8 --- /dev/null +++ b/Word-to-PDF-Conversion/Convert-Word-document-to-PDF/ASP.NET-Core-Web-API/Convert-Word-Document-to-PDF/Convert-Word-Document-to-PDF/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}