We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Excel - Set Active Printer

Thread ID:

Created:

Updated:

Platform:

Replies:

124330 Jun 1,2016 02:38 AM Jun 20,2016 12:44 AM Windows Forms 3
loading
Tags: XlsIO
Nilofer
Asked On June 1, 2016 02:38 AM

For Excel how do we set a Active Printer or Set Paper Size as ID Card Size. Want to use Printer other than Default Printer.
Size Details:
ISO ID-1 
In MM (85.60 X 53.98 MM)
In Points (242.65 X 153.02)
In Inch (2.13" X 3.38")

Output PDF Conversion needs to be this ID Card Size. If we don't change the Active Printer of Excel before conversion then PDF is coming full default A4 size. 
We can do this in excel, but how we do in XLsIO
Dim excel As Microsoft.Office.Interop.Excel.Application
excel = New Microsoft.Office.Interop.Excel.Application
excel.ActivePrinter = _DEFAULT_ID_PRINTER
wb.Activate()
wb.Save()
Thanks & Best Regards,

Kesavan D [Syncfusion]
Replied On June 2, 2016 01:12 AM

Hi Nilofer, 

Thank you for contacting Syncfusion support. 

Regarding query related to setting Paper Size. 

XlsIO has support for setting the page size using PaperSize property in IWorksheet.PageSetup. Even though when a different page size is set, while printing the document the page size is overridden by the page setting of printer which is chosen(This overriding behavior is seen in Microsoft Excel also).  

Regarding query related to changing Active Printer 

Currently, XlsIO does not have support to change active printer or printing a document, but as a workaround you can use the below code to print the XlsIO generated document to your desired printer( which already has the required ISO ID-1 paper size as its default one)

        [DllImport("Winspool.drv")] 
        private static extern bool SetDefaultPrinter(string printerName); 
 
        static void Main(string[] args) 
        { 
            // Change the default printer to XPS Document Writer 
            SetDefaultPrinter("Microsoft XPS Document Writer"); 
 
            //Print an Excel document 
            System.Diagnostics.Process pr = new System.Diagnostics.Process(); 
            pr.StartInfo.Verb = "Print"; 
            pr.StartInfo.FileName = "Sample.xls"; 
            pr.Start(); 
        } 

Please let us know if you any further queries. 

Regards, 
Kesavan

Nilofer
Replied On June 19, 2016 05:08 AM

Thanks Kesavan D, will look into this.

Kesavan D [Syncfusion]
Replied On June 20, 2016 12:44 AM

Hi Nilofer, 

Thanks for the update. 

We are waiting to hear the testing results from you. 

Kesavan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;