@@ -28,7 +28,9 @@ class Recipe {
28
28
this . src = src ;
29
29
// detect the src is Buffer or not
30
30
this . isBufferSrc = this . src instanceof Buffer ;
31
- this . isNewPDF = ! this . isBufferSrc && src . toLowerCase ( ) === "new" ;
31
+ this . isNewPDF =
32
+ ( ! this . isBufferSrc && src . toLowerCase ( ) === "new" ) ||
33
+ ( this . isBufferSrc && this . src . equals ( Buffer . from ( "new" ) ) ) ;
32
34
this . encryptOptions = this . _getEncryptOptions ( options , this . isNewPDF ) ;
33
35
this . options = Object . assign ( { } , options , this . encryptOptions ) ;
34
36
this . current = { } ;
@@ -75,12 +77,21 @@ class Recipe {
75
77
76
78
_createWriter ( ) {
77
79
if ( this . isNewPDF ) {
78
- this . writer = muhammara . createWriter (
79
- this . output ,
80
- Object . assign ( { } , this . encryptOptions , {
81
- version : this . _getVersion ( this . options . version ) ,
82
- } ) ,
83
- ) ;
80
+ if ( ! this . isBufferSrc ) {
81
+ this . writer = muhammara . createWriter (
82
+ this . output ,
83
+ Object . assign ( { } , this . encryptOptions , {
84
+ version : this . _getVersion ( this . options . version ) ,
85
+ } ) ,
86
+ ) ;
87
+ } else {
88
+ this . writer = muhammara . createWriter (
89
+ new muhammara . PDFStreamForResponse ( this . outStream ) ,
90
+ Object . assign ( { } , this . encryptOptions , {
91
+ log : this . logFile ,
92
+ } ) ,
93
+ ) ;
94
+ }
84
95
} else {
85
96
this . read ( ) ;
86
97
try {
0 commit comments