1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Document;
use glib::translate::*;
use std::fmt;

glib::wrapper! {
    ///
    #[doc(alias = "PopplerPSFile")]
    pub struct PSFile(Object<ffi::PopplerPSFile>);

    match fn {
        type_ => || ffi::poppler_ps_file_get_type(),
    }
}

impl PSFile {
    /// Create a new postscript file to render to
    /// ## `document`
    /// a [`Document`][crate::Document]
    /// ## `filename`
    /// the path of the output filename
    /// ## `first_page`
    /// the first page to print
    /// ## `n_pages`
    /// the number of pages to print
    ///
    /// # Returns
    ///
    /// a PopplerPSFile
    #[doc(alias = "poppler_ps_file_new")]
    pub fn new(document: &Document, filename: &str, first_page: i32, n_pages: i32) -> PSFile {
        unsafe {
            from_glib_full(ffi::poppler_ps_file_new(
                document.to_glib_none().0,
                filename.to_glib_none().0,
                first_page,
                n_pages,
            ))
        }
    }

    /// Create a new postscript file to render to.
    /// Note that this function takes ownership of `fd`; you must not operate on it
    /// again, nor close it.
    /// ## `document`
    /// a [`Document`][crate::Document]
    /// ## `fd`
    /// a valid file descriptor open for writing
    /// ## `first_page`
    /// the first page to print
    /// ## `n_pages`
    /// the number of pages to print
    ///
    /// # Returns
    ///
    /// a [`PSFile`][crate::PSFile]
    #[cfg(feature = "v21_12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v21_12")))]
    #[doc(alias = "poppler_ps_file_new_fd")]
    pub fn new_fd(document: &Document, fd: i32, first_page: i32, n_pages: i32) -> PSFile {
        unsafe {
            from_glib_full(ffi::poppler_ps_file_new_fd(
                document.to_glib_none().0,
                fd,
                first_page,
                n_pages,
            ))
        }
    }

    /// Enable or disable Duplex printing.
    /// ## `duplex`
    /// whether to force duplex printing (on printers which support this)
    #[doc(alias = "poppler_ps_file_set_duplex")]
    pub fn set_duplex(&self, duplex: bool) {
        unsafe {
            ffi::poppler_ps_file_set_duplex(self.to_glib_none().0, duplex.into_glib());
        }
    }

    /// Set the output paper size. These values will end up in the
    /// DocumentMedia, the BoundingBox DSC comments and other places in the
    /// generated PostScript.
    /// ## `width`
    /// the paper width in 1/72 inch
    /// ## `height`
    /// the paper height in 1/72 inch
    #[doc(alias = "poppler_ps_file_set_paper_size")]
    pub fn set_paper_size(&self, width: f64, height: f64) {
        unsafe {
            ffi::poppler_ps_file_set_paper_size(self.to_glib_none().0, width, height);
        }
    }
}

impl fmt::Display for PSFile {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("PSFile")
    }
}