π IrbyImaging/Views/IrbyForms/ViewForm.cshtml Documentation
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model
- Key Functional Areas
4.1 Title Initialization
4.2 Control Buttons (Undo/Redo)
4.3 PDF Viewer Component
4.4 Scripts Section - API Endpoints Overview
- Thirdβparty Integrations
- Sample Code Blocks
- UML Diagram
- Usage Examples
- Conclusion
π― 1. Overview & Purpose
ViewForm.cshtml is a Razor view in the IrbyImaging application that renders an interactive PDF form editor.
- It provides formβfilling, undo/redo, text search, and handwritten signature capabilities.
- The view leverages a Syncfusion EJ2 PDF Viewer to stream and manipulate PDF documents directly in the browser.
π§ 2. Dependencies & Technologies
| Technology / Library | Purpose |
|---|---|
| ASP.NET Core MVC (Razor) | Serverβside view rendering |
| Syncfusion EJ2 PDFViewer | Inβbrowser PDF viewing & form design tools |
| Bootstrap 4/5 | Layout and styling (cards, buttons, grid) |
| FontAwesome | Iconography for Undo/Redo buttons |
| JavaScript (Vanilla) | Event handling for undo/redo operations |
π¦ 3. View Model
This view consumes a single model:
| Property | Type | Description |
|---|---|---|
FileName |
string |
Path or identifier of the PDF document |
@model IrbyImaging.UI.Models.IrbyFormsView
FileNameis passed from the controller to specify which PDF to load.
ποΈ 4. Key Functional Areas
4.1 π Title Initialization
@{
ViewData["Title"] = "Fill Form";
}
- Sets the HTML title (and any layout placeholders) to "Fill Form".
4.2 π Control Buttons (Undo/Redo)
<button class="btn btn-success" id="undo">
Undo <i class="fa fa-undo" aria-hidden="true"></i>
</button>
<button class="btn btn-warning" id="redo">
Redo <i class="fa fa-redo" aria-hidden="true"></i>
</button>
- Undo and Redo buttons allow users to revert or reapply changes made in the PDF form designer.
- They target the Syncfusion PDF viewer instance via JavaScript.
4.3 π PDF Viewer Component
<ejs-pdfviewer
id="pdfviewer"
style="height:641px;"
serviceUrl="/api/IrbyForms"
[email protected]
enableTextSelection="true"
enableTextSearch="true"
enableFormDesignerToolbar="true"
enableHandwrittenSignature="true">
</ejs-pdfviewer>
Attributes Explained:
| Attribute | Description |
|---|---|
id="pdfviewer" |
Unique DOM ID for JS reference |
style="height:641px;" |
Fixed height for the viewer container |
serviceUrl="/api/IrbyForms" |
Backend API endpoint to fetch or save PDF data |
documentPath |
Path or filename of the PDF to load |
enableTextSelection |
Allows users to select text within the PDF |
enableTextSearch |
Adds search panel to find text |
enableFormDesignerToolbar |
Exposes designer tools (text fields, checkboxes, radio buttons) |
enableHandwrittenSignature |
Enables freeβhand / signature ink annotation |
4.4 π₯οΈ Scripts Section
@section Scripts {
<script>
// Undo functionality
document.getElementById('undo').addEventListener('click', function () {
var pdfviewer = document.getElementById("pdfviewer").ej2_instances[0];
pdfviewer.undo();
});
// Redo functionality
document.getElementById('redo').addEventListener('click', function () {
var pdfviewer = document.getElementById("pdfviewer").ej2_instances[0];
pdfviewer.redo();
});
</script>
}
- @section Scripts ensures the JavaScript is rendered in the layoutβs script block.
- Retrieves the first EJ2 PDF viewer instance from
ej2_instancesarray and calls itsundo()/redo()methods.
π£οΈ 5. API Endpoints Overview
| Endpoint | Method | Description |
|---|---|---|
/api/IrbyForms |
GET/POST | Serves PDF documents & accepts form data |
- GET to fetch the PDF specified by
documentPath. - POST to save annotations or form field changes, if implemented on the server.
π€ 6. Thirdβparty Integrations
-
Syncfusion EJ2 PDF Viewer
- Licensed component for advanced PDF interactions in SPAs or serverβrendered apps.
-
FontAwesome
- Provides the undo/redo icons (
fa-undo,fa-redo).
- Provides the undo/redo icons (
π§© 7. Sample Code Blocks
7.1 Controller Action Example
public IActionResult FillForm(string fileName)
{
var model = new IrbyFormsView { FileName = fileName };
return View("ViewForm", model);
}
7.2 Clientβside Undo/Redo Usage
// Trigger undo
pdfviewer.undo();
// Trigger redo
pdfviewer.redo();
π 8. UML Diagram
βββββββββββββββββββ
β Browser (UI) β
β βββββββββββββββ β
β β ViewForm.cshtml β
β βββββββββββββββ β
β β β β
β ββββββββββ β
β β ejs-pdfviewer βββββ
β ββββββββββ β β
βββββββββ¬ββββββββββ β
β β
β β
ββββββββββββββββββββββββββββββ
β Web API (/api/IrbyForms) β
ββββββββββββββββββββββββββββββ
- Flow: Browser β Razor View β PDF Viewer β Web API β PDF Data Store.
π 9. Usage Examples
- Navigate to
/IrbyForms/FillForm?fileName=sample.pdf. - Form Designer toolbar appears, allowing text fields, checkboxes, signatures.
- Undo/Redo changes with the dedicated buttons.
- Search for text within the PDF.
- Select text to copy/paste.
π 10. Conclusion
The ViewForm.cshtml razor view brings a powerful, interactive PDF formβfilling experience to your web application. By combining ASP.NET Core MVC with Syncfusionβs EJ2 PDF Viewer, users gain rich editing featuresβsuch as form designer toolbars, text search, and handwritten signaturesβall within a familiar browser environment. Use the provided undo/redo controls and the /api/IrbyForms endpoint to seamlessly load, edit, and save PDF documents in your workflow.
Happy coding! π