Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Printing / Customizing the Appearance of the Printing / Customizing the Print Job Settings
In This Topic
    Customizing the Print Job Settings
    In This Topic

    Sheets are printed on the current default printer in your Windows environment unless you specify otherwise. You can print sheets on any Windows-supported printer.

    The print job settings that you can customize include printer, source, page size and collated settings. Set the Printer, PaperSource, or PaperSize on the PrintInfo object and Collated settings on the PageSetup object.

    Using Code

    1. Set various print job settings.
    2. Print the sheet.

    Example

    This example code sets the paper source based on a selection from a combo box and sets the paper size before printing all the sheets.

    C#
    Copy Code
    private void Form1_Load(object sender, System.EventArgs e)
    {
        int i;
        System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
        
        for (i = 0; i <= ps.PaperSources.Count - 1; i++)
        {
            comboBox1.Items.Add(ps.PaperSources[i].SourceName);
        }
        comboBox1.Text = ps.PaperSources[0].SourceName;
    }
    
    private void button1_Click(object sender, System.EventArgs e
    {
        FarPoint.Win.Spread.PrintInfo pi = new FarPoint.Win.Spread.PrintInfo();
        System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
        pi.PaperSize = new System.Drawing.Printing.PaperSize("Letter", 600, 300);
        pi.PaperSource = ps.PaperSources[comboBox1.SelectedIndex];
        fpSpread1.Sheets[0].PrintInfo = pi;
        fpSpread1.PrintSheet(-1);
    }
    
    VB
    Copy Code
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ps As New System.Drawing.Printing.PrinterSettings()
        Dim i As Integer
        For i = 0 To ps.PaperSources.Count - 1
            ComboBox1.Items.Add(ps.PaperSources.Item(i).SourceName)
        Next
        ComboBox1.Text = ps.PaperSources.Item(0).SourceName
    End Sub
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pi As New FarPoint.Win.Spread.PrintInfo()
        Dim ps As New System.Drawing.Printing.PrinterSettings()
        pi.PaperSize = New System.Drawing.Printing.PaperSize("Letter", 600, 300)
        pi.PaperSource = ps.PaperSources(ComboBox1.SelectedIndex)
        FpSpread1.Sheets(0).PrintInfo = pi
        FpSpread1.PrintSheet(-1)
    End Sub
    

    Set the Collated Printing

    In printing, the term Collated refers to printing the first copy in the same order from start to finish, followed by printing the next copy in the same order, whereas Uncollated refers to printing multiple copies of the first page of a document, then multiple copies of the second page, and so on.

    In Spread.NET, the Collated property when set as true uses IPageSetup object to implement the collated printing of the spreadsheet.

    The following image shows the Collated option in the Print settings that appears on your screen.

     

    Example

    Collated printing can be useful for creating employee training materials whereas Uncollated option can be useful for creating separate piles of each page from the document.

    Refer to the following code to implement an uncollected printing of the Spreadsheet.

    C#
    Copy Code
    IWorksheet TestActiveSheet = fpSpread1.AsWorkbook().ActiveSheet;
    for (int i = 1; i < 50; i++)
    {
      for (int j = 3; j < 10; j++)
      {
       TestActiveSheet.Cells[i, j].Value = i + j;
      }
    }
    GrapeCity.Spreadsheet.Printing.IPageSetup pageSetup = fpSpread1.AsWorkbook().ActiveSheet.PageSetup;
    pageSetup.Collated = false;
    pageSetup.NumberOfCopies = 3;
    fpSpread1.Sheets[0].PrintInfo.Preview = true;
    fpSpread1.Sheets[0].PrintInfo.EnhancePreview = true;
    fpSpread1.PrintSheet(0);
    
    VB
    Copy Code
    Dim TestActiveSheet As IWorksheet = fpSpread1.AsWorkbook().ActiveSheet
    For i = 1 To 49
      For j = 3 To 9
         TestActiveSheet.Cells(i, j).Value = i + j
      Next
    Next
    Dim pageSetup As GrapeCity.Spreadsheet.Printing.IPageSetup = fpSpread1.AsWorkbook().ActiveSheet.PageSetup
    pageSetup.Collated = False
    pageSetup.NumberOfCopies = 3
    FpSpread1.Sheets(0).PrintInfo.Preview = True
    FpSpread1.Sheets(0).PrintInfo.EnhancePreview = True
    FpSpread1.PrintSheet(0)
    
    The Collated/Uncollated option cannot be used for printing PDFs, as NumberOfCopies property is not applicable for PDF.
    See Also