PDF Web Viewer
    Preparing search index...

    Class PdfSdk

    Main SDK class for PDF operations

    This class provides static methods for:

    • Initializing the PDF SDK
    • Opening existing PDF documents
    • Creating new blank PDF documents
    • Accessing system fonts

    All methods are static and should be called directly on the class. The SDK must be initialized before any document operations can be performed.

    Index

    Constructors

    Methods

    • Initializes the PDF SDK with the provided configuration

      This method must be called before any other SDK operations. It sets up the underlying PDF editor service with the necessary configuration such as worker paths, WASM files, and other initialization parameters.

      Parameters

      • options: IInitializeData

        Configuration data for initializing the SDK

      Returns Promise<void>

      Promise that resolves when initialization is complete

      If initialization fails

      // Minimal initialization (auto-detects all asset paths)
      await PdfSdk.initialize({
      license: 'your-license-key'
      });

      // With custom paths
      await PdfSdk.initialize({
      license: 'your-license-key',
      workerPath: '/custom/pwv-workers',
      fontsPath: '/custom/pwv-fonts'
      });
    • Retrieves all system fonts available for use in PDF documents

      This method returns a list of fonts that can be used when creating or editing text content in PDF documents.

      Returns Promise<IFontMini[]>

      Promise resolving to an array of available system fonts

      If the SDK is not initialized

      const fonts = await PdfSdk.listSystemFonts();
      console.log('Available fonts:', fonts);
    • Creates and opens a new blank PDF document

      This method creates a new PDF document with default or custom settings and returns a DocumentModel instance that can be used to add content and manipulate the document.

      Parameters

      • Optionaldata: ICreateNewDocumentData

        Optional configuration for the new document (page size, PDF version, etc.)

      Returns Promise<DocumentModel>

      Promise resolving to a DocumentModel instance for the new document

      If the SDK is not initialized or if document creation fails

      // Create with default settings
      const document = await PdfSdk.openBlankDocument();

      // Create with custom settings
      const document = await PdfSdk.openBlankDocument({
      name: 'My Document.pdf',
      numPages: 5,
      Rectangle: [0, 792, 612, 0], // Letter size
      PDFVersion: '2.0'
      });
    • Opens an existing PDF document from a file

      This method loads a PDF document from the provided file data and returns a DocumentModel instance that can be used to manipulate the document.

      Parameters

      Returns Promise<DocumentModel>

      Promise resolving to a DocumentModel instance for the opened document

      If the SDK is not initialized or if the file cannot be opened

      const document = await PdfSdk.openDocument({
      file: pdfFile,
      name: 'example.pdf'
      });
    • Registers user-provided fonts for use in PDF documents

      This method allows you to register custom fonts from external sources (e.g., Google Fonts API) that will be available for use when creating or editing text content in PDF documents. The fonts must be registered before opening or creating a document.

      Parameters

      • fonts: IUserFontData

        Array of user font objects containing family, variants, and file URLs

      Returns Promise<void>

      If the SDK is not initialized

      const userFonts = {
      baseUrl: 'https://fonts.googleapis.com/css2',
      fonts: [
      {
      family: 'Roboto',
      variants: ['regular', 'bold', 'italic'],
      files: {
      regular: 'https://fonts.gstatic.com/...',
      bold: 'https://fonts.gstatic.com/...',
      },
      // ... other font metadata
      }
      ]
      };
      await PdfSdk.registerUserFonts(userFonts);