Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PDF as output type #108

Open
junaid33 opened this issue Aug 31, 2022 · 4 comments
Open

Support PDF as output type #108

junaid33 opened this issue Aug 31, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@junaid33
Copy link

Would be a cool feature to have

@sindresorhus
Copy link
Owner

Rendering a SVG graphic or rendering a website to SVG?

@junaid33
Copy link
Author

junaid33 commented Sep 2, 2022

Rendering a website as SVG. I think there’s a way to use the pdf screenshot and Inkscape to get the SVG, but having that built-in would be helpful.

@sindresorhus
Copy link
Owner

I think generating SVG is out of scope for this package as there's no easy way to do it. However, I'm open to adding support for generating PDF in the type option. Puppeteer supports PDF, but it will require some changes as it's not just a simple option like the other image formats.

When PDF is supported here, you could pass it to some kind of PDF-to-SVG converter.

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Sep 2, 2022
@sindresorhus sindresorhus changed the title Any plans for SVG support? Support PDF as output type Sep 2, 2022
@SrZorro
Copy link

SrZorro commented Jul 9, 2023

I was using this library to export png's and now for another project I need to export PDF's. I just changed page.screnshot to page.pdf and works like a charm

diff --git a/node_modules/capture-website/index.js b/node_modules/capture-website/index.js
index f380b0d..156fb01 100644
--- a/node_modules/capture-website/index.js
+++ b/node_modules/capture-website/index.js
@@ -431,7 +431,8 @@ const internalCaptureWebsiteCore = async (input, options, page, browser) => {
 		screenshotOptions.clip = {x, y, width, height};
 	}
 
-	const buffer = await page.screenshot(screenshotOptions);
+	const buffer = await page.pdf(screenshotOptions);
 
 	return buffer;
 };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants