Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
وفقًا لنموذج كائن المستندات من Aspose.PDF for .NET، يحتوي ملف PDF على صفحة واحدة أو أكثر حيث تحتوي كل صفحة على مجموعة من الصور والنماذج والخطوط في كائن الموارد. لذلك، لاستخراج الصور من ملف PDF، سنقوم بالتنقل عبر الصفحات الفردية لملف PDF، والحصول على مجموعة الصور من صفحة معينة وحفظها في كائن MemoryStream لمزيد من المعالجة باستخدام فئة BarCodeReader من Aspose.BarCodeRecognition.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void IdentifyBarcodes()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "IdentifyBarcodes.pdf"))
{
// Traverse through individual pages of PDF file
for (int pageCount = 1; pageCount <= document.Pages.Count; pageCount++)
{
// Traverse through each image extracted from PDF pages
foreach (var xImage in document.Pages[pageCount].Resources.Images)
{
using (var imageStream = new MemoryStream())
{
// Save PDF document image
xImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
// Set the stream position to the begining of Stream
imageStream.Position = 0;
// Instantiate BarCodeReader object
var barcodeReader = new Aspose.BarCodeRecognition.BarCodeReader(imageStream, Aspose.BarCodeRecognition.BarCodeReadType.Code39Extended);
while (barcodeReader.Read())
{
// Get BarCode text from BarCode image
var code = barcodeReader.GetCodeText();
// Write the BarCode text to Console output
Console.WriteLine("BARCODE : " + code);
}
// Close BarCodeReader object to release the Image file
barcodeReader.Close();
}
}
}
}
}
لمزيد من التفاصيل حول الموضوعات التي تم تناولها في هذه المقالة، قم بزيارة الروابط التالية:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.