@@ -190,32 +190,32 @@ async function task(url, imageName) {
190190 const browser = await puppeteer . launch ( ) ;
191191 const page = await browser . newPage ( ) ;
192192 await page . setViewport ( {
193- width : 2980 ,
194- height : 6880 ,
195- deviceScaleFactor : 0.5
193+ width : 1024 ,
194+ height : 1024 ,
195+ deviceScaleFactor : 1
196196 } ) ;
197197 await page . goto ( url , {
198198 waitUntil : 'load'
199199 } ) ;
200- // const placeholder = await page.$('#basicdiagram');
201- // const rect = await page.evaluate((placeholder) => {
202- // const { y, x, bottom, right } = placeholder.getBoundingClientRect();
203- // return {
204- // x: x + 1,
205- // y: y + 1,
206- // height: bottom - y - 2,
207- // width: right - x - 2
208- // };
209- // }, placeholder);
200+ const placeholder = await page . $ ( '#basicdiagram' ) ;
201+ const rect = await page . evaluate ( ( placeholder ) => {
202+ const { y, x, bottom, right } = placeholder . getBoundingClientRect ( ) ;
203+ return {
204+ x : x + 1 ,
205+ y : y + 1 ,
206+ height : bottom - y - 2 ,
207+ width : right - x - 2
208+ } ;
209+ } , placeholder ) ;
210210
211211 const screenshot = await page . screenshot ( {
212- fullPage : true
213- // clip: {
214- // x: rect.x,
215- // y: rect.y,
216- // width: rect.width,
217- // height: rect.height
218- // }
212+ // fullPage: true
213+ clip : {
214+ x : rect . x ,
215+ y : rect . y ,
216+ width : rect . width ,
217+ height : rect . height
218+ }
219219 } ) ;
220220 browser . close ( ) ;
221221 fs . writeFileSync ( './samples/images/screenshots/screenshot.png' , screenshot ) ;
@@ -246,7 +246,7 @@ async function task(url, imageName) {
246246
247247
248248async function process ( ) {
249- for ( var index = 0 ; index < screenshots . length && index < 1 ; index += 1 ) {
249+ for ( var index = 0 ; index < screenshots . length ; index += 1 ) {
250250 screenshot = screenshots [ index ] ;
251251 await task ( screenshot . url , screenshot . imageName ) ;
252252 } ;
0 commit comments