Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ documentation: ug

# Dynamically instantiate the ASP.NET Core PDF Viewer

The Syncfusion<sup style="font-size:70%">&reg;</sup> ASP.NET Core PDF Viewer can be instantiated at runtime rather than during the initial page load. This dynamic approach is useful when the document to be displayed depends on user interaction or must be retrieved from a secure backend service.
The Syncfusion<sup style="font-size:70%">&reg;</sup> ASP.NET Core PDF Viewer can be instantiated at runtime rather than during the initial page load. This dynamic approach is useful when the document to be displayed depends on user interaction or must be retrieved from a secure back end service.

Follow these steps to instantiate the viewer component programmatically:

1. **Verify Prerequisites:** Ensure your application references the required Syncfusion EJ2 script and style assets. The backend PDF Viewer service must be correctly configured in your ASP.NET Core application.
1. **Verify Prerequisites:** Verify that your application references the required Syncfusion EJ2 script and style assets, and that the back end PDF Viewer service is correctly configured in your ASP.NET Core application.
2. **Setup Container:** Add a target container element and a trigger (such as a button) to the Razor view.
3. **Initialize Component:** To create the viewer instance, configure the [`serviceUrl`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_ServiceUrl) and [`documentPath`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_DocumentPath), and then mount it using the `appendTo` method.

Expand All @@ -22,12 +22,12 @@ The following example demonstrates how to load the viewer dynamically after an A
```html

<div style="width:100%;height:600px">
<button id="loadPDF Viewer">Load PDF Viewer</button>
<button id="loadPDFViewer">Load PDF Viewer</button>
<div id="pdfViewer" style="height: 100%;width: 100%;"></div>
</div>

<script>
document.getElementById("loadPDF Viewer").addEventListener('click', function () {
document.getElementById("loadPDFViewer").addEventListener('click', function () {
$.ajax({
url: 'https://localhost:44327/pdfviewer/GetPdfDocument',
type: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The PDF Viewer enables customization of toolbar items, including adding, showing
<ejs-pdfviewer id="pdfviewer"
style="width:1350px;height:100%"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
resourceUrl='https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib"'
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib"
toolbarClick="toolbarClick">
</ejs-pdfviewer>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ Follow these steps to configure authorization headers for your PDF Viewer instan

**Step 1:** Follow the [Getting Started with ASP.NET Core PDF Viewer guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/asp-net-core/getting-started) to set up a basic PDF Viewer instance in your ASP.NET Core project.

**Step 2:** Add the following script to configure the authorization token. This should be executed after the PDF Viewer instance is initialized (for example, in the Razor view or layout file).
**Step 2:** Add the following PDF Viewer markup and script to configure the authorization token. The script should be executed after the PDF Viewer instance is initialized (for example, in the Razor view or layout file).

```html
<div style="width:100%;height:600px">
<ejs-pdfviewer id="pdfviewer" serviceUrl="/Index"></ejs-pdfviewer>
</div>

<script>
// Include the Authorization token
window.onload = function () {
var pdfViewer = document.getElementById('pdfViewer').ej2_instances[0];
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
pdfViewer.ajaxRequestSettings = {
ajaxHeaders: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Manage how annotations appear at different stages of the document workflow. This

## Control annotation visibility on download

**Step 1:** Follow the [Syncfusion ASP.NET Core PDF Viewer getting started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/asp-net-core/getting-started) to set up a basic PDF Viewer sample.
**Step 1:** Follow the [Syncfusion ASP.NET Core PDF Viewer getting started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/asp-net-core/getting-started) to set up a basic PDF Viewer sample. The example below uses the PDF Library APIs exposed through the `ej2-pdfviewer-lib` resource, so no additional script references are required.

**Step 2:** Add a download button and configure the viewer markup. The following example includes logic to update annotation flags before the file is saved:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Use the `customContextMenuBeforeOpen()` event to conditionally display or hide m
</script>
```

## Sample: Custom context menu output
## Sample: Custom context menu

The following complete sample demonstrates a customized context menu with action handlers for all menu items:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The PDF Viewer supports changing fonts for Signature and Initial fields using th

**Step 1:** Follow the [Getting Started guide](https://help.syncfusion.com/document-processing/pdf/pdf-viewer/asp-net-core/getting-started) to set up a basic PDF Viewer instance.

**Step 2:** Define the signature and initial field settings in your application:
**Step 2:** Define the signature and initial field settings in your application and call the function (for example, on a button click or in the `documentLoaded` event) so the font arrays are applied to the viewer:

{% tabs %}
{% highlight html tabtitle="Standalone" %}
Expand Down Expand Up @@ -51,7 +51,7 @@ The PDF Viewer supports changing fonts for Signature and Initial fields using th
{% endhighlight %}
{% endtabs %}

### Initial field property
### typeInitialFonts property

Use the following code to apply custom fonts to the Initial field.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ documentation: ug
domainurl: ##DomainURL##
---

# Add custom fonts to PDF forms in ASP.NET Core PDF Viewer
# Add custom fonts in ASP.NET Core PDF Viewer

The Syncfusion ASP.NET Core PDF Viewer supports loading, editing, and saving custom fonts in interactive form fields such as [TextBox](../forms/manage-form-fields/create-form-fields#textbox), [ListBox](../forms/manage-form-fields/create-form-fields#listbox), and [DropDown](../forms/manage-form-fields/create-form-fields#dropdown). Use the `customFonts` property to ensure consistent text rendering even when specific fonts are not installed on the user's system.

Expand All @@ -31,7 +31,7 @@ The custom font workflow in the PDF Viewer involves these key steps:

### Step 1: Add TTF font files

Place the TTF font files in the resource path used by the PDF Viewer. Fonts can be referenced in two ways:
Place the TTF font files in the resource path used by the PDF Viewer (for example, the `wwwroot` folder in a typical ASP.NET Core project). Fonts can be referenced in two ways:

* **Relative Path:** (for example: `calibri.ttf` or `fallback-fonts/calibri.ttf`)
* **Absolute URL:** Host fonts on a secure server and reference them using a fully qualified URL. Ensure that the hosting server has **CORS** enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The following example demonstrates how to configure these colors in both Standal
<ejs-pdfviewer id="pdfviewer"
style="height:600px"
documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib""
resourceUrl="https://cdn.syncfusion.com/ej2/31.1.17/dist/ej2-pdfviewer-lib"
enableTextSearch="true"
textSearchColorSettings="@(new Syncfusion.EJ2.PdfViewer.PdfViewerTextSearchColorSettings
{ SearchColor = "#FF0000", SearchHighlightColor = "#0000FF" })">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ documentation: ug

Tile rendering is a performance-optimization feature used to display large PDF documents efficiently. In some scenarios, such as when viewing smaller documents or troubleshooting rendering artifacts, disabling this feature will help.

Use the **enableTileRendering** property within the `tileRenderingSettings` object to toggle this behavior. By default, tile rendering is enabled.
Use the **EnableTileRendering** property within the `tileRenderingSettings` object to toggle this behavior. By default, tile rendering is enabled.

N> Disabling tile rendering can improve initial performance for small documents but may result in slower rendering and increased memory usage for larger PDF files.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
layout: post
title: Enable resize in ASP.NET Core PDF Viewer control | Syncfusion
description: Learn here all about Enable resize in Syncfusion ASP.NET Core PDF Viewer control of Syncfusion Essential JS 2 and more.
title: Resize Text Markup Annotations in Syncfusion ASP.NET Core PDF Viewer
description: Learn here all about resizing text markup annotations in Syncfusion ASP.NET Core PDF Viewer control of Syncfusion Essential JS 2 and more.
platform: document-processing
control: PDF Viewer
documentation: ug
---

# Resize text markup annotations in ASP.NET Core PDF Viewer

The PDF Viewer has the option to display resizers for text markup annotations using the **enableTextMarkupResizer** property. This feature allows users to adjust the dimensions of the markup after it has been added to the document.
The PDF Viewer has the option to display resizer for text markup annotations using the **enableTextMarkupResizer** property. This feature allows users to adjust the dimensions of the markup after it has been added to the document.

The default value for this property is `false`.

## Enable text markup resizer

Set the **EnableTextMarkupResizer** property to `true` in the Razor view to display resizer handles on text markup annotations:
Set the **enableTextMarkupResizer** property to `true` in the Razor view to display resizer handles on text markup annotations:

{% tabs %}
{% highlight cshtml tabtitle="Standalone" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ Dynamically enable or disable text selection using buttons or other UI triggers.

Text selection is enabled by default. When disabled, users cannot select or copy text from the PDF, which helps protect document content in security-sensitive scenarios.

N> When `enableTextSelection` is set to `false`, all text selection functionality, including keyboard shortcuts and mouse interactions, is disabled.
N> When `enableTextSelection` is set to `false` (whether at initialization or at runtime), all text selection functionality, including keyboard shortcuts and mouse interactions, is disabled.

[View sample in GitHub](https://github.com/SyncfusionExamples/asp-core-pdf-viewer-examples/tree/master/How%20to)
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ To export multiple pages within a range, use the **exportAsImages()** method. Th

<script>
function exportAsImages() {
let startPageIndex: number = 1;
let endPageIndex: number = 5;
let startPageIndex = 1;
let endPageIndex = 5;
let imageDetails;
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAsImages(startPageIndex, endPageIndex).then(function (value) {
imageDetails = value;
Expand All @@ -98,18 +99,19 @@ Use this code snippet to export a range of pages as Base64-encoded image strings
{% tabs %}
{% highlight cshtml tabtitle="Standalone" %}

<button type="button" onclick="exportAsImageWithSize()">ExportAsImageWithSize</button>
<button type="button" onclick="exportAsImagesWithSize()">ExportAsImagesWithSize</button>
<div style="width:100%;height:600px">
@Html.EJS().PdfViewer("pdfviewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/hive-succinctly.pdf").Render()
</div>

<script>
function exportAsImageWithSize() {
let startPageIndex: number = 1;
let endPageIndex: number = 5;
let size: Size = new Size(200,500);
function exportAsImagesWithSize() {
let startPageIndex = 1;
let endPageIndex = 5;
let size = { width: 200, height: 500 };
let imageDetails;
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.exportAsImages(startPageIndex, endPageIndex, size).then(function (value) {
pdfViewer.exportAsImages(startPageIndex, endPageIndex, size).then(function (value) {
imageDetails = value;
console.log(imageDetails);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bitmapimage.Save(@"currentDirectory\..\..\..\..\Images\" + "bitmapImage" + i.ToS

### Export a page with custom size

Exports the specified page as image with respect to the specified custom size.
Exports the specified page as an image using the specified custom size.

```cs

Expand All @@ -70,7 +70,7 @@ bitmapimage.Save(@"currentDirectory\..\..\..\..\Images\" + "bitmapImage" + i.ToS

### Export a page with custom size and DPI

Exports the specified page as image with respect to the custom size and the specified DPI values.
Exports the specified page as an image using the specified custom size and DPI values.

```cs

Expand Down Expand Up @@ -127,7 +127,7 @@ for (int i = 0; i < pdfExportImage.PageCount; i++)

### Export a range with custom size

Exports the specified pages as images with respect to the specified custom size.
Exports the specified pages as images using the specified custom size.

```cs

Expand All @@ -147,7 +147,7 @@ for (int i = 0; i < pdfExportImage.PageCount; i++)

### Export a range with custom size and DPI

Exports the specified pages as images with respect to the custom size and the specified DPI values.
Exports the specified pages as images using the specified custom size and DPI values.

```cs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To extract text, set the **isExtractText** property to `true`. Once the text ext
{% tabs %}
{% highlight cshtml tabtitle="Standalone" %}

page "{handler?}"
@page "{handler?}"
@model IndexModel
@{
ViewData["Title"] = "Home page";
Expand All @@ -34,7 +34,7 @@ page "{handler?}"
var viewer = document.getElementById('pdfviewer').ej2_instances[0];
viewer.isExtractText = true;
viewer.extractTextCompleted = args => {
//Extract the Complete text of load document
//Extract the complete text of the loaded document
console.log(args);
console.log(args.documentTextCollection[1]);
//Extract the Text data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Configure extractTextOption in ASP.NET Core PDF Viewer

The Syncfusion<sup style="font-size:70%">&reg;</sup> ASP.NET Core PDF Viewer provides the [`extractTextOption`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_ExtractTextOption) property to control how the component extracts text data. Adjusting this property allows you to optimize memory consumption and determine the specific metadata returned in the `extractTextCompleted` event.
The Syncfusion<sup style="font-size:70%">&reg;</sup> ASP.NET Core PDF Viewer provides the [`extractTextOption`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_ExtractTextOption) property to control how the component extracts text data. Adjusting this property allows you to optimize memory consumption and determine the specific metadata returned in the [`extractTextCompleted`](https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.PdfViewer.PdfViewer.html#Syncfusion_EJ2_PdfViewer_PdfViewer_ExtractTextCompleted) event.

## Available options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation: ug

# Extract text using TextLineCollection in ASP.NET Core

The Syncfusion PDF Viewer server Library extracts text and its precise bounding coordinates from a PDF page using the **ExtractText** method. The output **TextLineCollection** contains detailed layout information for each line of text.
The Syncfusion PDF Viewer server Library extracts text and its precise bounding coordinates from a PDF page using the `ExtractText` method. The output `TextLineCollection` contains detailed layout information for each line of text.

## Prerequisites

Expand All @@ -34,7 +34,7 @@ var fileInfo = new FileInfo(path);
var docStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read);
// Load the PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(docStream);
// Loading page collections
// Load the first page.
PdfPageBase page = document.Pages[0] as PdfLoadedPage;
//Extract text from the page.
var text = page.ExtractText(out TextLineCollection textLineCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The `extractText()` method in the PDF Viewer retrieves text from a single page o

### Method parameters

- **startIndex:** The starting page index (0-based).
- **startIndex (number):** The starting page index (0-based).

- **endIndex or isOptions:** Either the ending page index for multi-page extraction or an option for single-page extraction.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ Use the `findTextAsync` method to search for text strings and retrieve bounding

### Description

The `findTextAsync` method performs an asynchronous text search within a PDF document. You can search for a single string or multiple strings while controlling case sensitivity. By default, the search runs across all pages. Specify the optional `pageIndex` argument to limit the search to a single page.
The `findTextAsync` method performs an asynchronous text search within a PDF document. You can search for a single string or multiple strings while controlling case sensitivity. By default, the search runs on all pages. Specify the optional `pageIndex` argument to limit the search to a single page.

### Parameters

- **text (string | string[]):** String or array of strings to search for.

- **matchCase (boolean):** Whether the search is case-sensitive. `true` matches exact case; `false` ignores case.

- **pageIndex (optional, number):** Zero-based page index to search. If omitted, searches all pages.
- **pageIndex (optional, number):** Zero-based page index to search. If omitted, searches all pages. When `text` is an array, each string is searched only on the page specified by `pageIndex`. When `pageIndex` is provided, the search is restricted to that single page and the `matchCase` argument is still honored.

### Example workflow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ control: PDF Viewer
documentation: ug
---

# Convert a loaded PDF to Base64 string in ASP.NET Core PDF Viewer
# Convert a loaded PDF to a Base64 string in ASP.NET Core PDF Viewer

Extract the current PDF as a Base64-encoded string from the Syncfusion ASP.NET Core PDF Viewer. This is useful for transmitting PDFs to a server, storing them in databases, or performing further processing on the client side.

Expand Down Expand Up @@ -45,7 +45,6 @@ Follow these steps to convert the displayed PDF to a Base64 string:
}
});
</script>

```

### Conclusion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: post
title: Identify annotation mode in ASP.NET Core PDF Viewer | Syncfusion
description: Learn here all about Identify added annotation mode in Syncfusion ASP.NET Core PDF Viewer control of Syncfusion Essential JS 2 and more.
description: Learn how to identify the current annotation addition mode in the Syncfusion ASP.NET Core PDF Viewer and manage annotation workflows efficiently.
platform: document-processing
control: PDF Viewer
documentation: ug
Expand Down
Loading