pdf-rs / pdf

Rust library to read, manipulate and write PDF files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to "screenshot" a page?

artecoop opened this issue · comments

Hello, and thanks for this library. I'm fairly new to rust and I've started with the super hard task of handling pdf.

What I need is to somehow "screenshot" all the pages of a pdf file and export them in bmp, for example, to perform some analysis.

I've also tried to get help from copilot, who suggest to use
pdf::render::Context::new(resources.clone(), content.clone(), width, height);

where resources and content come from the page I'm iterating in. But seems that Context::new does not exist anymore.

Any help or hint is very appreciated

It is possible. Check out this example:
https://github.com/pdf-rs/pdf_render/tree/master/examples/pdf2image

It is possible that some pdfs will crash it with clip paths, if that happens let me know and I will try to add an option to disable them.

I love it! Thanks s3bk.
I'm encountering problems with khronos-egl v6.0.0 because it seems to miss the egl install on my macos system, but it isn't imputable to this library.

Thanks again!

It is only tested on linux. You may need to do some modifications for macos.

Yeah I've imagined that. I'll work it out!