Skip to content

Commit cf76d29

Browse files
948910: Sample for Extract Text
1 parent e3b99b7 commit cf76d29

21 files changed

+593
-3
lines changed

How to/Extract Text Completed/ExtractTextCompleted/ExtractTextCompleted/ExtractTextCompleted.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
11-
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="29.1.33" />
11+
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
1212
</ItemGroup>
1313

1414
</Project>

How to/Extract Text Completed/ExtractTextCompleted/ExtractTextCompleted/Pages/Shared/_Layout.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
99
<link rel="stylesheet" href="~/PDFViewerSample.styles.css" asp-append-version="true" />
1010
<!-- Syncfusion ASP.NET Core controls styles -->
11-
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/27.1.58/fluent.css" />
11+
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/29.1.33/fluent.css" />
1212
<!-- Syncfusion ASP.NET Core controls scripts -->
13-
<script src="https://cdn.syncfusion.com/ej2/27.1.58/dist/ej2.min.js"></script>
13+
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js"></script>
1414
</head>
1515
<body>
1616
<div class="container">
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.34607.79
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtractText", "ExtractText\ExtractText.csproj", "{4E49C222-33F9-4DD3-96D1-EAA16A2A3D32}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4E49C222-33F9-4DD3-96D1-EAA16A2A3D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4E49C222-33F9-4DD3-96D1-EAA16A2A3D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4E49C222-33F9-4DD3-96D1-EAA16A2A3D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4E49C222-33F9-4DD3-96D1-EAA16A2A3D32}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {31245B35-82FC-4C3B-A888-4730D0AD8EE0}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="*" />
11+
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>https</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace PDFViewerSample.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@page "{handler?}"
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<div class="text-center">
8+
<button onclick="ExtractText()">Extract Text</button>
9+
<button onclick="ExtractTexts()">Extract Texts</button>
10+
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
11+
</ejs-pdfviewer>
12+
</div>
13+
14+
<script type="text/javascript">
15+
function ExtractText(){
16+
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
17+
viewer.extractText(1, 'TextOnly').then((val) => {
18+
console.log('Extracted Text from Page 1:');
19+
console.log(val); // Logs the extracted text from page 1
20+
});
21+
}
22+
function ExtractTexts(){
23+
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
24+
viewer.extractText(0, 2, 'TextOnly').then((val) => {
25+
console.log('Extracted Text from Pages 0 to 2:');
26+
console.log(val); // Logs the extracted text from pages 0 to 2
27+
});
28+
}
29+
</script>

0 commit comments

Comments
 (0)