@@ -377,7 +377,7 @@ export const usePDF: Callback<any> = () => {
377377 return { content, styles, base }
378378 }
379379
380- const doc = ( store : Store < any > ) => {
380+ const doc = ( store : Store < any > , options : Record < any , any > ) => {
381381 return {
382382 pageSize : generate ( ) . base ( store ) . pageSize ,
383383 pageOrientation : generate ( ) . base ( store ) . pageOrientation ,
@@ -400,23 +400,25 @@ export const usePDF: Callback<any> = () => {
400400 'heading-one' : generate ( ) . styles ( store ) . headingOne ( ) ,
401401 paragraph : generate ( ) . styles ( store ) . paragraph ( ) ,
402402 } ,
403- background : function ( currentPage : number ) {
404- return store . state . pdf . styles . switcher . main &&
405- store . state . pdf . styles . base . background . main &&
406- currentPage >= 3
407- ? [
408- {
409- image : store . state . pdf . styles . base . background . main ,
410- width : useDefines ( ) . pdf ( ) . base ( ) . pageSizeFixes ( ) [
411- store . state . pdf . styles . base . pageSize
412- ] [ 0 ] ,
413- height : useDefines ( ) . pdf ( ) . base ( ) . pageSizeFixes ( ) [
414- store . state . pdf . styles . base . pageSize
415- ] [ 1 ] ,
416- } ,
417- ]
418- : undefined
419- } ,
403+ background : options . final
404+ ? function ( currentPage : number ) {
405+ return currentPage >= 3 &&
406+ store . state . pdf . styles . base . background . main &&
407+ store . state . pdf . styles . switcher . main
408+ ? [
409+ {
410+ image : store . state . pdf . styles . base . background . main ,
411+ width : useDefines ( ) . pdf ( ) . base ( ) . pageSizeFixes ( ) [
412+ store . state . pdf . styles . base . pageSize
413+ ] [ 0 ] ,
414+ height : useDefines ( ) . pdf ( ) . base ( ) . pageSizeFixes ( ) [
415+ store . state . pdf . styles . base . pageSize
416+ ] [ 1 ] ,
417+ } ,
418+ ]
419+ : undefined
420+ }
421+ : undefined ,
420422 footer : function (
421423 currentPage : number ,
422424 pageCount : number ,
@@ -479,7 +481,7 @@ export const usePDF: Callback<any> = () => {
479481 const create : Callback < any > = ( store : Store < any > ) : void => {
480482 setVfsFonts ( store )
481483
482- const pdf = pdfMake . createPdf ( doc ( store ) )
484+ const pdf = pdfMake . createPdf ( doc ( store , { final : true } ) )
483485
484486 pdf . download ( `${ store . state . project . nameRaw } .pdf` , ( ) => {
485487 store . commit ( 'absolute/load' , false )
@@ -492,7 +494,7 @@ export const usePDF: Callback<any> = () => {
492494 ) : void => {
493495 setVfsFonts ( store )
494496
495- const generator = pdfMake . createPdf ( doc ( store ) )
497+ const generator = pdfMake . createPdf ( doc ( store , { final : false } ) )
496498
497499 generator . getDataUrl ( ( dataUrl : any ) => {
498500 const iframe = document . createElement ( 'iframe' )
0 commit comments