We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Printing office documents and QR codes

Hi, I need method/example code to print office documents from asp.net to the default (connected) printer.
This implies that whatever printer is available via selection dialog and/or printer dialog to be able to print documents locally by the user.


What we understand from your inquiry that you are trying to print the barcode generated by Aspose.BarCode APIs. Please visit the link Print Barcode Image for details.

Thank you for this!
Just to confirm, the barcode printing code as per the link, is used in an asp.net website, published on a webserver and the remote user will be able to print the barcode to the specified and/or default printer based on the settings in the code?


Yes, you can use the code in your .NET desktop application or in website application published on the webserver. Barcode will be printed on the printer specified in the code.

Hi, thank you for this.
I am now testing the sample and locally from Visual Studio all works fine.
However, after publishing to web server and running the sample on the webserver, I get the following error:
No printers are installed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Drawing.Printing.InvalidPrinterException: No printers are installed.

How do I specify the local printer or what should I do to print to the printer that the user is using?


Please forward us your sample .NET project for evaluation. We will analyze it, try to reproduce the issue and update you about our findings.

Hi Ikram,
Thank you for your help.
My test is very basic.
I am also pasting my web.config below the button code
The code below is on a button on a web page:
using Aspose.BarCode;
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace tt
public partial class _Default : Page
protected void Page_Load(object sender, EventArgs e)


    protected void Button1_Click(object sender, EventArgs e)
        // Get the default Printer Name

        PrinterSettings settings = new PrinterSettings();

        string printerName = settings.PrinterName;

        // Create instance of BarCodeBuilder, specify codetext and symbology in the constructor

        BarCodeBuilder builder = new BarCodeBuilder("12345678", Symbology.QR);

        // Set printer name

        builder.PrinterName = printerName;



<?xml version="1.0" encoding="utf-8"?>


Thank you for details. The code should work as this is the right code snippet to serve the purpose. There are several points that should be taken care on server side. Before you execute the code, make sure:

No network issue.
No firewall issue.

If these issues have been taken care then printing code should execute properly. For cross verification you may try following code snippet:


PrintDocument doc = new PrintDocument();
doc.PrinterSettings.PrinterName = "Your printer";
doc.PrintPage += (s, e) => e.Graphics.FillRectangle(Brushes.Black, new Rectangle(0, 0, 400, 300));

Please try the above solution and share your feedback.