File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 22
33import { launch , LaunchedChrome } from 'chrome-launcher' ;
44import * as CDP from 'chrome-remote-interface' ;
5+ import { Readable , Stream } from 'stream' ;
56
67import { ChromePrintOptions } from './ChromePrintOptions' ;
78import * as CompletionTrigger from './CompletionTrigger' ;
@@ -86,6 +87,20 @@ async function generate(html: string, options: CreateOptions): Promise<CreateRes
8687 }
8788}
8889
90+ function generateToStream ( html : string , options : CreateOptions ) : Stream {
91+ const stream = new Readable ( ) ;
92+ ( async ( ) => {
93+ try {
94+ const result = await generate ( html , options ) ;
95+ stream . push ( result . toBase64 ( ) , 'base64' ) ;
96+ stream . push ( null ) ;
97+ } catch ( e ) {
98+ stream . emit ( 'error' , e ) ;
99+ }
100+ } ) ( ) ;
101+ return stream ;
102+ }
103+
89104/**
90105 * Throws an exception if the operation has been canceled.
91106 *
You can’t perform that action at this time.
0 commit comments