Member Junction
    Preparing search index...

    Action that extracts content from PDF files using pdfjs-dist (Mozilla PDF.js). Can extract text, metadata, or specific pages.

    Uses pdfjs-dist instead of pdf-parse for broader PDF compatibility, including PDFs generated by pdfkit, and true per-page text extraction.

    // Extract all text from PDF
    await runAction({
    ActionName: 'PDF Extractor',
    Params: [{
    Name: 'FileURL',
    Value: 'https://example.com/document.pdf'
    }, {
    Name: 'ExtractType',
    Value: 'text'
    }]
    });

    // Extract metadata from PDF
    await runAction({
    ActionName: 'PDF Extractor',
    Params: [{
    Name: 'PDFData',
    Value: base64PdfData
    }, {
    Name: 'ExtractType',
    Value: 'metadata'
    }]
    });

    // Extract specific pages
    await runAction({
    ActionName: 'PDF Extractor',
    Params: [{
    Name: 'FileID',
    Value: 'uuid-of-pdf-file'
    }, {
    Name: 'ExtractType',
    Value: 'pages'
    }, {
    Name: 'PageNumbers',
    Value: [1, 3, 5]
    }]
    });

    Hierarchy

    • BaseFileHandlerAction
      • PDFExtractorAction
    Index

    Constructors

    Methods

    • Get file content from various sources based on parameters Priority: FileID > FileURL > Data parameter

      Parameters

      • params: RunActionParams

        Action parameters

      • dataParamName: string

        Name of the parameter containing direct data

      • fileParamName: string = 'FileID'

        Name of the parameter containing file ID (default: 'FileID')

      • urlParamName: string = 'FileURL'

        Name of the parameter containing file URL (default: 'FileURL')

      Returns Promise<
          {
              content: string
              | Buffer;
              fileName?: string;
              mimeType?: string;
              source: "url" | "storage" | "direct";
          },
      >

      Object with content and metadata

    • Extracts content from PDF files

      Parameters

      • params: RunActionParams

        The action parameters containing:

        • FileID: UUID of MJ Storage file (optional)
        • FileURL: URL of PDF file (optional)
        • PDFData: Base64 encoded PDF data (optional)
        • ExtractType: "text" | "metadata" | "pages" (default: "text")
        • PageNumbers: Array of page numbers to extract (for pages extraction)
        • MergePages: Boolean - merge text from all pages (default: true)
        • IncludePageBreaks: Boolean - add page break markers (default: false)

      Returns Promise<ActionResultSimple>

      Extracted content based on extraction type

    • Executes the action with the provided parameters.

      Parameters

      Returns Promise<ActionResultSimple>

      Promise resolving to the action result

    • Save file to MJ Storage. Uploads the content to a FileStorageAccount and creates the corresponding MJ: Files entity record.

      Parameters

      • content: string | Buffer

        File content as string or Buffer

      • fileName: string

        Name for the file

      • mimeType: string

        MIME type of the file

      • params: RunActionParams

        Action parameters (for contextUser)

      • OptionalstorageAccountName: string

        Optional: name of the storage account to use (falls back to first active)

      • OptionalstoragePath: string

        Optional: custom storage path prefix (falls back to artifacts/{date}/{uuid}/)

      Returns Promise<string>

      The ID of the newly created MJ: Files record