New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

preactjs-pdf

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preactjs-pdf

这是一个 Preact 库,用于通过基于组件的方法创建 PDF 文档,类似于 @react-pdf/renderer。

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Preact PDF Library

This is a Preact library for creating PDF documents using a component-based approach, similar to @react-pdf/renderer.

Installation

npm install preact-pdf

Usage

PDFViewer

import { Document, Page, Text, View, PDFViewer } from 'preact-pdf';

const App = () => (
  <PDFViewer style={{ width: '100%', height: '100vh' }}>
    <Document>
      <Page>
        <Text>Hello, World</Text>
      </Page>
    </Document>
  </PDFViewer>
);
import { Document, Page, Text, PDFDownloadLink } from 'preact-pdf';

const MyDoc = () => (
  <Document>
    <Page>
      <Text>Hello, World</Text>
    </Page>
  </Document>
);

const App = () => (
  <PDFDownloadLink document={<MyDoc />} fileName="document.pdf">
    {({ loading }) => (loading ? 'Loading document...' : 'Download now!')}
  </PDFDownloadLink>
);

Components

The library exports the following components:

  • Document - The root component for a PDF document
  • Page - Represents a page in the PDF document
  • View - A container for other components
  • Text - For displaying text
  • Image - For displaying images
  • Link - For creating hyperlinks
  • Note - For adding notes to the PDF
  • Svg - Container for SVG elements
  • Rect, Circle, Line, Path, G, LinearGradient, Stop, Defs - SVG elements
  • PDFViewer - Component for previewing the PDF in the browser
  • BlobProvider - Component to get the blob of the PDF

The props of these components are basically the same as the component props in @react-pdf/renderer. You can refer to components and svg

Keywords

pdf

FAQs

Package last updated on 28 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts