惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
美团技术团队
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
有赞技术团队
有赞技术团队
GbyAI
GbyAI
宝玉的分享
宝玉的分享
腾讯CDC
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
月光博客
月光博客
MyScale Blog
MyScale Blog
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK
How to print a PDF in C# with Nutrient
Olivier Houssin · 2024-06-18 · via Inside Nutrient

Table of contents

    How to print a PDF in C# with Nutrient

    Summary

    This tutorial demonstrates how to implement PDF printing functionality in C# applications using Nutrient’s .NET PDF SDK. The guide walks through project setup in Visual Studio, integration of the GdPicture.NET library, and implementation of PDF and image printing capabilities with customizable printer settings. The solution provides a straightforward approach to programmatic PDF printing without requiring external dependencies.

    In this post, you’ll learn how to use Nutrient’s .NET PDF SDK to print PDFs for your C# application.

    To get started, you’ll set up a new C# project and open a project in Visual Studio. Then, you’ll learn how to print a PDF using the Nutrient GdPicture.NET library in your project.

    Nutrient’s C# .NET PDF library

    Nutrient’s GdPicture.NET library is a complete SDK that supports:

    GdPicture.NET also supports more than 100 file formats and abstracts all of its powerful features behind a rich, cross-platform, and easy-to-use API to maximize developer productivity.

    Requirements

    To get started, you’ll need the following:

    • Visual studio — The official integrated development environment for C# .NET.

    Getting started with Nutrient

    The next sections will provide you with information on how to first create a new project and then prepare a PDF for printing using C#.

    Creating a new project

    1. Open Visual Studio and create a new project. Then specify your project requirements.
    2. Choose the correct template for your project. For this example, you’ll use Console App.

    Image showing a menu in Visual Studio that lets user choose a template

    1. When prompted, choose your project name (Nutrient PDF Demo), select the location where you want to save the project, and press Next. Then select the target .NET framework.

    Image showing to add a name and location

    1. Click Create to create your project at your preferred save location.

    Adding Nutrient’s PDF library to your project

    1. Add the Nutrient GdPicture library from the NuGet solution manager. Select the project and install that library into the project.

    Image showing to add a GdPicture from the NuGet solution manager

    1. Add the Nutrient dependency in the Program.cs file using GdPicture14.

    Building the project

    Once you’ve added the libraries mentioned above into the project and added the library reference into the current file, build the project and ensure that all solutions build successfully.

    Printing a PDF document

    Next, you’ll open a PDF file from the device’s local storage using the following code:

    using GdPicturePDF gdpicturePDF = new GdPicturePDF();

    // Load the source document.

    gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");

    // Store the handle of the active window in a variable.

    IntPtr WINDOW_HANDLE = IntPtr.Zero;

    // Enable the printer settings dialog.

    gdpicturePDF.PrintShowPrinterSettingsDialog(WINDOW_HANDLE);

    // Print the document.

    gdpicturePDF.Print();

    // Release unnecessary resources.

    gdpicturePDF.CloseDocument();

    The code above will first create the GdPicturePDF object, and based on that, the file will be opened. If the file is opened successfully, the active window will be handled in the WINDOW_HANDLE variable. Then, call the PrintShowPrinterSettingsDialog function using the GdPicturePDF object.

    Afterward, call the print function to print the loaded PDF to the PDF viewer tool or browser. The output of the code above is shown in the following image.

    Image showing the solution of the above code

    Printing an image

    The GdPictureImaging class will display the images and then print for you. Below is the code for viewing the file using the GdPictureImaging class:

    using GdPictureImaging gdpictureImaging = new GdPictureImaging();

    // Load the source image.

    int imageId = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.png");

    // Store the handle of the active window in a variable.

    IntPtr WINDOW_HANDLE = IntPtr.Zero;

    // Enable the printer settings dialog.

    gdpictureImaging.PrintShowPrinterSettingsDialog(WINDOW_HANDLE);

    // Print the image.

    gdpictureImaging.Print(imageId);

    // Release unnecessary resources.

    gdpictureImaging.ReleaseGdPictureImage(imageId);

    Conclusion

    This post demonstrated how to print a PDF in C# using Nutrient’s GdPicture.NET library. If you hit any snags, don’t hesitate to reach out to our Support team for help.

    At Nutrient, we offer a commercial, feature-rich, and completely customizable web PDF library that’s easy to integrate and comes with well-documented APIs to handle advanced use cases. Try it for free, or visit our demo to see it in action.

    Explore related topics

    Try for free Ready to get started?

    Related SDK articles

    Explore more