1

私は印刷ボタンを持っていて、それをクリックすると何らかの要求を出して印刷ダイアログを開きます。これはURLから直接来るものではなく、デコードが容易ではありません。印刷ダイアログからpdfを保存するための人形をどうやって扱うことができますか?

例の印刷ダイアログ

Example print dialog

私は人形遣いを使用してPDFとしてこの文書を保存することができます方法はありますか?

既存のコード:

const puppeteer = require('puppeteer'); 

(async() => { 
    const browser = await puppeteer.launch(); 
    const page = await browser.newPage(); 
    await page.setViewport({width: 1440, height: 2000}); 
    await page.goto(`https://www.southwest.com/air/check-in/review.html?confirmationNumber=${process.argv[2]}&passengerFirstName=${process.argv[3]}&passengerLastName=${process.argv[4]}`, { 
    waitUntil: 'networkidle2' 
    }); 
    [ confirmationNumber, checkinButtonText ] = [ await page.$eval('.confirmation-number--code', el => el.innerHTML), await page.$eval('.actionable_primary.actionable_large-button', el => el.innerHTML) ] 
    console.log(checkinButtonText); 
    console.log(confirmationNumber); 
    await page.click('.actionable_primary.actionable_large-button'); 
    // The below line makes a click on the button 
    await page.click('.air-check-in-boarding-pass-options .boarding-pass-options--button-email, .air-check-in-boarding-pass-options .boarding-pass-options--button-print, .air-check-in-boarding-pass-options .boarding-pass-options--button-text'); 
    await browser.close(); 

})(); 
+0

あなたのコードとあなたの結果の一例を共有してください。 –

+0

更新されたコードを確認してください。以前の南西航空の航空券を持っていない限り、これはあなたを助けるとは思わない。 –

答えて

0

そのhereための.pdf APIがあります。

使用例:

await page.pdf({path: 'myTicket.pdf'}); 
関連する問題