简体   繁体   中英

PDF is not printing from Windows XP, but works on Windows 7

The following code successfully prints on Windows 7, but won't work on Windows XP. Both computers have a default printer setup that works correctly if I go into Notepad and manually print a document. On the Windows XP box it just sits there, no errors no nothing.

How can I debug this so as to get an error message or some other way to figure out why this isn't printing?

try
{
    if (File.Exists(pdfPath))
    {
        Process process = new Process();
        process.StartInfo.FileName = pdfPath;
        process.StartInfo.Verb = "print";
        process.StartInfo.CreateNoWindow = true;
        process.Start();
        process.WaitForInputIdle();
        process.Kill();
    }
    else
    {
        MessageBox.Show("The file \"" + pdfPath + "\" does not exist", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
        statusLabel.Text = "";
        return;
    }
}
catch (Exception e)
{
    MessageBox.Show(e.Message, "Unable to print packing slip", MessageBoxButtons.OK, MessageBoxIcon.Error);
    return false;
}

I thing you have differently settings for pdf print in both systems.
Check "print" verb for .pdf filetypes .. in winXP and win7. You get the same results?

For check and compare you can use this software: nirsoft-file_types_manager
Maybe you get link like this:

print
"C:\\Program Files (x86)\\Foxit Software\\Foxit Reader\\Foxit Reader.exe" /p "%1"

As a solution I propose to do the following steps:

  1. Check "print" verb for PDF in your system. If this verb is missing, then reinstal PDF software.

  2. If you get differently commands then try use the same software in both systems. With software from nirsoft you can try edit XP command to fix it (this can be in system if you "incorrectly" uninstalled software for PDF .. if you know path with parameters then you can try edit this command

  3. Try use "open" verb if software for opening (and printing) PDF files is installed correctly. If this work and print no, then try reinstal software for PDF.

If all of this steps not help, commands are the same and open file work correctly, then you can try to use command to print PDF directly, to check if command working.

  1. In winXP replace %1 with your filename and run this command in Run window (start with shortcut WIN + R) Warning: your file will be printed if it works

If it not works, then reinstal PDF software. If it works from command line, but not from you software, then I do not know how to help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM