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

Make it possible to pass options to printer #12

Open
wants to merge 4 commits into
base: feature/printer-options
Choose a base branch
from

Conversation

JuliDi
Copy link

@JuliDi JuliDi commented Jan 15, 2023

This could serve as a starting point for allowing users to pass options to the printers. I only tested this on macOS, and it seems to work there.

There is of course a lot that can be improved, but it might be a good start.

fixes #11

@talesluna talesluna changed the base branch from master to feature/printer-options February 9, 2023 05:53
@talesluna talesluna mentioned this pull request Feb 9, 2023
@trembel
Copy link

trembel commented Feb 21, 2024

What's the state of this?

@doomspork
Copy link

@talesluna @JuliDi anything we could do to help with this? I'd very much like to leverage this library but I need this capability. Happy to help however.

@JuliDi
Copy link
Author

JuliDi commented Jun 6, 2024

Not sure, there isn't really anything blocking this PR. It works as is and pends integration into a new release afaik, see #11 (comment)

@sam-rusty
Copy link

Hey, great job. I currently have an electron app where i am using print api with options like this

window.webContents.print({
    margins: { marginType: 'none' },
    pageRanges: [{ from: 1, to: 1 }],
    pageSize: {
      width: 101600, // 4 inches
      height: 152400 // 6 inches
    },
})

how do i pass these options when using printers::print?

@JuliDi
Copy link
Author

JuliDi commented Jun 20, 2024

Haven't used it in a while, but this is what I have in the app I made that branch for:

let mut printer: Vec<Printer> = printers::get_printers();
let printer = printer
    .iter_mut()
    .find(|p| p.system_name == *selected)
    .unwrap();
// See https://www.cups.org/doc/options.html
printer.add_option(PrinterOption::new(r#"PageSize="Custom.54x101mm""#));
printer.add_option(PrinterOption::new(r#"orientation-requested=4"#)); // landscape
                                                                        //printer.add_option(PrinterOption::new(r#"orientation-requested=3"#)); // portrait
printer.add_option(PrinterOption::new(r#"fit-to-page"#));

printer.print_file(&file);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specify page size
5 participants