IronQR 教程 在 C# 中編寫 QR 碼 Write QR Codes in C# Curtis Chau 更新日期:7月 22, 2025 Download IronQR NuGet 下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Introduction With IronQR, developers can create QR codes for popular image formats and customize them with background colors, margins, logos, and even add them to PDFs. For advanced use, it also offers control over error correction and versions. This article will explore key features of IronQR with examples, helping you understand how to use it for writing QR codes in C# and apply it effectively in your projects. Table of Contents Input Data Text, URLs, Numbers Binary & Streams Export QR Codes Save as Image System.Drawing.Images IronSoftware.Drawing Stamp on PDF QR Code Options Encoding Error Correction QR Code Version Character Encoding QR Code Styling Resize Margins & Borders Recolor Add a Logo 立即開始在您的項目中使用 IronQR 並免費試用。 第一步: 免費啟動 Input Data Text, URLs, Numbers IronQR can convert a wide range of data types, including text, URLs, and numbers, into QR codes. Whether you're creating QR code links or text for marketing and communication, numeric codes for inventory management, or encoding binary data or streams into readable QR codes, IronQR provides all the support you need. Additionally, the API is straightforward. The QrWriter class offers several overloads, enabling different types of data as input, reducing complexity and streamlining the process. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-1.cs using IronQr; using IronSoftware.Drawing; string text = "Hello, World!"; string url = "https://ironsoftware.com/csharp/qr/"; string alphanumeric = "WATERSKU-12356"; // Create QR code QrCode textQr = QrWriter.Write(text); // Save QR code as a bitmap AnyBitmap textQrImage = textQr.Save(); // Save QR code as file textQrImage.SaveAs("textQr.png"); QrCode urlQr = QrWriter.Write(url); AnyBitmap urlQrImage = urlQr.Save(); urlQrImage.SaveAs("urlQr.png"); QrCode alphanumericQr = QrWriter.Write(alphanumeric); AnyBitmap alphanumericQrImage = alphanumericQr.Save(); alphanumericQrImage.SaveAs("alphanumericQr.png"); Imports IronQr Imports IronSoftware.Drawing Private text As String = "Hello, World!" Private url As String = "https://ironsoftware.com/csharp/qr/" Private alphanumeric As String = "WATERSKU-12356" ' Create QR code Private textQr As QrCode = QrWriter.Write(text) ' Save QR code as a bitmap Private textQrImage As AnyBitmap = textQr.Save() ' Save QR code as file textQrImage.SaveAs("textQr.png") Dim urlQr As QrCode = QrWriter.Write(url) Dim urlQrImage As AnyBitmap = urlQr.Save() urlQrImage.SaveAs("urlQr.png") Dim alphanumericQr As QrCode = QrWriter.Write(alphanumeric) Dim alphanumericQrImage As AnyBitmap = alphanumericQr.Save() alphanumericQrImage.SaveAs("alphanumericQr.png") $vbLabelText $csharpLabel Binary & Streams Similarly, we can convert binary data and streams into QR codes using the same Write method as mentioned earlier. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-2.cs using IronQr; using IronSoftware.Drawing; using System.Text; byte[] bytes = Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/qr/"); // Create QR code QrCode bytesQr = QrWriter.Write(bytes); // Save QR code as a bitmap AnyBitmap qrImage = bytesQr.Save(); // Save QR code bitmap to file qrImage.SaveAs("bytesQr.png"); Imports IronQr Imports IronSoftware.Drawing Imports System.Text Private bytes() As Byte = Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/qr/") ' Create QR code Private bytesQr As QrCode = QrWriter.Write(bytes) ' Save QR code as a bitmap Private qrImage As AnyBitmap = bytesQr.Save() ' Save QR code bitmap to file qrImage.SaveAs("bytesQr.png") $vbLabelText $csharpLabel class Program { static void Main() { // Create a QR code writer instance QrWriter writer = QrWriter.CreateQrCode(); // Example binary data byte[] data = { 0x01, 0x02, 0x03, 0x04 }; // Write binary data to QR code writer.Write(data) .SaveAs("binary-qr.png"); // Example using a memory stream using (MemoryStream stream = new MemoryStream(data)) { writer.Write(stream) .SaveAs("stream-qr.png"); } } } The `Write` method has overloads that accept both byte arrays and streams as inputs. For streams, we can create a `MemoryStream` from the byte array and then convert it into a QR code. This is useful when users require more fine-grained control over data chunks, as streams can be more memory-efficient. ```cs :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-3.cs Export QR Codes IronQR is flexible and adaptable to various use cases that require different file formats. You can save QR codes in multiple formats such as JPG, PNG, GIF, and TIFF using the SaveAs method. Save as Image The SaveAs method from AnyBitmap automatically detects the file format based on the provided file path. In this example, I specified a file path ending with .png. 請注意When using the SaveAs method, please note that there is no default image format. If you enter an unrecognized extension or make a typo in the file path, the image will be saved with the incorrect extension. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-4.cs using IronQr; using IronSoftware.Drawing; // Create a QR code object QrCode qr = QrWriter.Write("hello world"); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.SaveAs("qr.png"); Imports IronQr Imports IronSoftware.Drawing ' Create a QR code object Private qr As QrCode = QrWriter.Write("hello world") ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save() ' Save QR code bitmap as file qrImage.SaveAs("qr.png") $vbLabelText $csharpLabel System.Drawing.Images Converting images to the System.Drawing.Images object from Microsoft allows you to use the Bitmap class to save the QR code to a file path. In this example, the Save method saves the QR code as a PNG file to the path qrBitmap.png. 請注意System.Drawing.Common is only supported on the Windows platform. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-5.cs using IronQr; using System.Drawing; // Create a QR code object QrCode qr = QrWriter.Write("hello world"); // Save QR code as a bitmap Bitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.Save("qrBitmap.png"); Imports IronQr Imports System.Drawing ' Create a QR code object Private qr As QrCode = QrWriter.Write("hello world") ' Save QR code as a bitmap Private qrImage As Bitmap = qr.Save() ' Save QR code bitmap as file qrImage.Save("qrBitmap.png") $vbLabelText $csharpLabel IronSoftware.Drawing Due to the lack of cross-platform compatibility of System.Drawing.Common, developers may encounter issues when maintaining cross-platform applications. IronQR can utilize both System.Drawing.Common and IronSoftware.Drawing. IronQR uses the AnyBitmap class from IronSoftware.Drawing, a universally compatible Bitmap class that implicitly casts to the following: System.Drawing.Bitmap System.Drawing.Image SkiaSharp.SKBitmap SixLabors.ImageSharp Microsoft.Maui.Graphics.Platform.PlatformImage With this powerful open-source library, IronQR achieves cross-platform support and compatibility with .NET 8, .NET 7, .NET 6, .NET 5, .NET Core, .NET Standard, and .NET Framework 4.6.2+. To learn more about the library, please refer to IronSoftware.Drawing website. Stamp on PDF IronQR allows developers to stamp QR codes onto existing PDF documents, making it easy for others to quickly access links or additional resources. Stamping QR codes on both single and multiple pages is supported. Stamp to a Single Page After creating the QR code, call the StampToExistingPdfPage method from the QrCode object. This method requires the file path, coordinates (x and y), page number, and an optional password if the PDF is password-protected. Once the arguments are provided, the method stamps the QR code and saves the PDF. 請注意This method is based on the PDF pages, with page numbering starting at 1 instead of 0. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-6.cs using IronQr; // Create a QR code object QrCode qr = QrWriter.Write("hello world"); string filepath = "example.pdf"; int x = 100; int y = 150; int page = 1; // Stamp QR code to (100, 150) of the pdf on page 1 qr.StampToExistingPdfPage(filepath, x, y, page); Imports IronQr ' Create a QR code object Private qr As QrCode = QrWriter.Write("hello world") Private filepath As String = "example.pdf" Private x As Integer = 100 Private y As Integer = 150 Private page As Integer = 1 ' Stamp QR code to (100, 150) of the pdf on page 1 qr.StampToExistingPdfPage(filepath, x, y, page) $vbLabelText $csharpLabel Stamp to Multiple Pages Similar to the example above, the main difference is that the StampToExistingPdfPages method takes a list of page numbers instead of just one. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-7.cs using IronQr; using System.Collections.Generic; // Create a QR code object QrCode qr = QrWriter.Write("hello world"); string filepath = "example.pdf"; int x = 100; int y = 150; List<int> pages = new List<int>(); pages.Add(1); pages.Add(2); pages.Add(3); pages.Add(4); // Stamp QR code to (100, 150) of the pdf on pages 1-4 qr.StampToExistingPdfPages(filepath, x, y, pages); Imports IronQr Imports System.Collections.Generic ' Create a QR code object Private qr As QrCode = QrWriter.Write("hello world") Private filepath As String = "example.pdf" Private x As Integer = 100 Private y As Integer = 150 Private pages As New List(Of Integer)() pages.Add(1) pages.Add(2) pages.Add(3) pages.Add(4) ' Stamp QR code to (100, 150) of the pdf on pages 1-4 qr.StampToExistingPdfPages(filepath, x, y, pages) $vbLabelText $csharpLabel Output from Both Examples QR Code Options IronQR offers extensive customization options for fine-tuning QR code behavior and functionality. The QrOptions class provides several parameters, such as version control, encoding type, character encoding, and error correction levels. Let’s explore these options in more detail. Encoding IronQR supports multiple types of QR codes for both creation and reading. Below are the supported types: QRCode: This is the standard QR code, commonly used today. It can store up to 7,089 numeric characters or 4,296 alphanumeric characters. MicroQRCode: A smaller version of the standard QR code, it can store up to 35 numeric characters or 21 alphanumeric characters. RMQRCode: The Rectangular Micro QR Code is a compact version of the QR code, offering flexibility in its aspect ratio. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-8.cs using IronQr; using IronSoftware.Drawing; QrOptions options = new QrOptions { // Change encoding to micro QR code Encoding = IronQr.Enum.QrEncoding.MicroQRCode, }; // Create QR code QrCode qr = QrWriter.Write("1234", options); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.SaveAs("qrImage.png"); Imports IronQr Imports IronSoftware.Drawing Private options As New QrOptions With {.Encoding = IronQr.Enum.QrEncoding.MicroQRCode} ' Create QR code Private qr As QrCode = QrWriter.Write("1234", options) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save() ' Save QR code bitmap as file qrImage.SaveAs("qrImage.png") $vbLabelText $csharpLabel Error Correction IronQR uses standard QR error correction to ensure that all QR codes produced are fault-tolerant and reliable, even in harsh conditions. Additionally, IronQR allows you total control over error correction level for further fine-tuning. There are four levels of error correction available, provided by QrErrorCorrectionLevel: Highest: 30% error correction High: 25% error correction Medium: 15% error correction Low: 7% error correction :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-9.cs using IronQr; using IronSoftware.Drawing; QrOptions options = new QrOptions { // Change error correction level to medium ErrorCorrectionLevel = QrErrorCorrectionLevel.Medium, }; // Create QR code QrCode qr = QrWriter.Write("1234", options); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.SaveAs("qrImage.png"); Imports IronQr Imports IronSoftware.Drawing Private options As New QrOptions With {.ErrorCorrectionLevel = QrErrorCorrectionLevel.Medium} ' Create QR code Private qr As QrCode = QrWriter.Write("1234", options) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save() ' Save QR code bitmap as file qrImage.SaveAs("qrImage.png") $vbLabelText $csharpLabel Higher error correction provides greater fault tolerance when reading the QR code, making it more likely to be scanned at lower resolutions compared to one with low error correction. You may test out based on your use cases. QR Code Version You can adjust the QR code version to store more data. Higher versions are ideal for inventory or logistics, while lower versions work well for smaller data, like short URLs. Simply change the Version property in the QrOptions object and pass it to the Write method to generate the QR code as needed. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-10.cs using IronQr; using IronSoftware.Drawing; QrOptions options = new QrOptions { // Change QR code version to 40 Version = 40, }; // Create QR code QrCode qr = QrWriter.Write("1234", options); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.SaveAs("qrImage.png"); Imports IronQr Imports IronSoftware.Drawing Private options As New QrOptions With {.Version = 40} ' Create QR code Private qr As QrCode = QrWriter.Write("1234", options) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save() ' Save QR code bitmap as file qrImage.SaveAs("qrImage.png") $vbLabelText $csharpLabel As you can see from the output, version 40 of the QR code is highly complex and dense compared to version 5. Lower versions require more precise scanning and may be difficult to scan without higher-resolution scanners. However, higher versions are easier to scan, even with lower-resolution cameras. For a more detailed guide on choosing the QR version based on capacity, please refer to the QR version list. Character Encoding This option determines how the QR code is encoded. In our example, we changed it to 'UTF-32', while the default character encoding is 'ISO-8859-1.' :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-11.cs using IronQr; using IronSoftware.Drawing; QrOptions options = new QrOptions { // Change character encoding to UTF-32 CharacterEncoding = "UTF-32" }; // Create QR code QrCode qr = QrWriter.Write("1234", options); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(); // Save QR code bitmap as file qrImage.SaveAs("qrImage.png"); Imports IronQr Imports IronSoftware.Drawing Private options As New QrOptions With {.CharacterEncoding = "UTF-32"} ' Create QR code Private qr As QrCode = QrWriter.Write("1234", options) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save() ' Save QR code bitmap as file qrImage.SaveAs("qrImage.png") $vbLabelText $csharpLabel QR Code Styling In addition to its easy-to-use methods and flexibility in handling input data, IronQR offers many options for customizing and styling QR codes to make them unique. The QrStyleOptions class provides various parameters for customizing all aspects of a QR code. Let’s explore the available options. Resize To resize the QR code, you can set the Dimensions property of the QrStyleOptions object and then pass it to the Save method. By default, the QR code is saved at 300px. In this example, we saved the QR code at 600px instead of 300px. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-12.cs using IronQr; using IronSoftware.Drawing; QrStyleOptions styleOptions = new QrStyleOptions() { // Change the dimensions to 600px Dimensions = 600, }; string url = "https://ironsoftware.com/csharp/qr/"; // Create QR code QrCode qr = QrWriter.Write(url); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(styleOptions); // Save QR code bitmap as file qrImage.SaveAs("qrURLResized.png"); Imports IronQr Imports IronSoftware.Drawing Private styleOptions As New QrStyleOptions() With {.Dimensions = 600} Private url As String = "https://ironsoftware.com/csharp/qr/" ' Create QR code Private qr As QrCode = QrWriter.Write(url) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save(styleOptions) ' Save QR code bitmap as file qrImage.SaveAs("qrURLResized.png") $vbLabelText $csharpLabel Margins & Borders To adjust the margins and borders, we can use the Margins property of the QrStyleOptions class. This property controls the margins of the QR code on all sides, with a default value of 10px. In our example, we set the margin to 20px. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-13.cs using IronQr; using IronSoftware.Drawing; QrStyleOptions styleOptions = new QrStyleOptions() { // Change margins to 20px Margins = 20 }; string url = "https://ironsoftware.com/csharp/qr/"; // Create QR code QrCode qr = QrWriter.Write(url); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(styleOptions); // Save QR code bitmap as file qrImage.SaveAs("qrURLMarginMultiple.png"); Imports IronQr Imports IronSoftware.Drawing Private styleOptions As New QrStyleOptions() With {.Margins = 20} Private url As String = "https://ironsoftware.com/csharp/qr/" ' Create QR code Private qr As QrCode = QrWriter.Write(url) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save(styleOptions) ' Save QR code bitmap as file qrImage.SaveAs("qrURLMarginMultiple.png") $vbLabelText $csharpLabel Change Margins for Each Side IronQR also allows users to specify different margins for each side, providing more fine-grained control. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-14.cs using IronQr; using IronSoftware.Drawing; QrStyleOptions styleOptions = new QrStyleOptions() { // Change margins MarginBottom = 30, MarginTop = 100, MarginRight = 40, MarginLeft = 20, }; string url = "https://ironsoftware.com/csharp/qr/"; // Create QR code QrCode qr = QrWriter.Write(url); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(styleOptions); // Save QR code bitmap as file qrImage.SaveAs("qrURLMarginMultiple.png"); Imports IronQr Imports IronSoftware.Drawing Private styleOptions As New QrStyleOptions() With { .MarginBottom = 30, .MarginTop = 100, .MarginRight = 40, .MarginLeft = 20 } Private url As String = "https://ironsoftware.com/csharp/qr/" ' Create QR code Private qr As QrCode = QrWriter.Write(url) ' Save QR code as a bitmap Private qrImage As AnyBitmap = qr.Save(styleOptions) ' Save QR code bitmap as file qrImage.SaveAs("qrURLMarginMultiple.png") $vbLabelText $csharpLabel Recolor We can add colors to the QR code and its background using the QrStyleOptions class. Customizing colors makes the QR code more unique and eye-catching. You can change the color using the Color and BackgroundColor properties. Be sure to import IronSoftware.Drawing for a list of available colors to assign. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-15.cs using IronQr; using IronSoftware.Drawing; // Load new logo image AnyBitmap logo = AnyBitmap.FromFile("sample.png"); // Add new logo to QR code style options QrStyleOptions styleOptions = new QrStyleOptions() { Logo = new QrLogo(logo, 50, 50, 10), }; string url = "https://ironsoftware.com/csharp/qr/"; // Create QR code QrCode qr = QrWriter.Write(url); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(styleOptions); // Save QR code bitmap as file qrImage.SaveAs("qrURLColored.png"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Add a Logo In addition to colors and dimensions, you can also apply your company logo to the QR code. This helps users immediately recognize and associate the QR code with your brand. The Logo property makes it easy to customize a QR code by adding your company’s logo. :path=/static-assets/qr/content-code-examples/tutorials/csharp-qr-writing-15.cs using IronQr; using IronSoftware.Drawing; // Load new logo image AnyBitmap logo = AnyBitmap.FromFile("sample.png"); // Add new logo to QR code style options QrStyleOptions styleOptions = new QrStyleOptions() { Logo = new QrLogo(logo, 50, 50, 10), }; string url = "https://ironsoftware.com/csharp/qr/"; // Create QR code QrCode qr = QrWriter.Write(url); // Save QR code as a bitmap AnyBitmap qrImage = qr.Save(styleOptions); // Save QR code bitmap as file qrImage.SaveAs("qrURLColored.png"); IRON VB CONVERTER ERROR developers@ironsoftware.com $vbLabelText $csharpLabel Customize the Logo The QrLogo class allows further customization of the logo's appearance. Below are the available properties: Bitmap: Represents the image you want to use as the logo. Width: Represents the logo’s width. The default value is 0. Height: Represents the logo’s height. The default value is 0. CornerRadius: Represents the radius for rounding the logo’s corners. By default, it's set to 0, meaning the logo will have square corners. using IronQRCode; using IronSoftware.Drawing; class Program { static void Main() { QrStyleOptions styleOptions = new QrStyleOptions { Logo = new QrLogo { Bitmap = AnyBitmap.FromBitmap("path/to/logo.png"), Width = 50, Height = 50, CornerRadius = 5 } }; QrCode qr = QrWriter.CreateQrCode() .Write("Customized Logo Example"); qr.SaveAs("example-customized-logo-qr.png", styleOptions); } } using IronQRCode; using IronSoftware.Drawing; class Program { static void Main() { QrStyleOptions styleOptions = new QrStyleOptions { Logo = new QrLogo { Bitmap = AnyBitmap.FromBitmap("path/to/logo.png"), Width = 50, Height = 50, CornerRadius = 5 } }; QrCode qr = QrWriter.CreateQrCode() .Write("Customized Logo Example"); qr.SaveAs("example-customized-logo-qr.png", styleOptions); } } Imports IronQRCode Imports IronSoftware.Drawing Friend Class Program Shared Sub Main() Dim styleOptions As New QrStyleOptions With { .Logo = New QrLogo With { .Bitmap = AnyBitmap.FromBitmap("path/to/logo.png"), .Width = 50, .Height = 50, .CornerRadius = 5 } } Dim qr As QrCode = QrWriter.CreateQrCode().Write("Customized Logo Example") qr.SaveAs("example-customized-logo-qr.png", styleOptions) End Sub End Class $vbLabelText $csharpLabel Checking Fault Tolerance Along with extensive flexibility in file formats and customizations, the flexibility extends to debugging and error-handling aspects. IronQR provides various tools for developers to handle exceptions and write unit tests to verify applications. CheckSums QR codes may sometimes become damaged, but IronQR includes built-in checksums and data correction to keep them functional. It uses the Reed-Solomon error correction algorithm, ensuring that QR codes remain fault-tolerant. Detailed Error Messages IronQR provides detailed error messages that help users quickly identify issues. These messages contain a list of specific exceptions, making debugging and problem-solving more straightforward. Below is a list of IronQrException used by the library. IronQrEncodingException: A subclass of IronQrException, this error occurs when there is an issue with writing the QR code. For instance, it will appear if a user attempts to create a QR code from an empty string. IronQrFileException: A subclass of IronQrException, this error occurs when a file-related issue arises. IronQrPdfPasswordExcception: A subclass of IronQrException, this error occurs when the PDF a user is trying to stamp is password-protected, and either no password or an incorrect password is provided. It also covers other PDF-related errors, such as when the PDF cannot be opened, as shown in the example. Conclusion IronQR provides a comprehensive set of methods for generating and customizing QR codes within .NET applications. With its robust features, developers can easily create QR codes with various data encodings, visual styles, and error correction levels. The library's support for diverse output formats and seamless integration into existing documents makes it a versatile tool for any QR code project. Whether you need basic QR codes or advanced, branded solutions, IronQR offers the flexibility and functionality to meet your needs efficiently. To learn more, check out the IronQR documentation, start exploring with a free trial, and review the licensing options to see which plan best suits your needs. 常見問題解答 如何在 C# 中生成 QR 代碼? 您可以通過使用 IronQR 中可用的 QrWriter 類在 C# 中生成 QR 碼。此類允許您將數據寫入 QR 碼並將其保存為各種圖像格式。只需使用 Write 方法編碼您的數據,再使用 SaveAs 輸出 QR 碼。 我可以對 QR 碼進行哪些客製化? IronQR 允許您通過更改顏色、添加徽標、調整大小和調整邊距來自定義 QR 碼。使用 QrStyleOptions 類來應用這些自定義。 我可以使用 C# 將 QR 碼嵌入到 PDF 中嗎? 是的,您可以通過使用 IronQR 的 StampToExistingPdfPage 或 StampToExistingPdfPages 方法將 QR 碼嵌入到 PDF 中。這允許您指定 QR 碼應出現的位置和頁面。 如何在創建 QR 碼時處理錯誤? IronQR 具有強大的錯誤處理功能,提供錯誤消息如 IronQrEncodingException、IronQrFileException 和 IronQrPdfPasswordException,以協助調試和解決問題。 我可以將 QR 碼導出到什麼格式? 使用 IronQR,您可以將 QR 碼導出為多種格式,包括 JPG、PNG、GIF 和 TIFF。SaveAs 方法允許您指定 QR 碼輸出的所需格式。 此庫是否支援跨平台開發? 是的,IronQR 通過 Iron Software.Drawing 庫支持跨平台開發,使其兼容不同的 .NET 版本和平台。 可以為 QR 碼添加徽標以進行品牌化嗎? 您可以通過在 QrStyleOptions 類中設置 Logo 屬性來使用 IronQR 為 QR 碼添加徽標,允許使用定制徽標外觀的品牌 QR 碼。 錯誤更正在 QR 碼中的目的是什麼? IronQR 支持的 QR 碼錯誤更正確保即使在部分損壞的情況下也可以讀取 QR 碼。此功能提供四個更正級別:最高、高、中和低級,以適應不同的用例。 可以編碼到 QR 碼中的數據類型有哪些? IronQR 可以將多種數據類型編碼為 QR 碼,包括文本、URL、數字、二進位數據和流,提供靈活的數據表示。 如何使用 C# 創建帶有 URL 的 QR 碼? 要使用 C# 創建帶有 URL 的 QR 碼,請使用 IronQR 中的 QrWriter 類。使用 Write 方法編碼 URL,再使用 SaveAs 將 QR 碼保存為圖像。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 47,669 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:47,669 查看許可證