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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Excel - Set Active Printer

Thread ID:





124330 Jun 1,2016 06:38 AM UTC Jun 20,2016 04:44 AM UTC WinForms 3
Tags: XlsIO
Asked On June 1, 2016 06:38 AM UTC

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:
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
Thanks & Best Regards,

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

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)

        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"; 

Please let us know if you any further queries. 


Replied On June 19, 2016 09:08 AM UTC

Thanks Kesavan D, will look into this.

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

Hi Nilofer, 

Thanks for the update. 

We are waiting to hear the testing results from you. 



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon