Skip to content

Commit

Permalink
Feature: printToPDFTimeout (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphox authored Feb 18, 2022
1 parent 1549aa6 commit e3bb4a3
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 95 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
Dhalang (0.6.2)
Dhalang (0.6.4)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -35,6 +35,7 @@ GEM
ttfunk (1.7.0)

PLATFORMS
arm64-darwin-21
x86-mingw32

DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Below table lists all possible configuration parameters that can be set:
| Key | Description | Default |
|--------------------|-----------------------------------------------------------------------------------------|---------------------------------|
| navigationTimeout | Amount of milliseconds until Puppeteer while timeout when navigating to the given page | 10000 |
| printToPDFTimeout | Amount of milliseconds until Puppeteer while timeout when calling Page.printToPDF | 0 (unlimited) |
| navigationWaitForSelector | If set, Dhalang will wait for the specified selector to appear before creating the screenshot or PDF | None |
| navigationWaitForXPath | If set, Dhalang will wait for the specified XPath to appear before creating the screenshot or PDF | None |
| userAgent | User agent to send with the request | Default Puppeteer one |
Expand Down
21 changes: 11 additions & 10 deletions lib/Dhalang/puppeteer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ class Puppeteer
private_constant :NODE_MODULES_PATH

USER_OPTIONS = {
navigationTimeout: 10000,
navigationWaitUntil: 'load',
navigationWaitForSelector: '',
navigationWaitForXPath: '',
userAgent: '',
isHeadless: true,
viewPort: '',
httpAuthenticationCredentials: '',
isAutoHeight: false,
chromeOptions: []
navigationTimeout: 10000,
printToPDFTimeout: 0, # unlimited
navigationWaitUntil: 'load',
navigationWaitForSelector: '',
navigationWaitForXPath: '',
userAgent: '',
isHeadless: true,
viewPort: '',
httpAuthenticationCredentials: '',
isAutoHeight: false,
chromeOptions: []
}
private_constant :USER_OPTIONS

Expand Down
2 changes: 1 addition & 1 deletion lib/Dhalang/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Dhalang
VERSION = "0.6.3"
VERSION = "0.6.4"
end
3 changes: 3 additions & 0 deletions lib/js/dhalang.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ exports.getConfiguredPdfOptions = async function (page, configuration) {
// ignoring file related errors
}
}

if (pdfOptions['footerTemplateFile'] !== '') {
try {
pdfOptions['footerTemplate'] = fs.readFileSync(pdfOptions['footerTemplateFile'], 'utf8')
Expand All @@ -133,6 +134,8 @@ exports.getConfiguredPdfOptions = async function (page, configuration) {
}
}

pdfOptions['timeout'] = configuration.userOptions.printToPDFTimeout

return pdfOptions
}

Expand Down
Loading

0 comments on commit e3bb4a3

Please sign in to comment.