savePDF
將目前瀏覽內容的頁面列印到您作業系統上的 PDF 檔案。
用法
browser.savePDF(filepath, { orientation, scale, background, width, height, top, bottom, left, right, shrinkToFit, pageRanges })
參數
名稱 | 類型 | 詳細資訊 |
---|---|---|
filepath | 字串 | 相對於執行目錄所產生 PDF 的路徑 (需要 .pdf 副檔名) |
options 選填 | PDFPrintOptions | 列印 PDF 選項 |
options.orientation 選填 | 字串 | PDF 頁面的方向 |
options.scale 選填 | 數字 | PDF 頁面的縮放比例 |
options.background 選填 | 布林值 | 包含 PDF 頁面的背景 |
options.width 選填 | 數字 | PDF 頁面的寬度 |
options.height 選填 | 數字 | PDF 頁面的高度 |
options.top 選填 | 數字 | PDF 頁面的頂部邊距 |
options.bottom 選填 | 數字 | PDF 頁面的底部邊距 |
options.left 選填 | 數字 | PDF 頁面的左側邊距 |
options.right 選填 | 數字 | PDF 頁面的右側邊距 |
options.shrinkToFit 選填 | 布林值 | 縮小頁面以符合頁面 |
options.pageRanges | 陣列[物件] | 要包含在 PDF 中的頁面範圍 |
範例
savePDF.js
it('should save a PDF screenshot of the browser view', function () {
await browser.savePDF('./some/path/screenshot.pdf');
});