Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Jan 25, 2024 7:36 am

I have a printer that can separate individual print jobs in the output tray.
The printer places the pages of a job in the output tray with left/right offset per job.

I have to print a lot of documents and would like to use the job separation and other settings

How can I setup the printer with the PrintSetting dialog and then use the settings for several print jobs?

Peter

peterInStIngbert
 
Posts: 18
Joined: Wed Nov 25, 2020 2:08 pm

Thu Jan 25, 2024 9:20 am

Hello,

Thank you for your inquiry.
Based on your description, I understand that you are looking for a way to select a printer tray based on the left or right offset of the printer. The System.Drawing.Printing.PrinterSettings class supports retrieving the left or right offset of the printer settings. Please refer to the code snippet below to implement this requirement.
Code: Select all
// Create a new PdfDocument object
PdfDocument doc = new PdfDocument();

// Load the PDF file from the specified path
doc.LoadFromFile(@"input.pdf");

// Set the print settings for the document: color, landscape orientation, and duplex printing
doc.PrintSettings.Color = true;
doc.PrintSettings.Landscape = true;
doc.PrintSettings.Duplex = Duplex.Horizontal;

// Create a new PrinterSettings object and specify the printer name
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = "printer name";

// Set the left margin value for the default page settings of the printer
//printerSettings.DefaultPageSettings.Margins.Left = 12;

// Get the left and right margin values from the default page settings
int left = printerSettings.DefaultPageSettings.Margins.Left;
int right = printerSettings.DefaultPageSettings.Margins.Right;

// Set the printer name for the print settings of the document
doc.PrintSettings.PrinterName = printerSettings.PrinterName;

// Attach an event handler to the PaperSettings event of the PrintSettings
doc.PrintSettings.PaperSettings += delegate (object sender1, PdfPaperSettingsEventArgs e1)
{
    // Check if the left margin is greater than 0
    if (left > 0)
    {
        // Set the current paper source to the first available paper source
        e1.CurrentPaperSource = e1.PaperSources[0];
    }
    else
    {
        // Set the current paper source to the second available paper source
        e1.CurrentPaperSource = e1.PaperSources[1];
    }
};

// Print the document using the specified printer and settings
doc.Print();

If the provided code does not meet your requirements, please provide more specific details about your needs. We would be happy to assist you further.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Jan 26, 2024 6:51 am

Hello
Unfortunately, the code provided does not meet my requirements.

It is not a paperSoure thing.

The printer shifts the pages of a job in the output tray slightly to the left/right.
This makes it easy to separate the individual jobs.

There is a printer setting for this: Finishing - Separation Offset Jobs

Peter

peterInStIngbert
 
Posts: 18
Joined: Wed Nov 25, 2020 2:08 pm

Fri Jan 26, 2024 8:29 am

Hello,

Thank you for your feedback.
We apologize for the misunderstanding regarding your requirement. Unfortunately, the feature you mentioned is not supported by our product. It primarily involves manipulating printer properties rather than document properties, which is why we currently do not offer support for it.
If you have any other questions or need assistance with any other aspects of our product, please don't hesitate to let us know.
Again, we apologize for any confusion caused and appreciate your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron