Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Secret Value found!
name: Secret Value found!!
on:
push:
public:
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install the report tool packages
if: steps.gitleaks.outcome != 'success'
run: |
nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/"
dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1
dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "[email protected]" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE"
nuget install "Syncfusion.Email" -source ${{ secrets.NexusFeedLink }} -ExcludeVersion
dir $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1
dotnet $GITHUB_WORKSPACE/Syncfusion.Email/lib/netcoreapp3.1/GitleaksReportMail.dll ${{ secrets.CITEAMCREDENTIALS }} "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" ${{ secrets.ORGANIZATIONNAME }}
exit 1
25 changes: 25 additions & 0 deletions ASP.NET Core/EJ2APIServices_NET6.sln
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 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices_NET6.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {00388905-5E88-4BCF-B5FC-E4CAB5FA88EE}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EJ2APIServices", "src\EJ2APIServices_NET8.csproj", "{D2F1360E-DF8C-4AD2-A8CC-942A180D6762}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
96 changes: 81 additions & 15 deletions ASP.NET Core/src/Controllers/DocumentEditorController.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using System.Net.Http;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Syncfusion.EJ2.DocumentEditor;
using WDocument = Syncfusion.DocIO.DLS.WordDocument;
using WFormatType = Syncfusion.DocIO.FormatType;
using Syncfusion.EJ2.SpellChecker;
using EJ2APIServices;
using SkiaSharp;
using BitMiracle.LibTiff.Classic;

namespace SyncfusionDocument.Controllers
namespace EJ2APIServices.Controllers
{
[Route("api/[controller]")]
public class DocumentEditorController : Controller
{
private readonly IHostingEnvironment _hostingEnvironment;
string path;
private readonly IWebHostEnvironment _hostingEnvironment;
string? path;

public DocumentEditorController(IHostingEnvironment hostingEnvironment)
public DocumentEditorController(IWebHostEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
path = Startup.path;
Expand All @@ -35,7 +30,7 @@ public DocumentEditorController(IHostingEnvironment hostingEnvironment)
[Route("Import")]
public string Import(IFormCollection data)
{
if (data.Files.Count == 0)
if (data.Files.Count == 0)
return null;
Stream stream = new MemoryStream();
IFormFile file = data.Files[0];
Expand All @@ -59,11 +54,82 @@ public string Import(IFormCollection data)
//Converts Metafile to raster image.
private static void OnMetafileImageParsed(object sender, MetafileImageParsedEventArgs args)
{
if (args.IsMetafile)
{
//MetaFile image conversion(EMF and WMF)
//You can write your own method definition for converting metafile to raster image using any third-party image converter.
args.ImageStream = ConvertMetafileToRasterImage(args.MetafileStream);
}
else
{
//TIFF image conversion
args.ImageStream = TiffToPNG(args.MetafileStream);

}
}

private static Stream ConvertMetafileToRasterImage(Stream ImageStream)
// Converting Tiff to Png image using Bitmiracle https://www.nuget.org/packages/BitMiracle.LibTiff.NET
private static MemoryStream TiffToPNG(Stream tiffStream)
{
MemoryStream imageStream = new MemoryStream();
using (Tiff tif = Tiff.ClientOpen("in-memory", "r", tiffStream, new TiffStream()))
{
// Find the width and height of the image
FieldValue[] value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGEWIDTH);
int width = value[0].ToInt();

value = tif.GetField(BitMiracle.LibTiff.Classic.TiffTag.IMAGELENGTH);
int height = value[0].ToInt();

// Read the image into the memory buffer
int[] raster = new int[height * width];
if (!tif.ReadRGBAImage(width, height, raster))
{
throw new Exception("Could not read image");
}

// Create a bitmap image using SkiaSharp.
using (SKBitmap sKBitmap = new SKBitmap(width, height, SKImageInfo.PlatformColorType, SKAlphaType.Premul))
{
// Convert a RGBA value to byte array.
byte[] bitmapData = new byte[sKBitmap.RowBytes * sKBitmap.Height];
for (int y = 0; y < sKBitmap.Height; y++)
{
int rasterOffset = y * sKBitmap.Width;
int bitsOffset = (sKBitmap.Height - y - 1) * sKBitmap.RowBytes;

for (int x = 0; x < sKBitmap.Width; x++)
{
int rgba = raster[rasterOffset++];
bitmapData[bitsOffset++] = (byte)((rgba >> 16) & 0xff);
bitmapData[bitsOffset++] = (byte)((rgba >> 8) & 0xff);
bitmapData[bitsOffset++] = (byte)(rgba & 0xff);
bitmapData[bitsOffset++] = (byte)((rgba >> 24) & 0xff);
}
}

// Convert a byte array to SKColor array.
SKColor[] sKColor = new SKColor[bitmapData.Length / 4];
int index = 0;
for (int i = 0; i < bitmapData.Length; i++)
{
sKColor[index] = new SKColor(bitmapData[i + 2], bitmapData[i + 1], bitmapData[i], bitmapData[i + 3]);
i += 3;
index += 1;
}

// Set the SKColor array to SKBitmap.
sKBitmap.Pixels = sKColor;

// Save the SKBitmap to PNG image stream.
sKBitmap.Encode(SKEncodedImageFormat.Png, 100).SaveTo(imageStream);
imageStream.Flush();
}
}
return imageStream;
}

private static Stream ConvertMetafileToRasterImage(Stream ImageStream)
{
//Here we are loading a default raster image as fallback.
Stream imgStream = GetManifestResourceStream("ImageNotFound.jpg");
Expand Down Expand Up @@ -92,7 +158,7 @@ private static Stream GetManifestResourceStream(string fileName)
[Route("SpellCheck")]
public string SpellCheck([FromBody] SpellCheckJsonData spellChecker)
{
try
try
{
SpellChecker spellCheck = new SpellChecker();
spellCheck.GetSuggestions(spellChecker.LanguageID, spellChecker.TexttoCheck, spellChecker.CheckSpelling, spellChecker.CheckSuggestion, spellChecker.AddWord);
Expand Down
43 changes: 0 additions & 43 deletions ASP.NET Core/src/EJ2APIServices.csproj

This file was deleted.

27 changes: 27 additions & 0 deletions ASP.NET Core/src/EJ2APIServices_NET6.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="Syncfusion.Compression.Net.Core" Version="*" />
<PackageReference Include="Syncfusion.OfficeChart.Net.Core" Version="*" />
<PackageReference Include="Syncfusion.EJ2.WordEditor.AspNet.Core" Version="*" />
<PackageReference Include="Syncfusion.EJ2.SpellChecker.AspNet.Core" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="4.*" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9.2" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.*" />
<PackageReference Include="BitMiracle.LibTiff.NET" Version="2.4.649" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions ASP.NET Core/src/EJ2APIServices_NET8.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
<PackageReference Include="Npgsql" Version="4.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="Syncfusion.Compression.Net.Core" Version="*" />
<PackageReference Include="Syncfusion.OfficeChart.Net.Core" Version="*" />
<PackageReference Include="Syncfusion.EJ2.WordEditor.AspNet.Core" Version="*" />
<PackageReference Include="Syncfusion.EJ2.SpellChecker.AspNet.Core" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="4.*" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.9.2" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.*" />
<PackageReference Include="BitMiracle.LibTiff.NET" Version="2.4.649" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
});
}
}
}
}
Loading