RazorImageEditorLibrary 1.0.1

dotnet add package RazorImageEditorLibrary --version 1.0.1
NuGet\Install-Package RazorImageEditorLibrary -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RazorImageEditorLibrary" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RazorImageEditorLibrary --version 1.0.1
#r "nuget: RazorImageEditorLibrary, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RazorImageEditorLibrary as a Cake Addin
#addin nuget:?package=RazorImageEditorLibrary&version=1.0.1

// Install RazorImageEditorLibrary as a Cake Tool
#tool nuget:?package=RazorImageEditorLibrary&version=1.0.1

Razor-Image-Editor-Library

A Razor Class Library built using the Dynamsoft Document Viewer SDK, which is designed to offer a range of viewers for configuring and executing various document processing workflows, such as image editing and format conversion.

Demo Video

https://github.com/yushulx/Razor-Image-Editor-Library/assets/2202306/ac99fef4-d171-429a-88e4-ac4a2f1b23fb

Online Demo

https://yushulx.me/Razor-Image-Editor-Library/

Prerequisites

Quick Usage

  • Import and initialize the Razor Image Editor Library.

    @using RazorImageEditorLibrary
    
    @code {
        private ImageEditorJsInterop? imageEditorJsInterop;
    
        protected override async Task OnInitializedAsync()
        {
            imageEditorJsInterop = new ImageEditorJsInterop(JSRuntime);
            await imageEditorJsInterop.LoadJS();
        }
    }
    
  • Set the license key.

    await imageEditorJsInterop.SetLicense(licenseKey);
    
  • Createa a document manager instance.

    DocumentManager documentManager = await imageEditorJsInterop.CreateDocumentManager();
    
  • Load PDF reader wasm module if you want to view PDF files.

    await documentManager.LoadPdfWasm();
    
  • Create browse viewer and edit viewer by binding HTML div element IDs.

    <div id="browse-viewer"></div>
    <div id="edit-viewer"></div>
    
    @code {
        await documentManager.CreateBrowseViewer("browse-viewer");
        await documentManager.CreateEditViewer("edit-viewer");
    }
    
  • Load an input file or a canvas to the browse viewer.

    await documentManager.LoadFile(inputFile);
    await documentManager.LoadCanvas(canvas);
    
  • Convert selected images to a specified format.

    string selectedValue = FileFormat.PDF; // or FileFormat.PNG, FileFormat.JPG, FileFormat.TIFF
    await documentManager.Convert("convert", selectedValue, isZip);
    

API

FileFormat Class

Represents the file format of the output file.

DocumentManager Class

  • Task LoadPdfWasm(): Loads the PDF reader wasm module.
  • Task<bool> ExistPDF(ElementReference inputFile): Checks whether the input file is a PDF file.
  • Task CreateEditViewer(string elementId): Creates an edit viewer instance.
  • Task CreateBrowseViewer(string elementId): Creates a browse viewer instance.
  • Task LoadFile(ElementReference inputFile): Loads an input file to the browse viewer.
  • Task LoadCanvas(IJSObjectReference canvas): Loads a canvas to the browse viewer.
  • Task Convert(string filename, string format, bool isZip): Converts selected images to a specified format.
  • Task SelectAll(): Selects all files in the document manager.
  • Task UnselectAll(): Unselects all files in the document manager.
  • Task RemoveSelected(): Removes selected files from the document manager.
  • Task RemoveAll(): Removes all files from the document manager.

ImageEditorJsInterop Class

  • Task LoadJS(): Loads the Dynamsoft Document Viewer JavaScript library.
  • Task SetLicense(string license): Sets the license key.
  • Task<DocumentManager> CreateDocumentManager(): Creates a Document Manager instance.

Example

Build

cd RazorImageEditorLibrary
dotnet build --configuration Release
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 130 1/12/2024
1.0.0 81 1/11/2024

- Added ExistPDF() method to check input PDF file.