Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34309.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreSample", "CoreSample\CoreSample.csproj", "{74B177C7-8BEA-4FC2-8067-208F7A494DA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Xml|Any CPU = Release-Xml|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Release|Any CPU.Build.0 = Release|Any CPU
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Release-Xml|Any CPU.ActiveCfg = Release|Any CPU
{74B177C7-8BEA-4FC2-8067-208F7A494DA3}.Release-Xml|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0548ECA4-3BAC-44DB-90D2-F6C447AD24CC}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.8" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="PDF_Succinctly.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\EJ2 Materials\ASP.NET.Core\8.0\CoreSample8.01999985370\CoreSample\CoreSample\Properties\PublishProfiles\CoreSample20240719165733 - Web Deploy.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<fallbackPackageFolders>
<clear />
</fallbackPackageFolders>
<disabledPackageSources>
<clear />
</disabledPackageSources>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace CoreSample.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
@page "{handler?}"
@model IndexModel
@{
// Set the page title for the browser tab
ViewData["Title"] = "Home page";

// Build the base URL for the application using current request information
var originUrl = $"{Request.Scheme}://{Request.Host}{Request.PathBase}";

// Define the default document path
var document = originUrl + "/PDF_Succinctly.pdf";

// Set the resource URL for Syncfusion PDF Viewer library files
var resourceUrl = originUrl + "/ej2-pdfviewer-lib";
}

<div>
<h5>Select Document to View</h5>
<ul>
<li id="set" onclick="loadDocument1()"><a href="#">Document 1</a></li>
<li id="set" onclick="loadDocument2()"><a href="#">Document 2</a></li>
<li id="set" onclick="loadDocument3()"><a href="#">Document 3</a></li>
</ul>
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl=@resourceUrl formFieldPropertiesChange="formFieldPropertiesChange" formFieldAdd="onFormFieldAdd">
</ejs-pdfviewer>
</div>

<script>
var originUrl = '@originUrl';

function loadDocument1() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.load(originUrl + "/form-filling-document.pdf", "null");
}

function loadDocument2() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.load(originUrl + "/form-designer.pdf", "null");
}

function loadDocument3() {
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.load(originUrl + "/pdf-succinctly (5).pdf", "null");
}

function validateEmail(value) {
const emailRegex = /^[^\s@@]+@@[^\s@@]+\.[^\s@@]+$/;
return emailRegex.test(value);
}

function validateNumber(value) {
const numberRegex = /^[0-9]+$/;
return numberRegex.test(value);
}

function validateDate(value) {
const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
return dateRegex.test(value);
}

function onFormFieldAdd(event) {
console.log('New form field added:', event.field);

if (event.field.type === 'Text') {
event.field.placeholder = 'Enter text here...';
}
}


function formFieldPropertiesChange(event) {
const viewer = document.getElementById('pdfviewer').ej2_instances[0];
const field = event.field;
const value = field.value;
let isValid = true;

// Remove '_content' from the field ID if it exists
const fieldIdWithoutContent = field.id.replace('_content', '');

// Find the matching field in the form field collection
const formFields = viewer.formFieldCollections;
const matchingField = formFields.find(f => f.id === fieldIdWithoutContent);

if (!matchingField) {
console.error(`Field with ID "${fieldIdWithoutContent}" not found in the form field collection.`);
return;
}

// Validate based on field name
if (matchingField.name.includes('My Email')) {
isValid = validateEmail(value);
} else if (matchingField.name.includes('My Phone')) {
isValid = validateNumber(value);
} else if (matchingField.name.includes('dob')) {
isValid = validateDate(value);
}

if (!isValid) {
// Update field properties to show invalid state (red border), keep the value as is
viewer.formDesigner.updateFormField(matchingField, { borderColor: 'red' });
} else {
// Reset to the default border color when valid input is entered
viewer.formDesigner.updateFormField(matchingField, { borderColor: '#2f2f2fff' });
}
}


</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Syncfusion.EJ2.PdfViewer;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Reflection;
using System.Net;
using Syncfusion.Pdf.Parsing;

namespace CoreSample.Pages
{
[IgnoreAntiforgeryToken(Order = 1001)]
public class IndexModel : PageModel
{

private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
private IMemoryCache _cache;

public IndexModel(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IMemoryCache cache)
{
_hostingEnvironment = hostingEnvironment;
_cache = cache;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Use this page to detail your site's privacy policy.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace CoreSample.Pages
{
public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;

public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}

public void OnGet()
{
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - CoreSample</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/CoreSample.styles.css" asp-append-version="true" />
<!-- Syncfusion ASP.NET Core controls styles -->
<link rel="stylesheet" href="~/material.min.css" />
<!-- Syncfusion ASP.NET Core controls scripts -->
<script src="~/ej2.min.js"></script>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">CoreSample</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container-fluid">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - CoreSample - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>

@await RenderSectionAsync("Scripts", required: false)
<!-- Syncfusion ASP.NET Core Script Manager -->
<ejs-scripts></ejs-scripts>
</body>
</html>
Loading