ArcticLampyrid / winprint.rs

A crate for printing to a Windows printer device using Windows API.
https://crates.io/crates/winprint
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Use win_pdf to print, if the pdf font is Song Dynasty(宋体). Code Error #2

Open letian-tang opened 1 month ago

letian-tang commented 1 month ago
#[test]
    fn win_pdf_print_songti() {
        let device_list  = PrinterDevice::all().unwrap();
        for d in device_list {
            if d.name().contains("EPSON LQ-735KII ESC/P2") {
                let pdf = WinPdfPrinter::new(d);
                let path = Path::new("D:\\RustroverProjects\\winprin.rs\\test_data\\song_ti.pdf");
                let r = pdf.print(path, Default::default());
                match r {
                    Ok(s) => {

                    },
                    Err(e) => {
                        println!("{:?}",e)
                    }
                }
            }
        }
    }

The error occurred in

pdf_renderer .RenderPageToDeviceContext(&pdf_page, d2d_context, Some(&pdf_render_options)) .map_err(WinPdfPrinterError::RenderError)?; Error: (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

test failed song_ti.pdf test passed fang_song.pdf

ArcticLampyrid commented 1 month ago

Considering that we simply called the API provided by WinRT and the error seems to occur within WinRT itself, we may be powerless in this situation.

Any workarounds that can address this issue would be welcomed; please feel free to provide them.

Furthermore, if there is any public method to contact the relevant Windows team, please let me know.

ArcticLampyrid commented 1 month ago

BTW, you may use Pdfium to print the PDF files.

https://docs.rs/winprint/latest/winprint/printer/struct.PdfiumPrinter.html

letian-tang commented 1 month ago

BTW, you may use Pdfium to print the PDF files.

https://docs.rs/winprint/latest/winprint/printer/struct.PdfiumPrinter.html

👌