Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,57 @@
---
date: 2026-01-15
description: 学习如何使用 Aspose.BarCode for .NET 在 Visual Studio 中创建条形码并进行条形码生成。提供代码示例的分步指南。
linktitle: Compact PDF417 Basic Configuration
date: 2026-05-30
description: 学习如何使用 Aspose.BarCode for .NET 在 Visual Studio 中创建条形码并进行条形码生成。提供带代码示例的分步指南。
keywords:
- how to create barcode
- barcode generation visual studio
- install aspose barcode .net
linktitle: Compact PDF417 基本配置
schemas:
- author: Aspose
dateModified: '2026-05-30'
description: Learn how to create barcode and perform barcode generation visual studio
using Aspose.BarCode for .NET. Step‑by‑step guide with code examples.
headline: How to Create Barcode – Compact PDF417 with Aspose.BarCode
type: TechArticle
- description: Learn how to create barcode and perform barcode generation visual studio
using Aspose.BarCode for .NET. Step‑by‑step guide with code examples.
name: How to Create Barcode – Compact PDF417 with Aspose.BarCode
steps:
- name: Set the Output Path
text: Define where the generated image will be saved. Replace `"Your Directory
Path"` with an absolute or relative folder on your machine. Ensure the folder
exists and the application has write permissions; otherwise you’ll encounter
an *Invalid path* error.
- name: Create the Barcode Generator
text: '`EncodeTypes.Pdf417` specifies the PDF417 barcode symbology. The `BarcodeGenerator`
class is Aspose.BarCode''s core engine for creating barcode images. Even though
we’re using the standard PDF417 type, we’ll configure it to behave as a Compact
PDF417 barcode by adjusting a few properties in the next '
- name: Configure Barcode Parameters
text: '`XDimension.Pixels` sets the width of a single module (X‑dimension) in
pixels. `Columns` defines the number of data columns in the barcode. Feel free
to experiment with these values to meet your specific size or data‑capacity
requirements. For example, decreasing `XDimension.Pixels` reduces overall '
- name: Save the Barcode Image
text: Finally, save the barcode as a PNG file (or any supported format). Give
the file a meaningful name and choose the format that best fits your application.
PNG is loss‑less and works well for web and print, but you can also output JPEG,
BMP, or TIFF if needed.
type: HowTo
- questions:
- answer: Aspose.BarCode for .NET, supporting over 50 barcode symbologies.
question: What is the primary library?
- answer: Visual Studio 2019, 2022, or any later version.
question: Which IDE is recommended?
- answer: Roughly 10 lines for a basic Compact PDF417 barcode.
question: How many lines of code are needed?
- answer: Yes—X‑dimension, column count, and truncation are fully configurable.
question: Can I adjust barcode dimensions?
- answer: A commercial license is mandatory for non‑trial deployments.
question: Is a license required for production?
type: FAQPage
second_title: Aspose.BarCode .NET API
title: 如何使用 Aspose.BarCode 创建紧凑型 PDF417 条码
title: 如何使用 Aspose.BarCode 创建条形码 – Compact PDF417
url: /zh/net/compact-pdf417-encoding/compact-pdf417-basic-configuration/
weight: 10
---
Expand All @@ -12,39 +60,56 @@ weight: 10
{{< blocks/products/pf/main-container >}}
{{< blocks/products/pf/tutorial-page-section >}}

# 如何使用 Aspose.BarCode for .NET 创建紧凑型 PDF417 条码
# 如何使用 Aspise.BarCode for .NET 创建条形码 – 紧凑型 PDF417

## 介绍
## 简介

如果你是一名希望在 .NET 项目中 **创建条码** 图像的开发者,Aspose.BarCode for .NET 是一个强大的解决方案,可让此任务变得简单直观。在本教程中,我们将演示如何生成紧凑型 PDF417 条码——一种在物流、库存跟踪和票务中常用的空间高效的 2‑D 符号。完成后,你将能够直接在 Visual Studio 中生成并自定义紧凑型 PDF417 条码,全面掌控尺寸、数据密度和外观。
如果您是一名希望在 .NET 项目中 **how to create barcode** 图像的开发者,Aspose.BarCode for .NET 是一个强大的解决方案,使任务变得简单直观。在本教程中,我们将演示生成紧凑型 PDF417 条码——一种在物流、库存跟踪和票务中常用的节省空间的 2‑D 符号。完成后,您将能够直接从 Visual Studio 生成并自定义紧凑型 PDF417 条码,全面控制尺寸、数据密度和外观。您可以从主站点 [here](https://releases.aspose.com/) 下载最新的 Aspose 发布

## 快速答案
- **主要库是什么?** Aspose.BarCode for .NET
- **推荐使用的 IDE?** Visual Studio(任意近期版本)
- **需要多少行代码?** 基础条码约 10 行代码
- **可以调整条码尺寸吗?** 可以,X‑dimension、列数和截断均可配置
- **生产环境需要许可证吗?** 商业许可证是非试用情况下的必需品

## 前置条件
- **主要库是什么?** Aspose.BarCode for .NET, supporting over 50 barcode symbologies.
- **推荐使用哪个 IDE?** Visual Studio 2019, 2022, or any later version.
- **需要多少行代码?** Roughly 10 lines for a basic Compact PDF417 barcode.
- **我可以调整条码尺寸吗?** Yes—X‑dimension, column count, and truncation are fully configurable.
- **生产环境是否需要许可证?** A commercial license is mandatory for non‑trial deployments.

在开始之前,请确保具备以下条件:
## 什么是紧凑型 PDF417?

1. **Visual Studio** – 已安装 Visual Studio(2019、2022 或更高版本),用于 **条码生成 Visual Studio** 开发。
2. **Aspose.BarCode for .NET** – 从官方网站下载并安装该库。下载链接请参见 [here](https://releases.aspose.com/barcode/net/)。
3. **基本的 C# 知识** – 本指南假设你熟悉 C# 语法和项目设置。
4. **文本编辑器** – 虽然推荐使用 Visual Studio,任何支持 C# 的编辑器均可使用。
紧凑型 PDF417 是一种高容量的 2‑D 条码,与标准 PDF417 相比,可在更小的占用空间内存储多达 1,800 个字符。当空间受限但数据密度必须保持高时,它非常适合,例如在小型产品标签或登机牌上。

## 为什么选择使用 Aspose.BarCode 的紧凑型 PDF417?

Aspose.BarCode 支持 **50+ barcode types**,并且能够在单个紧凑型 PDF417 符号中编码 **up to 2,000 characters**,同时将图像大小控制在 200 KB 以下。该库能够在不将整个文件加载到内存的情况下处理数百页的文档,在典型服务器硬件上实现亚秒级的生成时间。

## 先决条件

在开始之前,请确保您具备以下条件:

1. **Visual Studio** – 一个可正常使用的 Visual Studio(2019、2022 或更高版本)安装,用于 **barcode generation visual studio** 开发。
2. **Aspose.BarCode for .NET** – 从官方网站下载并安装该库。您可以在此找到下载链接 [here](https://releases.aspose.com/barcode/net/)。
3. **Basic C# knowledge** – 本指南假设您熟悉 C# 语法和项目设置。
4. **A text editor** – 虽然推荐使用 Visual Studio,但任何支持 C# 的编辑器都可以使用。

## 导入命名空间

首先,在 C# 文件中添加所需的命名空间,以便访问条码生成类:
首先,将所需的命名空间添加到您的 C# 文件中,以便访问条码生成类:

```csharp
using Aspose.BarCode.Generation;
```

```csharp
using Aspose.BarCode.Generation;
```

现在可以开始构建紧凑型 PDF417 条码了。
现在您可以开始构建紧凑型 PDF417 条码了。

## 步骤指南
## 如何在 .NET 中生成紧凑型 PDF417 条码?

使用 `EncodeTypes.Pdf417` 类型加载 `BarcodeGenerator`,设置数据字符串,启用紧凑模式,然后调用 `Save`——全部代码不超过十行。这种方法为您提供了一个可直接使用的 PNG(或任何受支持的格式),可嵌入报告、打印在标签上或发送到移动设备。

## 分步指南

### 步骤 1:设置输出路径

Expand All @@ -54,29 +119,31 @@ using Aspose.BarCode.Generation;
string path = "Your Directory Path";
```

将 `"Your Directory Path"` 替换为机器上的绝对或相对文件夹路径
将 `"Your Directory Path"` 替换为您机器上的绝对或相对文件夹路径。确保该文件夹存在且应用程序具有写入权限;否则您会遇到 *Invalid path* 错误

### 步骤 2:创建条码生成器

实例化 `BarcodeGenerator`,选择 PDF417 类型,并提供要编码的数据。
`EncodeTypes.Pdf417` 指定 PDF417 条码符号。
`BarcodeGenerator` 类是 Aspose.BarCode 用于创建条码图像的核心引擎。

```csharp
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Pdf417, "Åspóse.Barcóde©");
```

虽然我们使用的是标准 PDF417 类型,但随后会将其配置为紧凑型 PDF417 条码。
虽然我们使用的是标准 PDF417 类型,但将在下一步通过调整几个属性将其配置为紧凑型 PDF417 条码。

### 步骤 3:配置条码参数

调整 X‑dimension、列数,并启用截断,以生成紧凑版本。
`XDimension.Pixels` 设置单个模块(X‑dimension)的宽度(像素)。
`Columns` 定义条码中的数据列数。

```csharp
gen.Parameters.Barcode.XDimension.Pixels = 2;
gen.Parameters.Barcode.Pdf417.Columns = 3;
gen.Parameters.Barcode.Pdf417.Pdf417Truncate = true;
```

根据具体的尺寸或数据容量需求,随意尝试这些数值
请随意尝试这些数值,以满足您的特定尺寸或数据容量需求。例如,减小 `XDimension.Pixels` 会降低整体宽度,而增加 `Columns` 会在每行中添加更多数据

### 步骤 4:保存条码图像

Expand All @@ -86,46 +153,56 @@ gen.Parameters.Barcode.Pdf417.Pdf417Truncate = true;
gen.Save($"{path}CompactPdf417Basic.png", BarCodeImageFormat.Png);
```

为文件取一个有意义的名称,并选择最适合你应用的格式
为文件取一个有意义的名称,并选择最适合您应用的格式。PNG 是无损的,适用于网页和打印,但如果需要,也可以输出 JPEG、BMP 或 TIFF

## 常见问题与技巧

- **路径无效** – 确认目录存在且应用拥有写入权限。
- **不支持的字符** – PDF417 支持 Unicode,但某些特殊符号可能需要转义。
- **图像尺寸过大** – 降低 `XDimension.Pixels` 或减少列数以缩小条码。
- **Invalid path** – 确保目录存在且应用程序具有写入权限。
- **Unsupported characters** – PDF417 支持 Unicode,但某些特殊符号可能需要转义。
- **Image size too large** – 减少 `XDimension.Pixels` 或降低列数以缩小条码。
- **Performance on large batches** – 重用同一个 `BarcodeGenerator` 实例,仅在保存之间更改 `CodeText` 属性,以最小化对象创建开销。

## 结论
## 常见问题

现在,你已经掌握了使用 Aspose.BarCode for .NET **创建条码** 图像的技巧,特别是紧凑型 PDF417 变体。此方法可在 Visual Studio 中无缝运行,让你全面控制条码外观和数据编码。欢迎探索其他条码类型(QR Code、Code 128 等),并根据业务需求微调参数。
### Q1:我可以在 Web 和桌面应用程序中使用 Aspose.BarCode for .NET 吗?

如果遇到任何问题,Aspose.BarCode 社区是提问的好去处——访问 [forum](https://forum.aspose.com/c/barcode/13) 获取帮助
**A:** 是的,该库可在 ASP.NET、WinForms、WPF 以及其他 .NET 应用类型中使用

## 常见问答
### Q2:我还能使用 Aspose.BarCode for .NET 生成哪些其他条码类型?

### Q1:我可以在 Web 和桌面应用中同时使用 Aspose.BarCode for .NET 吗?
**A:** 可以,库支持 ASP.NET、WinForms、WPF 以及其他 .NET 应用类型。
**A:** 它支持 QR Code、Code 128、Code 39、DataMatrix、Aztec 等众多类型,总计超过 50 种符号。

### Q2:Aspose.BarCode for .NET 能生成哪些其他条码类型?
**A:** 支持 QR Code、Code 39、Code 128、DataMatrix、Aztec 等多种条码。
### Q3:Aspose.BarCode for .NET 有免费试用版吗?

### Q3:Aspose.BarCode for .NET 有免费试用版吗?
**A:** 有,你可以在此处获取免费试用版 [here](https://releases.aspose.com/).
**A:** 是的,您可以在此获取 Aspose.BarCode for .NET 的免费试用版 [here](https://releases.aspose.com/)。

### Q4:如何购买 Aspose.BarCode for .NET 的许可证?
**A:** 可通过 Aspose 商店购买许可证,链接在此 [here](https://purchase.aspose.com/buy)。
### Q4:如何购买 Aspose.BarCode for .NET 的许可证?

### Q5:是否有额外的资源或文档可供参考?
**A:** 详细的 API 文档和代码示例请访问 [here](https://reference.aspose.com/barcode/net/)。
**A:** 许可证可通过 Aspose 商店购买 [here](https://purchase.aspose.com/buy)。

### Q5:是否有 Aspose.BarCode for .NET 的其他资源或文档?

**A:** 详细的 API 文档和代码示例可在此获取 [here](https://reference.aspose.com/barcode/net/)。

## 结论

您现在已经学习了使用 Aspose.BarCode for .NET 创建 **how to create barcode** 图像的方法,特别是紧凑型 PDF417 变体。此方法可在 Visual Studio 中无缝运行,让您全面控制条码外观和数据编码。欢迎探索其他条码类型(QR Code、Code 128 等),并根据业务需求调整参数。如果遇到任何挑战,Aspose.BarCode 社区是提问的好地方——请访问 [forum](https://forum.aspose.com/c/barcode/13) 获取帮助。

---

**最后更新:** 2026-01-15
**最后更新:** 2026-05-30
**测试环境:** Aspose.BarCode 24.11 for .NET
**作者:** Aspose

{{< /blocks/products/pf/tutorial-page-section >}}
{{< blocks/products/products-backtop-button >}}

## 相关教程

- [Aspose.BarCode for .NET 的综合教程和示例](/barcode/net/)
- [使用 Aspose.BarCode for .NET 的 Aztec 编码文本](/barcode/net/aztec-barcode-encoding/aztec-code-text-encoding/)
- [如何使用 Aspose.BarCode for .NET 为 Code 16K 创建条码安静区](/barcode/net/code-16k-encoding/code-16k-quiet-zone-settings/)

{{< /blocks/products/pf/main-container >}}
{{< /blocks/products/pf/main-wrap-class >}}

{{< blocks/products/products-backtop-button >}}
{{< /blocks/products/pf/tutorial-page-section >}}
{{< /blocks/products/pf/main-container >}}
{{< /blocks/products/pf/main-wrap-class >}}
Loading