Closed westy92 closed 7 years ago
What if it's a remote chrome instance, though? How would you pass the temporary file?
This would only work for locally-running Chrome instances.
This is likely a better solution: https://github.com/cyrus-and/chrome-remote-interface/issues/95#issuecomment-293945313.
I believe this is blocked by https://github.com/ChromeDevTools/devtools-protocol/issues/13.
This does not appear to be an issue any longer. I was able to generate a 365 page PDF with the code below that used an HTML string composed of over over 2 million characters.
it('should generate from a lengthy HTML string', async () => {
const options: HtmlPdf.CreateOptions = {
port,
};
const filler = `
<p>
Bacon ipsum dolor amet fatback pastrami tongue short ribs jowl jerky meatloaf chuck pancetta pork pork loin tail cow brisket. Frankfurter chuck prosciutto tongue venison beef ribs filet mignon brisket turkey chicken hamburger ground round porchetta leberkas short ribs. Jerky doner ball tip, beef strip steak pancetta venison shankle boudin brisket. Rump leberkas biltong bresaola. Tongue burgdoggen strip steak beef ribs salami doner. Hamburger beef ribs shank, ribeye tail chuck pig turkey short loin shankle boudin cow. Cupim spare ribs turducken pastrami frankfurter jowl.
Shankle beef corned beef porchetta. Capicola kevin pork chop short ribs, ham hock pancetta shankle. Buffalo kielbasa turducken beef ribs tongue. Filet mignon kevin pork loin pastrami meatloaf. Alcatra sausage brisket burgdoggen flank filet mignon biltong short ribs pork chop jowl pork venison rump sirloin beef ribs.
Rump flank hamburger shank meatball alcatra ground round doner ham boudin. Beef pig pork chop bacon short loin ball tip rump, ground round frankfurter pork belly strip steak chicken landjaeger picanha. Ham frankfurter ball tip drumstick sausage doner salami. Venison alcatra kielbasa ribeye salami pork belly rump fatback cupim buffalo jerky pig bresaola. Picanha biltong brisket prosciutto hamburger kielbasa. Hamburger buffalo chuck spare ribs.
Strip steak short ribs bacon, hamburger drumstick tenderloin filet mignon ball tip. Jowl biltong tenderloin doner capicola, porchetta boudin pork loin prosciutto pastrami shankle pork belly. Short ribs t-bone capicola tail tri-tip turkey chicken pig fatback ham brisket bresaola. Jerky sausage tail, venison spare ribs prosciutto meatloaf beef ribs swine shoulder tri-tip sirloin salami cupim.
Capicola drumstick kielbasa pork jerky. Brisket chicken kielbasa salami flank short ribs, venison prosciutto swine bresaola ham spare ribs buffalo. Andouille chicken doner ball tip alcatra short loin burgdoggen. Capicola picanha strip steak meatball t-bone, bresaola cow ground round pastrami tenderloin tongue buffalo cupim prosciutto. Tongue spare ribs leberkas, pork pig jerky pancetta turducken kevin t-bone kielbasa boudin ribeye pork loin shankle. Tail drumstick turducken chuck shankle shank t-bone. Cow pastrami salami corned beef cupim alcatra, ham brisket sirloin meatloaf shankle.
</p>
`;
const html = `
<html>
<head>
</head>
<body>
${filler.repeat(850)}
END
</body>
</html>
`;
console.log(html.length);
const result = await HtmlPdf.create(html, options);
await result.toFile('long.pdf');
});
Please add a comment if you see this issue surface again.
Hello. URL length is limited to 2097152 characters. This is an error chromium throws in console for very big html which contains few base64-encoded images: Refusing to load URL as it exceeds 2097152 characters
. Unfortunately I can't share html that I'm trying to convert (those images contain some sensitive data)
Most likely,
'data:text/html,' + html
has a length limitation. Instead of passing a string of HTML to Chrome using a data URL, use a temporary file.