adri-glez / filepond-plugin-pdf-preview Goto Github PK
View Code? Open in Web Editor NEWShow a preview for PDFs dropped on FilePond
License: MIT License
Show a preview for PDFs dropped on FilePond
License: MIT License
Hi guys,
Not really an issue but more a question regarding pdfComponentExtraParams
correct usage.
I'm trying to display PDF in a filepond instance.
I'm working on Vue2 with the following dependencies
"filepond": "^4.30.4"
"filepond-plugin-pdf-preview": "^1.0.4"
In a page component I setup the filepond as follows :
<setup>
...
// Import FilePond component
import vueFilePond, { setOptions } from "vue-filepond";
// Import FilePond styles
import "filepond/dist/filepond.min.css";
// Import FilePond plugins
import "filepond-plugin-pdf-preview/dist/filepond-plugin-pdf-preview.css";
// Create filepond
const FilePond = vueFilePond(FilePondPluginPdfPreview);
setOptions({
allowPdfPreview: true,
pdfComponentExtraParams: 'toolbar=0&view=fit&page=1'
});
...
</setup>
Also I want 3 PDF inlines so :
<style>
.filepond--item {width: calc(33% - 0.5em);}
</style>
Now the problem I'm having is the following with Firefox and Internet Explorer : the view=fit doesn't work.
Firefox (don't see the bottom of the PDF)
Microsoft Edge (I don't see much of the PDF)
And what I'd like is to have the exact same result as the one obtained in Chrome
Am I doing something wrong ?
$ npm install adriglez/filepond-plugin-pdf-preview
npm ERR! code 128
npm ERR! command failed
npm ERR! command git ls-remote ssh://[email protected]/adriglez/filepond-plugin-pdf-preview.git
npm ERR! ERROR: Repository not found.
npm ERR! fatal: Could not read from remote repository.
Describe the bug
Using vue-filepond with the pdf preview plugin, sometimes the stacktraced error occurs on route change.
To Reproduce
Expected behavior
No console TypeError.
Stacktraces
Uncaught TypeError: Cannot read property 'file' of null
at filepond-plugin-pdf-preview.js:181
at filepond.js:1445
at filepond.js:1096
at Array.forEach (<anonymous>)
at Object._write (filepond.js:1095)
at filepond.js:1125
at Array.forEach (<anonymous>)
at Object._write (filepond.js:1123)
at filepond.js:1125
at Array.forEach (<anonymous>)
Information about your project:
Windows 10
Google Chrome - Version 89.0.4389.90 (64-Bit)
"filepond": "^4.21.1"
"filepond-plugin-file-encode": "^2.1.9"
"filepond-plugin-image-preview": "^4.6.4"
"filepond-plugin-file-validate-type": "^1.2.6"
"filepond-plugin-image-transform": "^3.7.6"
"filepond-plugin-pdf-preview": "^1.0.2"
"filepond-plugin-file-validate-size": "^2.2.4"
"vue-filepond": "^6.0.3"
Additional context
I tried "resolving/catching" this error in the beforeDestroy() life-cycle hook of the component holding vue-filepond, but the this.$refs is already undefined at that point.
Hello @Adri-Glez , thank you for sharing this plugin!
I'm glad I read the README document and started using it and it worked, but I have a problem:
my PDF preview page does not show the full-screen button, unlike your recDemoPdfFullPage2.gif in the README document.
How do I set the full-screen button to show?
My operating environment: macOS,Chrome lasted Version
Looking forward to your reply, thank you!
Hi,
Any way you could add the typescript definition to the package?
It should be very straightforward with rollup
When I upload a PDF file, I get a preview of the entire pdf file, is there a way in which I can get a preview of just 1st page.
When using the default minified css style (from the CDN), the preview seems to work fine, and also the name of the file and the "Uploading xx%" and later the "Upload complete" messages. But the green overlay that appears when a file is correctly uploaded does not appear in the previewed PDF, even though it seems to work fine on the image preview.
Here is my CSS section:
<!-- Filepond -->
<link href="https://unpkg.com/filepond@^4/dist/filepond.css" rel="stylesheet" />
<link
href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css"
rel="stylesheet"
/>
<link href="https://unpkg.com/filepond-plugin-pdf-preview/dist/filepond-plugin-pdf-preview.min.css" rel="stylesheet">
<style>
/**
* FilePond Custom Styles
*/
.filepond--drop-label {
color: #4c4e53;
}
.filepond--label-action {
text-decoration-color: #babdc0;
}
.filepond--panel-root {
border-radius: 2em;
background-color: #edf0f4;
height: 1em;
}
.filepond--item-panel {
background-color: #595e68;
}
.filepond--drip-blob {
background-color: #7f8a9a;
}
/**
* Page Styles
*/
html {
padding:30vh 0 0;
}
body {
max-width: 20em;
margin: 0 auto;
}
</style>
I have these Javascripts:
<script src="https://unpkg.com/filepond@^4/dist/filepond.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-encode/dist/filepond-plugin-file-encode.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-validate-size/dist/filepond-plugin-file-validate-size.js"></script>
<script src="https://unpkg.com/filepond-plugin-image-exif-orientation/dist/filepond-plugin-image-exif-orientation.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-rename/dist/filepond-plugin-file-rename.js"></script>
<script src="https://unpkg.com/filepond-plugin-file-validate-type/dist/filepond-plugin-file-validate-type.js"></script>
<script src="https://unpkg.com/filepond-plugin-pdf-preview/dist/filepond-plugin-pdf-preview.min.js"></script>
This is the input component being called
<input type="file"
class="filepond"
name="filepond"
multiple
data-allow-reorder="true"
data-max-file-size="100MB"
data-max-files="20"
credits="false" />
And this is FilePond being initialized:
<script>
FilePond.registerPlugin(
// encodes the file as base64 data
FilePondPluginFileEncode,
// validates the size of the file
FilePondPluginFileValidateSize,
// corrects mobile image orientation
FilePondPluginImageExifOrientation,
// previews dropped images
FilePondPluginImagePreview,
// renames
FilePondPluginFileRename,
// Validates filetypes
FilePondPluginFileValidateType,
// Preview PDFs
FilePondPluginPdfPreview
);
FilePond.setOptions(
{
// FIXME Chunked upload are resulting in a HTTP 400 error
// chunkUploads: true,
// chunkSize: 50000,
server: {
url: 'http://localhost:8000/fp',
process: '/process/',
patch: '/patch/',
revert: '/revert/',
fetch: '/fetch/?target='
}
}
);
// Get a reference to the file input element
const inputElement = document.querySelector('input[type="file"]');
// Create a FilePond instance
const pond = FilePond.create(inputElement);
</script>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.