Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ https://www.npmjs.com/package/@libresign/vue-pdf-editor
:show-line-size-select = 'false' <!--Select the default TRUE of the line spacing-->
:show-font-size-select= 'false' <!--Select the default TRue-->
:show-font-select="false" <!--Select the default true font-->
:show-rename="true" <!--Show the rename column default TRUE-->
:show-rename="true" <!--Show the rename column default TRUE (hidden when multiple PDFs)-->
:show-save-btn="false" <!--Show the saving button default TRUE-->
:save-to-upload="true" <!--False directly download; TRUE trigger onsave2upload event default FALSe->
:init-file-src="'【pdf url】'" <!--Initialization file address-->
:init-file=File <!--Initialization file object (supports multiple PDFs when using show-choose-file-btn)-->
:init-file-name="initFileName" <!--Initialized file name-->
:init-files="[File, File, ...]" <!--Array of File objects to initialize with-->
:init-file-names="['name1.pdf', 'name2.pdf', ...]" <!--Array of file names corresponding to initFiles-->
:init-text-fields = "【text array】" <!--Initialized text array-->
:init-image-urls = "【image url array】" <!--Initialized picture array-->
:init-image-scale = "0.2" <!--The zoom level of the initialized picture defaults to 0.2 times the original size-->
Expand Down
8 changes: 4 additions & 4 deletions examples/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
:show-font-select="true"
:show-rename="true"
:show-save-btn="true"
:init-file-src="initFile"
:init-file-name="initFileName"
:init-files="initFiles"
:init-file-names="initFileNames"
:init-text-fields = "this.textFields"
:init-image-urls = "this.imageUrls"
:init-image-scale = "1"
Expand All @@ -37,8 +37,8 @@ export default {
name: 'App',
data(){
return {
initFileName: 'test.pdf',
initFile :'',
initFileNames: ['test.pdf'],
initFiles: [],
textFields: ['initial text'],
imageUrls: [],
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@libresign/vue-pdf-editor",
"description": "vue2 pdf editor component",
"version": "1.6.2",
"version": "1.6.3",
"author": "LibreCode",
"private": false,
"main": "dist/vue-pdf-editor.umd.js",
Expand Down
33 changes: 16 additions & 17 deletions src/VuePdfEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,13 @@ export default {
type: Boolean,
default: false,
},
initFileSrc: {
type: String,
default: '',
},
initFile: {
type: [File, Blob, ArrayBuffer],
default: null,
initFiles: {
type: Array,
default: () => [],
},
initFileName: {
type: String,
default: '',
initFileNames: {
type: Array,
default: () => [],
},
initTextFields: {
type: Array,
Expand Down Expand Up @@ -415,13 +411,16 @@ export default {
this.scale = parseFloat((this.scale - 0.1).toFixed(1))
},
async init() {
const file = this.initFile || this.initFileSrc
if (!file) {
console.log('init file is not exist')
if (this.initFiles.length === 0) {
console.log('init files do not exist')
return
}

try {
await this.addPDF(file)
for (let i = 0; i < this.initFiles.length; i++) {
const fileName = this.initFileNames[i] || ''
await this.addPDF(this.initFiles[i], fileName)
}
this.selectedDocIndex = 0
this.selectedPageIndex = 0
fetchFont(this.currentFont)
Expand Down Expand Up @@ -609,7 +608,7 @@ export default {
this.pdfDocuments = []
this.selectedDocIndex = -1
},
async addPDF(file) {
async addPDF(file, fileName = '') {
try {
// Don't reset if we're adding to existing documents
if (this.pdfDocuments.length === 0) {
Expand All @@ -618,8 +617,8 @@ export default {

const originalFile = file
let pdfName = ''
if (this.initFileName && this.pdfDocuments.length === 0) {
pdfName = this.initFileName
if (fileName) {
pdfName = fileName
} else if (file instanceof File && file.name) {
pdfName = file.name
} else {
Expand Down