πŸ“„ IrbyImaging/Views/IrbyForms/ViewForm.cshtml Documentation


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model
  4. Key Functional Areas
    4.1 Title Initialization
    4.2 Control Buttons (Undo/Redo)
    4.3 PDF Viewer Component
    4.4 Scripts Section
  5. API Endpoints Overview
  6. Third‑party Integrations
  7. Sample Code Blocks
  8. UML Diagram
  9. Usage Examples
  10. 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
  • FileName is 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_instances array and calls its undo()/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).

🧩 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

  1. Navigate to /IrbyForms/FillForm?fileName=sample.pdf.
  2. Form Designer toolbar appears, allowing text fields, checkboxes, signatures.
  3. Undo/Redo changes with the dedicated buttons.
  4. Search for text within the PDF.
  5. 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! πŸš€