Generate Barcode using Aspose.Barcode and Add to PDF with Aspose.PDF for .NET

I am using Aspose BarCode to generate a bar code to insert into a aspose.pdf document.
With the following code.

            barCodeGenerator.CodeText = barcodetext;
	barCodeGenerator.Save(imgStream, BarCodeImageFormat.Png);
	PDFPage.AddImage(imgStream, pageLocation, 350, 55, false);

where pageLocation is a rectangle on a pdf page.
Specifying width and height of image to be 350, 55 accordingly.

I saved down the imgStream and confirmed that the image exists ( I am attaching a persisted image file)
However after Image was added to the pdf document
I am seeing very fuzzy image … instead of a crisp and clean barcode

What am I doing wrong ?testbarcode.png (186 Bytes)pdf.jpg (14.3 KB)


Thank you for contacting support.

We have tried to Add Image Stamp in PDF File and image in generated PDF document appears better with Aspose.PDF for .NET 19.4. We have attached generated file for your kind reference.

// Open document
Document pdfDocument = new Document();
var page = pdfDocument.Pages.Add();
// Create image stamp
ImageStamp imageStamp = new ImageStamp(dataDir + "testbarcode.png");
imageStamp.Background = true;
imageStamp.XIndent = 10;
imageStamp.YIndent = 100;
imageStamp.Height = 55;
imageStamp.Width = 350;
imageStamp.Quality = 100;
// Add stamp to particular page
dataDir = dataDir + "AddImageStamp_19.4.pdf";
// Save output document

If you still face the problem with latest version then please share SSCCE code along with source file so that we may investigate further to help you out.

2 posts were split to a new topic: Generate Barcode and add it to PDF - Height and Width are not being honored set by Aspose.Barcode