C#에서 PDF의 바코드를 읽는 방법
IronBarcode는 PDF 문서에서 이미지로 먼저 변환할 필요 없이 직접 바코드를 읽을 수 있게 하며, ReadPdf 메서드를 사용하여 송장, 배송 라벨 및 보고서에서 바코드 데이터를 한 줄의 코드로 추출합니다.
PDF 문서에서 바코드를 읽는 것은 PDF 페이지 내에서 바코드를 감지하고 디코딩하는 것을 의미합니다. 이 기술은 인쇄된 바코드의 수동 스캔을 필요로 하지 않고, 디지털 문서에서 인코딩된 정보를 직접 추출합니다. 이는 송장, 배송 라벨, 보고서 및 바코드 데이터를 포함한 다른 문서 처리 워크플로우를 자동화합니다.
빠른 시작: PDF에서 직접 바코드 읽기IronBarcode의 ReadPdf 메서드를 사용하여 이미지로 변환하지 않고 PDF에서 바코드를 읽습니다. 한 줄의 코드로 바코드 데이터를 추출하고 필요에 따라 고급 옵션을 추가하세요.
-
1IronBarcode를 NuGet Package Manager로 설치하십시오
-
2다음 코드 조각을 복사하여 실행하세요.
var results = IronBarCode.BarcodeReader.ReadPdf("invoice.pdf");Dim results = IronBarCode.BarcodeReader.ReadPdf("invoice.pdf")Dim results = IronBarCode.BarcodeReader.ReadPdf("invoice.pdf") -
3실제 운영 환경에서 테스트할 수 있도록 배포하세요.
오늘 프로젝트에서 IronBarcode 사용을 시작해보세요 무료 체험
PDF 바코드를 읽는 기본 단계는 무엇입니까?
- 바코드 파일을 처리하기 위해 바코드 라이브러리를 설치하세요. 플랫폼별 설치를 위한 NuGet 패키지 가이드를 확인하세요.
- 필요하면
PdfBarcodeReaderOptions을 생성합니다. ReadPdf메서드를BarcodeReader에서 사용하여 PDF에서 바코드를 읽습니다.BarcodeReaderOption을 사용하여 추가 바코드 읽기 옵션을 지정합니다.- 바코드 값을 추출하세요.
PDF 문서에서 바코드를 직접 어떻게 읽습니까?
IronBarcode는 이미지로 변환할 필요 없이 PDF 문서에서 직접 바코드를 읽습니다. 모든 기능에 대한 종합적인 개요를 보려면 기능 페이지를 방문하세요. 다음과 같은 PDF 입력 유형을 허용하는 BarcodeReader.ReadPdf() 메서드를 사용하세요:
byte[]배열: 바이트 배열로서의 PDF 문서.IEnumerable<Byte[]>: 컬렉션에 저장된 바이트 배열로서의 PDF 문서들.MemoryStream:MemoryStream형식으로서의 PDF 문서들.IEnumerable<Stream>:MemoryStream의 컬렉션으로서의 PDF 문서들. 스트림에서 바코드 읽기 가이드를 참조하세요.String: 문자열 또는 프로젝트에 복사된 파일 이름으로서의 PDF 문서 경로.IEnumerable<String>: 컬렉션에 저장된 경로/이름 문자열로서의 PDF 문서.
BarcodeReader.ReadPdf() 메서드는 또한 고급 읽기 기능을 위한 PdfBarcodeReaderOptions을 허용하며, 다음 절에서 논의됩니다. PDF 문서의 바코드를 읽기 위해 BarcodeReader.ReadPdf()을 사용하는 방법은 다음과 같습니다:
using IronBarCode;
using System;
using System.Collections.Generic;
List<String> docs = new List<String>();
docs.Add(@"pdf_a.pdf");
docs.Add(@"pdf_b.pdf");
var myBarcode = BarcodeReader.ReadPdfs(docs); //can also accept individual PDF document file path as argument
foreach (var value in myBarcode)
{
Console.WriteLine(value.ToString());
}using IronBarCode;
using System;
using System.Collections.Generic;
List<String> docs = new List<String>();
docs.Add(@"pdf_a.pdf");
docs.Add(@"pdf_b.pdf");
var myBarcode = BarcodeReader.ReadPdfs(docs); //can also accept individual PDF document file path as argument
foreach (var value in myBarcode)
{
Console.WriteLine(value.ToString());
}Imports IronBarCode
Imports System
Imports System.Collections.Generic
Private docs As New List(Of String)()
docs.Add("pdf_a.pdf")
docs.Add("pdf_b.pdf")
Dim myBarcode = BarcodeReader.ReadPdfs(docs) 'can also accept individual PDF document file path as argument
For Each value In myBarcode
Console.WriteLine(value.ToString())
Next valueImports IronBarCode
Imports System
Imports System.Collections.Generic
Private docs As New List(Of String)()
docs.Add("pdf_a.pdf")
docs.Add("pdf_b.pdf")
Dim myBarcode = BarcodeReader.ReadPdfs(docs) 'can also accept individual PDF document file path as argument
For Each value In myBarcode
Console.WriteLine(value.ToString())
Next value바코드 값을 읽기 위해 PDF 파일 경로 문자열을 BarcodeReader.ReadPdf()에 전달합니다. 다양한 출처에서 바코드를 읽는 더 많은 예제를 보려면 C# / .NET 에서 바코드 읽기 튜토리얼을 확인하세요. PDF에서 발견된 모든 바코드 값을 인쇄하려면 foreach 루프를 통해 결과를 반복하고 각 요소에 대해 ToString()을 호출합니다. 이 예는 또한 메소드 인자로 PDF 문서 이름의 컬렉션을 사용하는 것을 보여줍니다.
여러 PDF를 한 번에 어떻게 읽을 수 있습니까?
IronBarcode는 여러 PDF를 동시에 처리할 수 있는 ReadPdfs 메서드를 제공합니다. 이 메소드는 PDF 목록에서 바코드를 효율적으로 추출합니다. 문서 내 여러 바코드를 처리하는 방법에 대한 가이드는 다중 바코드 읽기를 참조하세요.
using IronBarCode;
using System;
using System.Collections.Generic;
using System.IO;
// Get all PDF files from a directory and add to list
string folderPath = @"PATH_TO_YOUR_FOLDER";
List<string> docs = new List<string>(Directory.GetFiles(folderPath, "*.pdf"));
// Read barcodes from all PDFs
var docResult = BarcodeReader.ReadPdfs(docs);
// Print results
foreach (var doc in docResult)
{
foreach (var item in doc)
{
Console.WriteLine("Barcode " + item.ToString() + " found at page " + item.PageNumber);
}
}using IronBarCode;
using System;
using System.Collections.Generic;
using System.IO;
// Get all PDF files from a directory and add to list
string folderPath = @"PATH_TO_YOUR_FOLDER";
List<string> docs = new List<string>(Directory.GetFiles(folderPath, "*.pdf"));
// Read barcodes from all PDFs
var docResult = BarcodeReader.ReadPdfs(docs);
// Print results
foreach (var doc in docResult)
{
foreach (var item in doc)
{
Console.WriteLine("Barcode " + item.ToString() + " found at page " + item.PageNumber);
}
}Imports IronBarCode
Imports System
Imports System.Collections.Generic
Imports System.IO
' Get all PDF files from a directory and add to list
Dim folderPath As String = "PATH_TO_YOUR_FOLDER"
Dim docs As New List(Of String)(Directory.GetFiles(folderPath, "*.pdf"))
' Read barcodes from all PDFs
Dim docResult = BarcodeReader.ReadPdfs(docs)
' Print results
For Each doc In docResult
For Each item In doc
Console.WriteLine("Barcode " & item.ToString() & " found at page " & item.PageNumber)
Next
NextImports IronBarCode
Imports System
Imports System.Collections.Generic
Imports System.IO
' Get all PDF files from a directory and add to list
Dim folderPath As String = "PATH_TO_YOUR_FOLDER"
Dim docs As New List(Of String)(Directory.GetFiles(folderPath, "*.pdf"))
' Read barcodes from all PDFs
Dim docResult = BarcodeReader.ReadPdfs(docs)
' Print results
For Each doc In docResult
For Each item In doc
Console.WriteLine("Barcode " & item.ToString() & " found at page " & item.PageNumber)
Next
Next이 코드는 디렉터리에서 모든 PDF 파일을 검색하여 List<string>에 추가하고 목록을 입력값으로 ReadPdfs을 호출합니다. 메서드는 BarcodeResults의 배열을 반환합니다. 결과를 반복하여 각 PDF에서 바코드를 액세스하세요.
PDF 바코드 리더 옵션을 어떻게 구성합니까?
PdfBarcodeReaderOptions을 사용하여 PDF에서 바코드를 읽도록 구성합니다. 모든 리더 설정에 대한 자세한 설명은 PDF 바코드 리더 옵션 설정 예제를 방문하세요. 이 속성을 조정하면 품질, 정확성, 성능이 향상됩니다. PdfBarcodeReaderOptions은 모든 BarcodeReaderOptions 속성을 상속하며 PDF 전용 옵션을 추가합니다. 페이지 번호를 PdfBarcodeReaderOptions 인스턴스화할 때 지정합니다:
using IronBarCode;
using System.Collections.Generic;
List<int> pageNumber = new List<int>() { 1, 2, 3 };
PdfBarcodeReaderOptions PdfOptions = new PdfBarcodeReaderOptions(pageNumber) // can also use individual page number as argument
{
// Properties of PDF Barcode reader options
};using IronBarCode;
using System.Collections.Generic;
List<int> pageNumber = new List<int>() { 1, 2, 3 };
PdfBarcodeReaderOptions PdfOptions = new PdfBarcodeReaderOptions(pageNumber) // can also use individual page number as argument
{
// Properties of PDF Barcode reader options
};Imports IronBarCode
Imports System.Collections.Generic
Private pageNumber As New List(Of Integer)() From {1, 2, 3}
Private PdfOptions As New PdfBarcodeReaderOptions(pageNumber)Imports IronBarCode
Imports System.Collections.Generic
Private pageNumber As New List(Of Integer)() From {1, 2, 3}
Private PdfOptions As New PdfBarcodeReaderOptions(pageNumber)PdfBarcodeReaderOptions에서 BarcodeReaderOptions으로부터 상속된 속성 이외의 추가 속성을 탐색합니다.
DPI 설정이 바코드 읽기에 어떻게 영향을 미칩니까?
PDF 문서의 바코드 이미지의 DPI(Dots Per Inch)를 설정하세요. 이는 저품질 바코드 읽기를 개선합니다. 정수값을 사용하세요. 기본 DPI는 150입니다. 더 작은 또는 저품질 바코드의 경우, 인식을 개선하기 위해 300 또는 600으로 증가시키세요. 높은 DPI 값은 처리 시간과 메모리 사용량을 증가시킵니다.
페이지 번호를 언제 지정해야 하나요?
특히 다중 페이지 PDF의 경우 성능을 향상시키기 위해 바코드를 포함하는 페이지 번호를 지정하세요. 특정 페이지 번호를 제공할 때 IronBarcode는 바코드가 없는 페이지를 건너뜁니다. 페이지 번호는 1부터 시작합니다(첫 페이지는 0이 아닌 1입니다). 대용량 문서를 위한 최적화 기술은 읽기 속도 옵션 가이드를 참조하세요.
암호로 보호된 PDF 파일은 어떻게 처리해야 하나요?
암호화된 PDF 파일과 작업하려면 문자열 입력으로 비밀번호를 제공하세요. IronBarcode는 PDF 암호를 검색할 수 없습니다. 필요한 권한을 확인하고 애플리케이션에서 비밀번호를 안전하게 저장하세요.
작은 바코드에 어떤 스케일 팩터를 사용해야 하나요?
이미지로 변환할 때 너비와 높이에 대한 스케일 팩터를 제어하세요. 기본값 3.5를 가진 정수 값을 허용합니다. 높은 스케일 팩터는 PDF를 확대하여 작은 바코드를 읽는 데 도움이 됩니다. 1인치 미만의 바코드에는 스케일 팩터 5.0 이상을 사용하세요. 높은 스케일 팩터는 성능에 영향을 미칩니다.
PDF에서 고급 바코드 읽기를 구현하려면 어떻게 해야 하나요?
프로젝트에서 바코드 인식을 강화하기 위해 PdfBarcodeReaderOptions 속성을 적용하세요. 바코드가 인식되지 않을 때의 추가 문제 해결 팁은 바코드 인식 안 됨 가이드를 참조하세요.
using IronBarCode;
using System;
using System.Collections.Generic;
List<int> pageNumber = new List<int>() { 1, 2, 3 };
PdfBarcodeReaderOptions PdfOptions = new PdfBarcodeReaderOptions(pageNumber)
{
DPI = 150,
//PageNumbers = pageNumber, //this property is not needed if page numbers has been specified as the argument in PdfBarcodeReaderOptions
Password = "barcode",
Scale = 3.5,
//properties below are some of the properties inherited from BarcodeReaderOptions
Speed = ReadingSpeed.Detailed,
ExpectBarcodeTypes = BarcodeEncoding.Code93,
ExpectMultipleBarcodes = true
};
var myBarcode = BarcodeReader.ReadPdf(@"pdf_a_filepath.pdf", PdfOptions);
foreach (var value in myBarcode)
{
Console.WriteLine(value.ToString());
}using IronBarCode;
using System;
using System.Collections.Generic;
List<int> pageNumber = new List<int>() { 1, 2, 3 };
PdfBarcodeReaderOptions PdfOptions = new PdfBarcodeReaderOptions(pageNumber)
{
DPI = 150,
//PageNumbers = pageNumber, //this property is not needed if page numbers has been specified as the argument in PdfBarcodeReaderOptions
Password = "barcode",
Scale = 3.5,
//properties below are some of the properties inherited from BarcodeReaderOptions
Speed = ReadingSpeed.Detailed,
ExpectBarcodeTypes = BarcodeEncoding.Code93,
ExpectMultipleBarcodes = true
};
var myBarcode = BarcodeReader.ReadPdf(@"pdf_a_filepath.pdf", PdfOptions);
foreach (var value in myBarcode)
{
Console.WriteLine(value.ToString());
}Imports IronBarCode
Imports System
Imports System.Collections.Generic
Private pageNumber As New List(Of Integer)() From {1, 2, 3}
Private PdfOptions As New PdfBarcodeReaderOptions(pageNumber) With {
.DPI = 150,
.Password = "barcode",
.Scale = 3.5,
.Speed = ReadingSpeed.Detailed,
.ExpectBarcodeTypes = BarcodeEncoding.Code93,
.ExpectMultipleBarcodes = True
}
Private myBarcode = BarcodeReader.ReadPdf("pdf_a_filepath.pdf", PdfOptions)
For Each value In myBarcode
Console.WriteLine(value.ToString())
Next valueImports IronBarCode
Imports System
Imports System.Collections.Generic
Private pageNumber As New List(Of Integer)() From {1, 2, 3}
Private PdfOptions As New PdfBarcodeReaderOptions(pageNumber) With {
.DPI = 150,
.Password = "barcode",
.Scale = 3.5,
.Speed = ReadingSpeed.Detailed,
.ExpectBarcodeTypes = BarcodeEncoding.Code93,
.ExpectMultipleBarcodes = True
}
Private myBarcode = BarcodeReader.ReadPdf("pdf_a_filepath.pdf", PdfOptions)
For Each value In myBarcode
Console.WriteLine(value.ToString())
Next value변수 이름으로 PdfBarcodeReaderOptions을 초기화하여 속성을 접근하고 조정합니다. 초기화 시 페이지 번호를 인수로 전달하여 특정 페이지에 설정을 적용하세요. 또는 PageNumbers 속성을 사용하여 페이지 번호를 설정합니다.
성능과 정확성을 향상시키기 위해 BarcodeReaderOptions 속성에서 상속된 ExpectMultipleBarcodes 및 ExpectBarcodeTypes 속성을 사용하세요. 구성된 PdfBarcodeReaderOptions을 첫 번째 인수로 PDF 파일 경로를, 두 번째 인수로 BarcodeReader.ReadPdf()에 전달하여 적용합니다.
불완전하거나 손상된 바코드를 포함한 PDF를 처리하려면 PDF 처리 중에 적용할 수 있는 이미지 보정 기능을 탐색하세요.
자주 묻는 질문
C#를 사용하여 PDF 파일에서 바코드를 읽을 수 있는 방법은 무엇입니까?
IronBarcode 라이브러리를 사용하여 PDF 파일에서 바코드를 읽을 수 있으며, 이 라이브러리는 ReadPdf 메서드를 제공하여 PDF 문서에서 이미지를 변환할 필요 없이 바코드 데이터를 직접 추출할 수 있습니다.
여러 PDF 파일을 한 번에 읽으려면 어떤 메서드를 사용해야 하나요?
IronBarcode의 ReadPdfs 메서드를 사용하여 여러 PDF 파일에서 바코드를 동시에 처리하고 추출하십시오. 이 메서드는 PDF 문서 목록을 효율적으로 처리합니다.
PDF 파일에 대한 바코드 리더 옵션을 어떻게 구성합니까?
PdfBarcodeReaderOptions 클래스를 사용하여 DPI, 특정 페이지 번호 및 기타 고급 옵션과 같은 속성을 설정하여 바코드 읽기 정확도와 성능을 향상시킬 수 있습니다.
PDF 문서에 암호가 설정되어 있는 경우 어떻게 해야 하나요?
암호가 설정된 PDF 문서에 대해서는, IronBarcode에 문자열 입력으로 암호를 제공하세요. 적절한 권한을 가지고 있는지 확인하고 암호는 안전하게 저장하세요.
DPI 설정이 PDF에서 바코드 읽기에 어떤 영향을 미칩니까?
더 높은 DPI(Dots Per Inch)를 설정하면 PDF 문서의 저품질 바코드 가독성을 개선할 수 있습니다. DPI를 증가시키면 더 작거나 저품질의 바코드를 인식하는 데 도움이 되지만 처리 시간이 길어질 수 있습니다.
PDF에서 바코드를 읽을 때 페이지 번호를 지정해야 하나요?
페이지 번호를 지정하면 성능이 향상될 수 있습니다, 특히 여러 페이지의 PDF에서. IronBarcode는 바코드가 없는 페이지를 건너뛰어 읽기 프로세스를 최적화합니다.
다양한 유형의 PDF 입력 형식에서 바코드를 읽을 수 있나요?
IronBarcode의 ReadPdf 메서드는 문자열로 파일 경로, 바이트 배열 및 스트림을 포함한 다양한 PDF 입력 유형을 수락하여 여러 입력 소스를 처리할 수 있는 유연성을 제공합니다.
이미지로 변환하지 않고 PDF에서 바코드를 추출할 수 있나요?
네, IronBarcode는 ReadPdf 메서드를 사용하여 이미지 변환 없이 PDF 문서에서 직접 바코드를 추출할 수 있도록 합니다.
PDF의 작은 바코드에 권장되는 스케일 팩터는 무엇입니까?
5.0 이상의 더 높은 스케일 팩터가 작은 바코드를 읽는 데 권장되며, 이는 바코드 이미지를 확대하여 읽기 쉽게 만듭니다.
단일 PDF 문서에서 여러 바코드를 어떻게 처리할 수 있습니까?
PdfBarcodeReaderOptions의 ExpectMultipleBarcodes 속성을 사용하여 IronBarcode가 동일한 PDF 페이지 내에서 여러 바코드를 감지하고 디코딩하도록 지시할 수 있습니다.