pdfextract API
    Preparing search index...

    Function openPdf

    • Open a whole PDF and return a caller-owned document handle.

      Parameters

      • input: PdfInput

        File/Blob or whole PDF bytes; caller-owned buffers are copied before worker transfer.

      • options: OpenPdfOptions = {}

        Password, assets, resource limits and a borrowed OCR provider.

      Returns Promise<PdfDocument>

      A document to close in a finally block. Closing it never closes the supplied OCR provider.

      PdfExtractError for invalid/password-protected input, invalid options, cancellation or resource limits.

      const pdf = await openPdf(bytes);
      try {
      const text = await pdf.getStructuredText({ ocr: 'off' });
      console.log(text.fullText);
      } finally {
      await pdf.close();
      }