File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ async function convertPDFToText(file: File): Promise<string> {
189189async function convertPDFToImage ( file : File ) : Promise < string [ ] > {
190190 const buffer = await getFileAsBuffer ( file ) ;
191191 const doc = await pdfjs . getDocument ( buffer ) . promise ;
192- const pages : string [ ] = [ ] ;
192+ const pages : Promise < string > [ ] = [ ] ;
193193
194194 for ( let i = 1 ; i <= doc . numPages ; i ++ ) {
195195 const page = await doc . getPage ( i ) ;
@@ -202,12 +202,14 @@ async function convertPDFToImage(file: File): Promise<string[]> {
202202 throw new Error ( 'Failed to get 2D context from canvas' ) ;
203203 }
204204 const task = page . render ( { canvasContext : ctx , viewport : viewport } ) ;
205- task . promise . then ( ( ) => {
206- pages . push ( canvas . toDataURL ( ) ) ;
207- } ) ;
205+ pages . push (
206+ task . promise . then ( ( ) => {
207+ return canvas . toDataURL ( ) ;
208+ } )
209+ ) ;
208210 }
209211
210- return pages ;
212+ return await Promise . all ( pages ) ;
211213}
212214
213215// WARN: vibe code below
You can’t perform that action at this time.
0 commit comments