1.1.1 • Published 12 months ago
@component-hook/pdf-canvas v1.1.1
@component-hook/pdf-canvas
Rendering PDF documents onto a canvas with vue3 and react component.
Implementation depository: PDF-signature
Features
- Rendering PDF documents onto a canvas
- Open encrypted PDF files
- Drag and drop the images and text onto the canvas
- Manually add the images and text onto the canvas
- Full
TypeScriptsupport
Documentation
For detailed documentation and usage examples, please visit: Official Docs.
Installation
# Using npm
$ npm install @component-hook/pdf-canvas
# Using yarn
$ yarn add @component-hook/pdf-canvas
# Using pnpm
$ pnpm install @component-hook/pdf-canvasBase Usage
Vue3
<script setup lang="ts">
import PdfCanvas, { loadFile, type PDF } from '@component-hook/pdf-canvas/vue';
import { ref } from 'vue';
const currentPdf = ref<PDF>();
async function uploadFile(event: Event) {
const target = event.target as HTMLInputElement;
const { files } = target;
if (!files) return;
const file = files[0];
const content = await loadFile(file);
currentPdf.value = content;
target.value = '';
}
</script>
<template>
<div class="w-fit flex flex-col items-center gap-3">
<pdf-canvas
v-if="currentPdf"
:file="currentPdf"
/>
<p
v-else
class="font-mono text-sm"
>
Please select a PDF file or image.
</p>
<button class="relative">
<input
type="file"
accept="application/pdf, .jpg, .png"
class="opacity-0 top-0 left-0 absolute w-[94px] h-[36px] cursor-pointer"
@change="uploadFile"
/>
select file
</button>
</div>
</template>React
import PdfCanvas, { loadFile, type PDF } from '@component-hook/pdf-canvas/react';
import { useState, type ChangeEvent } from 'react';
export function DrawPdf() {
const [currentPdf, setCurrentPdf] = useState<PDF>();
const uploadFile = async (event: ChangeEvent<HTMLInputElement>) => {
const target = event.target;
const { files } = target;
if (!files || files.length === 0) return;
const file = files[0];
const content = await loadFile(file);
setCurrentPdf(content);
target.value = '';
};
return (
<div>
{currentPdf ? <PdfCanvas file={currentPdf} /> : <p>Please select a PDF file or image.</p>}
<button>
<input
type="file"
accept="application/pdf, .jpg, .png"
onChange={uploadFile}
/>
select file
</button>
</div>
);
}License
This project is licensed under the MIT License.
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago
1.1.0-alpha.11
1 year ago
1.1.0-alpha.10
1 year ago
1.1.0-alpha.12
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
0.2.1-alpha.0
1 year ago
1.1.1
12 months ago
1.1.0
1 year ago
1.0.5-alpha.0
1 year ago
1.0.5-alpha.2
1 year ago
1.0.5-alpha.1
1 year ago
0.2.0-alpha.0
1 year ago
0.2.0-alpha.1
1 year ago
1.0.5-alpha.4
1 year ago
1.0.5-alpha.3
1 year ago
1.1.0-alpha.9
1 year ago
1.1.0-alpha.7
1 year ago
1.1.0-alpha.8
1 year ago
1.1.0-alpha.1
1 year ago
1.1.0-alpha.2
1 year ago
0.2.1
1 year ago
1.1.0-alpha.0
1 year ago
0.2.0
1 year ago
1.1.0-alpha.5
1 year ago
1.1.0-alpha.6
1 year ago
1.1.0-alpha.3
1 year ago
1.1.0-alpha.4
1 year ago
0.2.3
1 year ago
0.2.2
1 year ago
0.2.5
1 year ago
0.2.4
1 year ago
0.1.6
2 years ago
0.1.5
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.3-alpha.8
2 years ago
0.1.3-alpha.7
2 years ago
0.1.3-alpha.6
2 years ago
0.1.3-alpha.5
2 years ago
0.1.3-alpha.4
2 years ago
0.1.3-alpha.3
2 years ago
0.1.3-alpha.2
2 years ago
0.1.3-alpha.1
2 years ago
0.1.3-alpha.0
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago