@taktikal/pdf2html
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@taktikal/pdf2html

Purpose

Provide utility functions for consuming Taktikal's PDF-to-HTML service.

Configuration

There is no default value for the URL. If it is not configured, you will run into errors.

import { setPdf2HtmlUrl } from "@taktikal/pdf2html";

setPdf2HtmlUrl(process.env.PDF_TO_HTML_URL);

Usage

Getting the PDF HTML

import { getPdfHtml } from "@taktikal/pdf2html";

const html = await getPdfHtml(pdfUrl);

Using the PDF HTML

import { PdfHtmlData } from "@taktikal/pdf2html";

const render = (html: PdfHtmlData) => (
  <>
    <Head>
      {html.styles.map((styleHTML, i) => (
        <style key={i.toString()} dangerouslySetInnerHTML={{ __html: styleHTML }} />
      ))}
    </Head>
    {html.pages.map((pageHTML, i) => (
      <div
        key={i}
        id={"pf" + (i + 1).toString(16)} // pdf2htmlEX uses hexadecimal page numbering
        className="pf"
        data-page-no={i + 1}
        dangerouslySetInnerHTML={{ __html: pageHTML }}
        style={{ overflow: "hidden" }}
      />
    ))}
  </>
);

Readme

Keywords

none

Package Sidebar

Install

npm i @taktikal/pdf2html

Weekly Downloads

1

Version

1.1.0

License

ISC

Unpacked Size

6.17 kB

Total Files

9

Last publish

Collaborators

  • alexharri
  • bjark