11const { PdfApi } = require ( "asposepdfcloud" ) ;
2- const { PdfAType } = require ( "asposepdfcloud/src/models/fieldType " ) ;
2+ const fs = require ( "fs " ) ;
33
4+ const api = new PdfApi ( "http://172.17.0.1:5000/v3.0" ) ;
45
6+ // The document name.
7+ const fileName = "PdfWithImages2.pdf" ;
8+ // Use default storage.
9+ const storage = null ;
10+ // Width of coverted image.
11+ const width = 100 ;
12+ // Heigth of coverted image.
13+ const heigth = 100 ;
14+ // Set document folder.
15+ const folder = "Documents" ;
16+ // Set extracted image folder.
17+ const destFolder = "testOutput" ;
518
6- pdfApi = new PdfApi ( "XXXX" , "XXXXXXX" )
19+ async function main ( )
20+ {
21+ // Read document images.
22+ const result = await api . getImages ( fileName , 1 , null , null ) ;
23+ const imageId = result . body . images . list [ 0 ] . id ;
24+ // Swagger method definition available at
25+ // https://reference.aspose.cloud/pdf/#/Images/GetImageExtractAsJpeg
26+ // Extract document image in PNG format.
27+ const response = await api . getImageExtractAsJpeg ( fileName , imageId , width , heigth , storage , folder ) ;
28+ if ( response . response . statusCode == 200 )
29+ {
30+ console . log ( "OK" ) ;
31+ // Write extracted image on disk.
32+ fs . writeFileSync ( destFolder + "/" + fileName + ".jpeg" , response . body ) ;
33+ }
34+ }
735
8- console . log ( 'running example' ) ;
9-
10- const result = await pdfApi . getImages ( "PdfWithImages2.pdf" , 1 , null , null ) ;
11- imageId = result . body . images . list [ 0 ] . id ;
12-
13- pdfApi . putImageExtractAsJpeg ( "PdfWithImages2.pdf" , imageId , null , null , null , null , null )
14- . then ( ( result ) => {
15- console . log ( result . response ) ;
16- } ) ;
36+ main ( ) ;
0 commit comments