Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 1.59 KB

3.quickstart.md

File metadata and controls

77 lines (57 loc) · 1.59 KB

Quick Start Guide

This guide will help you get started with Docen quickly by walking through basic usage examples.

Basic Usage

1. Simple Document Conversion

import { convert } from "docen";
import { PDFProcessor } from "docen/pdf";
import { DOCXProcessor } from "docen/docx";

// Register processors
registerProcessor(new PDFProcessor());
registerProcessor(new DOCXProcessor());

// Convert PDF to DOCX
await convert("document.pdf", "document.docx");

2. Using the CLI

# Convert PDF to DOCX
docen convert document.pdf document.docx

# Convert with options
docen convert document.pdf document.docx --ocr --language eng

Common Use Cases

1. Batch Processing

import { convert } from "docen";
import { PDFProcessor } from "docen/pdf";

registerProcessor(new PDFProcessor());

const files = ["doc1.pdf", "doc2.pdf", "doc3.pdf"];
await Promise.all(
  files.map((file) => convert(file, file.replace(".pdf", ".docx"))),
);

2. Custom Conversion Options

await convert("document.pdf", "document.docx", {
  ocr: true,
  language: "eng",
  preserveFormatting: true,
  quality: "high",
});

3. Error Handling

try {
  await convert("document.pdf", "document.docx");
} catch (error) {
  if (error.code === "UNSUPPORTED_FORMAT") {
    console.error("Format not supported");
  } else {
    console.error("Conversion failed:", error.message);
  }
}

Next Steps