Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
fge-pdf-vue3
Advanced tools
Vue 3 PDF Viso Pdf baso en Mozilla's PDFJS. Forked from https://github.com/sandanat/vue-pdf-app.
100% PDFJS Funcionalidades:
npm install fge-pdf-vue3
<template>
<fge-pdf-vue3
style="height: 100vh;"
:viewButton="viewButton"
:viewSignature="viewSignature"
:signature="signature"
:page-number="1"
file-name="Custom fileName"
v-model:files="files"
:footer-text="'Copyright © MINISTERIO PÚBLICO DE BOLIVIA'"
:footer-visible="true"
:token="token"
:theme="'light'"
:buttonDeleteFile="buttonDeleteFile"
></fge-pdf-vue3>
</template>
<script>
import FgePdfVue3 from "fge-pdf-vue3";
import "vue3-pdf-app/dist/icons/main.css";
export default {
components: {
FgePdfVue3
},
data(){
// token generado por el servicio de seguridad
const token ="********";
const files = ref([
{
// id del archivo al cual se va dar el valor legal
id: "6359b8a82736f8d11cd61190",
// nombre del archivo
fileName: "prueba-fuego.pdf",
// pdf: puede ser url, base64 o ArrayBuffer, dato solo usado para renderizar en el visor pdf
pdf: "https://www.africau.edu/images/default/sample.pdf",
},
]);
return {
// token requerido para firmar, aprobar o visualizar el valor legal del documento
token,
// listado de archivos que se visualizaran en el visor pdf
files,
// botón para quitar o eliminar un archivo del listado
buttonDeleteFile: false,
// variables para ocultar botones del toolbar
viewButton: {
print: true,
openFile: false,
presentationMode: true,
download: true,
bookmark: true,
files: true,
},
// variables usadas para visualizar el valor legal del documento
viewSignature: {
adsib: true,
agetic: true,
},
// variables usadas para firmar todos los documentos o aprobar el documento actual
signature: {
adsib: true,
agetic: true,
},
// opciones de configuracion para ocultar o visualizar
config: {
toolbar: true,
sidebar: true,
},
scale: "1",
};
}
};
</script>
{ id:string; fileName:string; pdf: string | ArrayBuffer | TypedArray}[]
true
[]
<vue-pdf-app files="https://example.com/sample.pdf" />
signature
Atributo usado para visualizar el valor legal documento.{ agetic: boolean; adsib: boolean}
false
{ agetic: false, adsib: false}
<vue-pdf-app :signature="{ agetic: false, adsib: false}" />
viewSignature
Atributo usado visualizar el valor legal de los documentos.{ agetic: boolean; adsib: boolean}
false
{ agetic: false, adsib: false}
<vue-pdf-app :viewSignature="{ agetic: false, adsib: false}" />
enableInformationFile
Atributo usado para obtener la descripción de los documentos desde el servidor.boolean
false
false
<vue-pdf-app :enableInformationFile="false" />
viewButton
Atributo usado ocultar botones.{ print: boolean, openFile: false, presentationMode: false, download: false, bookmark: false, files: false}
false
{ print: false, openFile: false, presentationMode: false, download: false, bookmark: false, files: false,}
<vue-pdf-app :viewSignature="{ agetic: false, adsib: false}" />
true
renames document title to pdf file name.boolean
false
false
<vue-pdf-app :title="true" />
token
usado para visualizar y dar valor a los documentos.string
false
''
<vue-pdf-app :token="'****'" />
msAdsib
usado para visualizar y dar valor a los documentos mediante la ADSIB.string
false
''
<vue-pdf-app :msAdsib="'****'" />
disableButtonSignAutomatic
usado para desactivar botones para dar valor legal a los documentos si ya cuentan con algún valor legal.boolean
false
true
<vue-pdf-app :disableButtonSignAutomatic="true" />
msSeguridad
usado para visualizar valor legal mediante la AGETIC.string
false
''
<vue-pdf-app :msSeguridad="'****'" />
footerText
usado para remplazar el texto del footer.string
false
Copyright © FgePdfVue 2023
<vue-pdf-app :footerText="'Copyright © FgePdfVue 2023'" />
footerVisible
usado para remplazar el texto del footer.boolean
false
false
<vue-pdf-app :footerVisible="false" />
toastEnabled
usado para mostrar los mensajes de respuestas cuando se realiza una aprobacion o firma del documento o cuando ocurre algun error.boolean
false
true
<vue-pdf-app :toastEnabled="true" />
"dark" | "light"
false
<vue-pdf-app theme="dark" />
<vue-pdf-app :theme="theme" />
<vue-pdf-app :theme.sync="theme" />
number | "page-actual"| "page-width"| "page-height"| "page-fit"| "auto"
false
// 20%
<vue-pdf-app page-scale="20" />
<vue-pdf-app :page-scale="20" />
<vue-pdf-app :page-scale="page-actual" />
window.localStorage.getItem("pdfjs.history")
. Specify the prop to override it.number
false
<vue-pdf-app :page-number="1" />
false
for buttons or whole group of buttons to disable them.toolbar config (see below)
false
toolbar config
<vue-pdf-app :config="config" />
<script>
export default {
data() {
return {
// disable "Previous page" button
config: {
toolbar: {
toolbarViewerLeft: {
previous: false
}
}
},
// disable whole page navigation panel
config2: {
toolbar: {
toolbarViewerLeft: false
}
},
// disable whole panel
config3: {
toolbar: false
}
};
}
};
</script>
{
sidebar: {
viewThumbnail: true,
viewOutline: true,
viewAttachments: true,
},
secondaryToolbar: {
secondaryPresentationMode: true,
secondaryOpenFile: true,
secondaryPrint: true,
secondaryDownload: true,
secondaryViewBookmark: true,
firstPage: true,
lastPage: true,
pageRotateCw: true,
pageRotateCcw: true,
cursorSelectTool: true,
cursorHandTool: true,
scrollVertical: true,
scrollHorizontal: true,
scrollWrapped: true,
spreadNone: true,
spreadOdd: true,
spreadEven: true,
documentProperties: true,
},
toolbar: {
toolbarViewerLeft: {
findbar: true,
previous: true,
next: true,
pageNumber: true,
},
toolbarViewerRight: {
presentationMode: true,
openFile: true,
print: true,
download: true,
viewBookmark: true,
},
toolbarViewerMiddle: {
zoomOut: true,
zoomIn: true,
scaleSelectContainer: true,
},
},
errorWrapper: true,
};
disabled
attribute of a button but it won't if a div is used instead of a button). So it is better to use native HTML element specified as recommended in ID config specification below. Four slots are specially designed to build custom toolbar (are situated near a pdf page): viewer-header, viewer-prepend, viewer-append, viewer-footer
(refer slots API). It is also possible to use other slots or elements outside vue-pdf-app.ID config (see below)
false
<template>
<div>
<button :id="idConfig.zoomOut" type="button">Zoom out</button>
<vue-pdf-app :id-config="idConfig">
<template #viewer-prepend>
<div class="viewer-prepend">
<button :id="idConfig.zoomIn" type="button">Zoom in</button>
</div>
</template>
</vue-pdf-app>
</div>
</template>
<script>
export default {
data() {
return {
idConfig: { zoomIn: "zoomInId", zoomOut: "zoomOutId" }
};
}
};
</script>
{
cursorHandTool?: string; // <button> is recommended
cursorSelectTool?: string; // <button> is recommended
documentProperties?: string; // <button> is recommended
download?: string; // <button> is recommended
findbar?: string; // <div> is recommended
findEntireWord?: string; // <input type="checkbox"> is recommended
findHighlightAll?: string; // <input type="checkbox"> is recommended
findMessage?: string; // <span> is recommended
findInput?: string; // <input type="text"> is recommended
findMatchCase?: string; // <input type="checkbox"> is recommended
findNext?: string; // <button> is recommended
findPrevious?: string; // <button> is recommended
findResultsCount?: string; // <span> is recommended
firstPage?: string; // <button> is recommended
lastPage?: string; // <button> is recommended
nextPage?: string; // <button> is recommended
numPages?: string; // total pages qty. <span> is recommended
openFile?: string; // <button> is recommended
pageNumber?: string; // input for page number. <input type="number"> is recommended
pageRotateCcw?: string; // <button> is recommended
pageRotateCw?: string; // <button> is recommended
presentationMode?: string; // <button> is recommended
previousPage?: string; // <button> is recommended
print?: string; // <button> is recommended
scrollHorizontal?: string; // <button> is recommended
scrollVertical?: string; // <button> is recommended
scrollWrapped?: string; // <button> is recommended
sidebarToggle?: string; // <button> is recommended
spreadEven?: string; // <button> is recommended
spreadNone?: string; // <button> is recommended
spreadOdd?: string; // <button> is recommended
toggleFindbar?: string; // <button> is recommended
viewAttachments?: string; // <button> is recommended
viewBookmark?: string; // <a> tag is recommended
viewOutline?: string; // <button> tag is recommended
viewThumbnail?: string; // <button> tag is recommended
zoomIn?: string; // <button> tag is recommended
zoomOut?: string; // <button> tag is recommended
}
ℹ️ Note that elements must be in HTML document by the time vue-pdf-app is mounting (use
v-show
instead ofv-if
directive if necessary). Otherwise an error occurs.
<vue-pdf-app @after-created="afterCreated" />
<vue-pdf-app @open="openHandler" />
<vue-pdf-app @pages-rendered="pagesRendered" />
<script>
export default {
methods: {
pagesRendered(pdfApp) {
setTimeout(() => (pdfApp.pdfViewer.currentScaleValue = "page-height"));
}
}
};
</script>
<fge-pdf-app @fileSign="event" />
<script>
export default {
methods: {
event(pdfApp) {
console.log(pdfApp)
}
}
};
</script>
<fge-pdf-app @fileApprove="event" />
<script>
export default {
methods: {
event(pdfApp) {
console.log(pdfApp)
}
}
};
</script>
<fge-pdf-app @deleteFile="event" />
<script>
export default {
methods: {
event(pdfApp) {
console.log(pdfApp)
}
}
};
</script>
ℹ️ Events are triggered in the following order
after-created (once) => open => pages-rendered
viewer-prepend
slot. Can be used to build custom toolbar.viewerContainer
div. Can be used to build custom toolbar.viewerContainer
div. Can be used to build custom toolbar.viewer-append
slot. Can be used to build custom toolbar.Each slot has props:
toggleTheme
Type: (): void.
Description: toggle theme handler
isSidebarHidden
Type: boolean
Description: state of a sidebar (visible or hidden). Can be used to manage visibility of custom Attachments, Outline and Thumbnail buttons
Type: boolean
Description: state of a findbar (visible or hidden). Can be used to manage visibility of custom findbar
<vue-pdf-app>
<template #toolbar-left-prepend="{ toggleTheme }">
<button @click="toggleTheme" type="button">Toggle theme</button>
</template>
</vue-pdf-app>
Colors of the pdf viewer are customized via custom css properties:
<style>
/* for dark theme */
.pdf-app.dark {
--pdf-toolbar-color: black;
}
/* for light theme */
.pdf-app.light {
--pdf-toolbar-color: white;
}
</style>
Property | Applied to selectors | Description |
---|---|---|
--pdf-app-background-color | .pdf-app | Background color for root pdf container |
--pdf-button-hover-font-color |
.pdf-app .toolbarButton:hover
.pdf-app .toolbarButton:focus .pdf-app .dropdownToolbarButton:hover .pdf-app .secondaryToolbarButton:hover .pdf-app .secondaryToolbarButton:focus | Hover color for buttons of toolbar and secondary toolbar |
--pdf-button-toggled-color |
.pdf-app .toolbarButton.toggled
.pdf-app .splitToolbarButton.toggled > .toolbarButton.toggled .pdf-app .secondaryToolbarButton.toggled .pdf-app .outlineItemToggler:hover .pdf-app .outlineItemToggler:hover + a .pdf-app .outlineItemToggler:hover ~ .outlineItems .pdf-app .outlineItem > a:hover .pdf-app .attachmentsItem > button:hover | Background color for toggleable buttons when selected, outline items on hover, attachment items on hover |
--pdf-dialog-button-color | .pdf-app .dialog .overlayButton | |
--pdf-dialog-button-font-color | .pdf-app .dialog .overlayButton | |
--pdf-error-more-info-color | .pdf-app #errorMoreInfo | |
--pdf-error-more-info-font-color | .pdf-app #errorMoreInfo | |
--pdf-error-wrapper-color | .pdf-app #errorWrapper | |
--pdf-find-input-placeholder-font-color | .pdf-app #findInput::placeholder | |
--pdf-find-message-font-color | .pdf-app #findMsg | |
--pdf-find-results-count-color | .pdf-app #findResultsCount | |
--pdf-find-results-count-font-color | .pdf-app #findResultsCount | |
--pdf-horizontal-toolbar-separator-color | .pdf-app .horizontalToolbarSeparator | |
--pdf-input-color | .pdf-app .toolbarField | |
--pdf-input-font-color | .pdf-app .toolbarField | |
--pdf-loading-bar-color | .pdf-app #loadingBar .progress | |
--pdf-loading-bar-secondary-color | .pdf-app #loadingBar .progress.indeterminate .glimmer | |
--pdf-not-found-color | .pdf-app #findInput.notFound | |
--pdf-overlay-container-color | .pdf-app #overlayContainer | Background color for overlay container of dialogs |
--pdf-overlay-container-dialog-color | .pdf-app #overlayContainer > .container > .dialog | Background color for document properties, password, print dialogs |
--pdf-overlay-container-dialog-font-color | .pdf-app #overlayContainer > .container > .dialog | Font color for document properties, password, print dialogs |
--pdf-overlay-container-dialog-separator-color | .pdf-app .dialog .separator | |
--pdf-sidebar-content-color | .pdf-app #sidebarContent | Background color for sidebar |
--pdf-split-toolbar-button-separator-color |
.pdf-app .splitToolbarButtonSeparator
.pdf-app .verticalToolbarSeparator | |
--pdf-thumbnail-selection-ring-selected-color | .pdf-app .thumbnail.selected > .thumbnailSelectionRing | Border color for selected thumbnail |
--pdf-thumbnail-selection-ring-color |
.pdf-app a:focus > .thumbnail > .thumbnailSelectionRing
.pdf-app .thumbnail:hover > .thumbnailSelectionRing | Border color for thumbnail on hover and focus |
--pdf-toolbar-color |
.pdf-app #toolbarContainer
.pdf-app .findbar .pdf-app .secondaryToolbar .pdf-app .doorHanger:after .pdf-app .doorHangerRight:after .pdf-app .dropdownToolbarButton > select .pdf-app .dropdownToolbarButton > select > option | Background color for toolbar, findbar, secondary toolbar, page scale dropdown |
--pdf-toolbar-font-color |
.pdf-app .toolbarButton
.pdf-app .dropdownToolbarButton .pdf-app .secondaryToolbarButton .pdf-app .dropdownToolbarButton > select .pdf-app .toolbarLabel .pdf-app .outlineItem > a .pdf-app .attachmentsItem > button | Font color for toolbar, findbar, secondary toolbar, page scale dropdown, attachments name |
--pdf-toolbar-sidebar-color | .pdf-app #toolbarSidebar |
To use default icons import "vue3-pdf-app/dist/icons/main.css";
.
To use custom icons you have to implement icons.css:
.vue-pdf-app-icon::before,
.vue-pdf-app-icon::after {
font-family: "your font family";
}
.vue-pdf-app-icon.zoom-out::before {
content: "icon code";
}
Toggle theme button is not implemented by default. It's up to you to decide where to place it. The button can be implemented with slots:
<vue-pdf-app>
<template #footer="{ toggleTheme }">
<button @click="toggleTheme" type="button">Toggle theme</button>
</template>
</vue-pdf-app>
English is the default language for panel.
Use <link rel="resource" type="application/l10n" href="path-to-localization-file">
in your html for localization.
See localization file examples.
PDFJS is a huge package (see the library size table above). So use lazy loading to split your bundle into small pieces.
<template>
<div id="app">
<vue-pdf-app></vue-pdf-app>
</div>
</template>
<script>
import "vue3-pdf-app/dist/icons/main.css";
import Loader from "./components/Loader.vue";
export default {
name: "App",
components: {
"vue-pdf-app": () => ({
component: new Promise((res) => {
return setTimeout(
() => res(import(/* webpackChunkName: "pdf-viewer" */ "vue-pdf-app")),
4000
);
}),
loading: Loader
})
}
};
</script>
You can interact with pdfjs library when pdf is opened via open
event.
<template>
<div id="app">
<div id="pdf-wrapper">
<vue-pdf-app pdf="/sample.pdf" @open="openHandler"></vue-pdf-app>
</div>
<div id="info">
<h1>PDF info:</h1>
<div v-for="item in info" :key="item.name">
<span>{{ item.name }}: {{ item.value }}</span>
<br />
</div>
</div>
</div>
</template>
<script>
import "vue3-pdf-app/dist/icons/main.css";
import VuePdfApp from "vue3-pdf-app";
export default {
name: "App",
components: {
VuePdfApp
},
data() {
return {
info: []
};
},
methods: {
async openHandler(pdfApp) {
this.info = [];
const info = await pdfApp.pdfDocument
.getMetadata()
.catch(console.error.bind(console));
if (!info) return;
const props = Object.keys(info.info);
props.forEach((prop) => {
const obj = {
name: prop,
value: info.info[prop]
};
this.info.push(obj);
});
}
}
};
</script>
FAQs
Vue 3 PDF viewer
The npm package fge-pdf-vue3 receives a total of 12 weekly downloads. As such, fge-pdf-vue3 popularity was classified as not popular.
We found that fge-pdf-vue3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.