Somebody please help!!!! =.... (
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.status == 'complete' && tab.url != undefined)
{
chrome.debugger.attach({tabId:tabId}, "1.2", function(){
chrome.debugger.sendCommand({tabId:tabId}, "Page.printToPDF", {}, function(blahs){
console.log(blahs);
});
});
}
});
I've tried everything I can think of to get this to work. I even launched 10 different versions of chrome ranging from version 52 to 68, restricting auto update using group policies.
If chrome accepts the command it returns the following: Unchecked runtime.lastError: {"code":-32000,"message":"PrintToPDF is not implemented"}
headless wont accept the paramters I want to use which are the following:
- landscape
- booleanPaper orientation. Defaults to false.
- displayHeaderFooter
- booleanDisplay header and footer. Defaults to false.
- printBackground
- booleanPrint background graphics. Defaults to false.
- scale
- numberScale of the webpage rendering. Defaults to 1.
- paperWidth
- numberPaper width in inches. Defaults to 8.5 inches.
- paperHeight
- numberPaper height in inches. Defaults to 11 inches.
- marginTop
- numberTop margin in inches. Defaults to 1cm (~0.4 inches).
- marginBottom
- numberBottom margin in inches. Defaults to 1cm (~0.4 inches).
- marginLeft
- numberLeft margin in inches. Defaults to 1cm (~0.4 inches).
- marginRight
- numberRight margin in inches. Defaults to 1cm (~0.4 inches).
- pageRanges
- stringPaper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
- ignoreInvalidPageRanges
- booleanWhether to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false.
- headerTemplate
- stringHTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:
date
: formatted print datetitle
: document titleurl
: document locationpageNumber
: current page numbertotalPages
: total pages in the document
For example, <span class=title></span>
would generate span containing the title.
- footerTemplate
- stringHTML template for the print footer. Should use the same format as the
headerTemplate
.
- preferCSSPageSize
- booleanWhether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.