Saltar al pie de página
USANDO IRONPRINT

Cómo Imprimir un PDF desde una Impresora de Red Usando IronPDF

<div class="alert alert-info iron-variant-1" role="alert">
<a href="https://ironsoftware.com/csharp/print/">IronPrint</a> is Iron Software's brand new .NET printing library, offering compatibility across a wide range of platforms, including Windows, macOS, Android, and iOS. <a href="https://ironsoftware.com/csharp/print/docs/">Get started with IronPrint</a> now!
</div>
<div class="alert alert-info iron-variant-1" role="alert">
<a href="https://ironsoftware.com/csharp/print/">IronPrint</a> is Iron Software's brand new .NET printing library, offering compatibility across a wide range of platforms, including Windows, macOS, Android, and iOS. <a href="https://ironsoftware.com/csharp/print/docs/">Get started with IronPrint</a> now!
</div>
HTML

1. Introduction

This tutorial will show you how to print PDFs from any printer on a network using IronPDF.

1.1 IronPDF Features

IronPDF is a potent PDF library that can convert from HTML to PDF with minimal loss of the original formatting shown in browsers. The .NET library for developers makes it easy to produce, read, and manipulate PDF files.

IronPDF converts HTML files to PDF files using the Chrome engine. IronPDF supports HTML, ASPX, Razor pages, and MVC Views, in addition to other web formats. IronPDF supports all Microsoft.NET technologies (both ASP.NET Web applications and traditional Windows applications).

IronPDF can be used to create visually stunning PDF documents. We can produce PDF documents with IronPDF from HTML5, JavaScript, CSS, and images. There may also be headers and footers in the files. It is also easy to view PDF files using IronPDF.

  • Some of the sources that can be used to make a PDF file include HTML, HTML5, ASPX, and Razor/MVC View. We also have the option to convert picture files as well as HTML files to PDF.
  • You can build interactive PDF files with IronPDF, fill out and submit interactive forms with it, merge and split PDF files, extract text and images from PDF files, search text within a PDF file, rasterize PDF pages to images, convert PDF to HTML, and print PDF files.
  • A document can be generated using IronPDF from a URL. It also supports user agents, proxies, cookies, HTTP headers, and form variables for logins made behind HTML login forms.
  • IronPDF can view and edit PDF files.
  • Images can be extracted from documents using IronPDF.
  • We can add headers, footers, text, images, bookmarks, watermarks, and more to documents with IronPDF.
  • We can combine and divide pages in brand-new or recent documents using IronPDF.
  • IronPDF can convert documents to PDFs without relying on Acrobat software.
  • IronPDF can create PDFs from HTML files that use CSS files.

2. Creating a New Project in Visual Studio

In this article, we are going to use a console application to generate PDF documents.

Open the Visual Studio software, and go to the File menu. Select "New Project", and then select "Console Application".

How to Print a PDF from a Network Printer, Figure 1


Enter the project name and select the file path in the appropriate text box. Then, click the *Create* button and select the required .NET Framework, as in the screenshot below.

![How to Print a PDF from a Network Printer, Figure 2](/static-assets/pdf/blog/csharp-print-pdf-network-printer/csharp-print-pdf-network-printer-2.webp)

The Visual Studio project will now generate the structure for the selected application. If you have selected the console, Windows, or the Web application template in the New Project wizard, Visual Studio will open the Program.cs file, where you can enter code.

How to Print a PDF from a Network Printer, Figure 3


Next, we can add the library to test the code.

## 3. Install the IronPDF Library

The IronPDF Library can be downloaded and installed in four ways.

These are:

1. Using Visual Studio NuGet Package Manager UI
2. Using the Visual Studio Command Line
3. Direct download from the NuGet website
4. Direct download from the IronPDF website

### 3.1 Using Visual Studio NuGet Package Manager UI

Visual Studio provides the NuGet Package Manager UI for installing packages directly to a solution. The below screenshot shows how to open the NuGet Package Manager.

![How to Print a PDF from a Network Printer, Figure 4](/static-assets/pdf/blog/csharp-print-pdf-network-printer/csharp-print-pdf-network-printer-4.webp)

The Package Manager UI provides a search box to show the list of packages from the NuGet website. In the Package Manager, search for the IronPDF library using the keyword "IronPDF," as shown in the screenshot below.

How to Print a PDF from a Network Printer, Figure 5


In the above image, we can see the list of the related search items. We need to select the required option to install the package to the solution.

### 3.2 Using the Visual Studio Command-Line

In Visual Studio, go to Tools > NuGet Package Manager > Package Manager Console.

Enter the following line in the package manager console tab:

```shell
:ProductInstall

The package will download/install to the current project and be ready to use.

How to Print a PDF from a Network Printer, Figure 6


### 3.3 Direct download from the NuGet website

The third way to install IronPDF is to download the NuGet package directly from the website.

1. Navigate to IronPDF's [NuGet](https://www.nuget.org/packages/IronPdf/) gallery page.
2. Select the "Download package" link from the menu on the right-hand side.
3. Double-click the downloaded package from the File Explorer to install it.
4. Reload the Visual Studio project.

### 3.4 Direct download from the IronPDF website

[Download the latest version of IronPDF](/) directly from the website. Once downloaded, follow the steps below to add the package to the project.

1. From Visual Studio, right-click the project from the Solution Explorer panel.
2. Select the Add Reference option. Click the Browse button and search for the location of the downloaded reference.
3. Click OK to add the reference.

## 4. Print PDF Files

IronPDF allows us to print PDF documents using a network printer driver. We can print PDF documents however many times we wish. Below is a code sample for printing on network printers.

```csharp
try
{
    // Initialize the Chrome Pdf Renderer object
    var chromePdfRenderer = new ChromePdfRenderer();

    // Render the HTML content to a PDF
    using (var pdfDocument = chromePdfRenderer.RenderHtmlAsPdf("<h1>Hello, world!</h1>"))
    {
        // Get the print document from the rendered PDF
        using (var printDocument = pdfDocument.GetPrintDocument())
        {
            // Specify the printer name
            printDocument.PrinterSettings.PrinterName = "Brother DCP-T700W Printer";
            // Alternative printer for local PDF creation
            printDocument.PrinterSettings.PrinterName = "Microsoft Print to PDF";

            // Trigger the print process
            printDocument.Print();
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

The above code helps us to print the created PDF document on the local or network printer programmatically. First, we create an object for the ChromePdfRenderer, which helps us to convert text, HTML code, URLs, and other documents into PDF documents. Various types of methods such as RenderHtmlAsPdf, RenderHTMLFileAsPdf, and RenderUrlAsPdf are used to perform various types of operations. This sample code uses RenderHtmlAsPdf, as it allows us to convert the entered HTML code into a PDF document.

Once we have created an object for the ChromePdfRenderer by using the required method, we then need to use the method GetPrintDocument on the created object, which allows us to access all the printer settings. This provides setting options such as page size, margin, DPI, etc., while we can further gain access to many more settings. We can also pass the printer name to the PrinterSettings.PrinterName property, which allows us to print the pages from a specified printer. After specifying all the printer settings, we call the Print method, which will trigger printing on the specified printer. To use this method, you will need to add an assembly reference to the System.Drawing.dll.

IronPDF does not have any restrictions on printing documents. We can print any number of documents as required. If we do not specify a printer name, it will print from the default printer.

5. Conclusion

IronPDF is one of the best-known PDF libraries. It functions independently of all other libraries, and your computer does not need to have Adobe Reader installed. It also works on a variety of platforms. The initial price point for IronPDF is $799.00. There is an option to make a one-year payment for product maintenance and upgrades. IronPDF also provides coverage for royalty-free SaaS and OEM redistribution at an extra cost.

For further details on pricing, go here.

Preguntas Frecuentes

¿Cómo puedo imprimir un documento PDF usando una impresora de red en C#?

Puede usar IronPDF para imprimir documentos PDF a través de una impresora de red inicializando un objeto ChromePdfRenderer, renderizando el HTML a un PDF, obteniendo el documento de impresión del PDF, especificando el nombre de la impresora y usando el método Print para iniciar el proceso de impresión.

¿Puedo usar IronPDF sin Adobe Reader instalado?

Sí, IronPDF opera de manera independiente y no requiere que Adobe Reader esté instalado en su sistema para imprimir o administrar documentos PDF.

¿Qué tipos de formatos de documentos pueden convertirse a PDF usando IronPDF?

IronPDF puede convertir varios formatos web como HTML, ASPX y páginas Razor en documentos PDF, mientras preserva el formato original a través del motor de renderizado de Chrome.

¿Cómo configuro un nuevo proyecto en Visual Studio para usar IronPDF?

Para configurar un nuevo proyecto, abra Visual Studio, navegue al menú Archivo, seleccione 'Nuevo proyecto', elija 'Aplicación de consola', ingrese el nombre y la ruta del archivo de su proyecto, haga clic en 'Crear', y seleccione el .NET Framework deseado.

¿Cuáles son los pasos para instalar IronPDF en Visual Studio?

Puede instalar IronPDF utilizando la IU del Administrador de Paquetes NuGet de Visual Studio, la línea de comandos o descargándolo directamente desde los sitios web de NuGet o IronPDF.

¿Es IronPDF compatible con macOS y Android?

Sí, IronPDF es una biblioteca multiplataforma que admite Windows, macOS, Android y iOS, lo que la hace versátil para diferentes entornos de desarrollo.

¿Qué características interactivas se pueden agregar a los PDF usando IronPDF?

IronPDF permite la creación de PDF interactivos que incluyen características como completar formularios, agregar encabezados y pies de página, insertar marcas de agua y más, mejorando la interacción del usuario con el documento.

¿Existen limitaciones para imprimir documentos con IronPDF?

No, IronPDF no impone ninguna limitación en la cantidad de documentos que se pueden imprimir, ofreciendo flexibilidad para necesidades de impresión de alto volumen.

¿Cómo funciona el modelo de precios de IronPDF?

IronPDF ofrece una licencia lite en un punto de precio inicial, con opciones adicionales para un año de mantenimiento, actualizaciones y cobertura para distribución SaaS y OEM libre de regalías a costos extra.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más