Modules@robinpath/pdf
pdf

@robinpath/pdf

0.1.5Node.jsPublic

PDF generation from HTML/text and text extraction from PDFs

PDF

PDF generation (documents, tables, HTML-to-PDF) and parsing (text extraction, metadata, page count)

Package: @robinpath/pdf | Category: Documents | Type: Integration

Authentication

No authentication required. All functions are available immediately.

Use Cases

Use the pdf module when you need to:

  • Generate a PDF document with title, content, and sections -- Use pdf.generate to perform this operation
  • Parse a PDF file and extract text, metadata, and page count -- Use pdf.parse to perform this operation
  • Extract all text from a PDF file -- Use pdf.extractText to perform this operation
  • Get the number of pages in a PDF -- Use pdf.pageCount to perform this operation
  • Get PDF metadata (author, title, creation date, etc.) -- Use pdf.metadata to perform this operation

Quick Reference

FunctionDescriptionReturns
generateGenerate a PDF document with title, content, and sections{path, pages}
parseParse a PDF file and extract text, metadata, and page count{text, pages, info, metadata}
extractTextExtract all text from a PDF fileExtracted text content
pageCountGet the number of pages in a PDFPage count
metadataGet PDF metadata (author, title, creation date, etc.){info, metadata, pages}
generateTableGenerate a PDF with a formatted table{path}
generateFromHtmlGenerate a PDF from basic HTML content{path, pages}

Functions

generate

Generate a PDF document with title, content, and sections

Module: pdf | Returns: object -- {path, pages}

pdf.generate "./report.pdf" {"title": "Monthly Report", "content": "..."}
ParameterTypeRequiredDescription
outputPathstringYesOutput file path
optionsobjectYes{title, author, content, sections, footer, size, margin, fontSize}

parse

Parse a PDF file and extract text, metadata, and page count

Module: pdf | Returns: object -- {text, pages, info, metadata}

pdf.parse "./document.pdf"
ParameterTypeRequiredDescription
filePathstringYesPath to PDF file

extractText

Extract all text from a PDF file

Module: pdf | Returns: string -- Extracted text content

pdf.extractText "./document.pdf"
ParameterTypeRequiredDescription
filePathstringYesPath to PDF file

pageCount

Get the number of pages in a PDF

Module: pdf | Returns: number -- Page count

pdf.pageCount "./document.pdf"
ParameterTypeRequiredDescription
filePathstringYesPath to PDF file

metadata

Get PDF metadata (author, title, creation date, etc.)

Module: pdf | Returns: object -- {info, metadata, pages}

pdf.metadata "./document.pdf"
ParameterTypeRequiredDescription
filePathstringYesPath to PDF file

generateTable

Generate a PDF with a formatted table

Module: pdf | Returns: object -- {path}

pdf.generateTable "./table.pdf" ["Name","Email"] $rows
ParameterTypeRequiredDescription
outputPathstringYesOutput file path
headersarrayYesColumn headers
rowsarrayYesArray of row arrays or objects
optionsobjectNo{title, landscape}

generateFromHtml

Generate a PDF from basic HTML content

Module: pdf | Returns: object -- {path, pages}

pdf.generateFromHtml "./output.pdf" "<h1>Title</h1><p>Content</p>"
ParameterTypeRequiredDescription
outputPathstringYesOutput file path
htmlstringYesHTML content

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(standard errors)Check function parameters and authentication
@desc "Generate and validate result"
do
  set $result as pdf.generate "./report.pdf" {"title": "Monthly Report", "content": "..."}
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. Multi-step PDF workflow

Chain multiple pdf operations together.

@desc "Generate, parse, and more"
do
  set $r_generate as pdf.generate "./report.pdf" {"title": "Monthly Report", "content": "..."}
  set $r_parse as pdf.parse "./document.pdf"
  set $r_extractText as pdf.extractText "./document.pdf"
  print "All operations complete"
enddo

2. Safe generate with validation

Check results before proceeding.

@desc "Generate and validate result"
do
  set $result as pdf.generate "./report.pdf" {"title": "Monthly Report", "content": "..."}
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • excel -- Excel module for complementary functionality
  • office -- Office module for complementary functionality
  • docusign -- DocuSign module for complementary functionality
  • pandadoc -- PandaDoc module for complementary functionality
  • hellosign -- HelloSign module for complementary functionality

Versions (1)

VersionTagPublished
0.1.5latest1 months ago
Install
$ robinpath add @robinpath/pdf

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.5
LicenseMIT
Unpacked Size9.0 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

productivity