Greetings Aspose support.
Hello.
System.IO.MemoryStream outputStream = new System.IO.MemoryStream();
Aspose.Words.Document pdfDoc = new Aspose.Words.Document();
Aspose.Words.DocumentBuilder docBuilder = new Aspose.Words.DocumentBuilder(pdfDoc);
Aspose.BarCode.BarCodeBuilder barcodeBuilder = new Aspose.BarCode.BarCodeBuilder();
barcodeBuilder.GraphicsUnit = GraphicsUnit.Pixel;
barcodeBuilder.CodeText = barcodeText;
barcodeBuilder.CodeTextAlignment = StringAlignment.Center;
barcodeBuilder.CodeTextEncoding = Encoding.Unicode;
barcodeBuilder.AutoSize = true;
barcodeBuilder.BarHeight = 35;
barcodeBuilder.ImageWidth = 500; //offsetX - 2;
barcodeBuilder.ImageHeight = 200; // offsetY - 5;
barcodeBuilder.Resolution = new Aspose.BarCode.Resolution(150, 350, Aspose.BarCode.ResolutionMode.Graphics);
barcodeBuilder.CaptionAbove = new Aspose.BarCode.Caption();
var barcodeImage = barcodeBuilder.GenerateBarCodeImage();
barcodeBuilder.Save(@"test_caption_Code128.png", Aspose.BarCode.BarCodeImageFormat.Png);
docBuilder.InsertImage(barcodeImage,
Aspose.Words.Drawing.RelativeHorizontalPosition.Page,
30,
Aspose.Words.Drawing.RelativeVerticalPosition.Page,
3,
100,
100,
Aspose.Words.Drawing.WrapType.Through);
pdfDoc.Save(@"test_caption_Code128.pdf", Aspose.Words.SaveFormat.Pdf);
Was this ever resolved? I’m having the same issue. Increasing the barcode resolution doesn’t resolve the poor quality of the caption.
As mentioned in my previous reply that issue is not with Aspose.BarCode as barcode APIs are generating correct image. The issue raises when barcode image stream is used to generate PDF.
It is again request to please forward us a sample .Net project having complete code to analyze the issue. We will forward the sample project to Aspose.Words support team for further investigation.
Greetings Aspose support.
We are not saying that the generated barcode is not correct. It is correct, and the barcode image is perfect, as you can check by zooming in. The barcode itself is clear no matter how much you zoom in. The same can not be said for the CodeText - the text that can ussualy be found bellow the barcode. Will attach photo for reference as to what I am trying to tell you. The issue is in the red square (on the image). As you can see, when you zoom in to the barcode, the barcode itself is fine - the text is blurry. And that blurry text is the issue, as clients have trouble reading the barcode.
I will attach a .cs file with the code that you will need to reproduce the issue. Again, the issue is not whether the barcode is correct or not - it is about the quality of the text.
Kind regards,
Katja
Aspose_BarCode.zip (34.8 KB)
We have investigated the issue at our end. There could be many reasons for this issue:
- The blur effect is due to low/different DPI values for the barcode image.
- Bars are just straight lines without any anti-aliasing. Any picture viewer will zoom it without blur. On the other hand the text is not straight and has anti-aliasing. So zooming it will produce the blur effect.
- The image has been scaled when generating PDF file, means barcode image was generated with low resolution while it has been scaled before inserting it to PDF file.
You can overcome this issue by increasing image resolution before inserting barcode into PDF or generate a high resolution barcode image.
Hope the above information helps. Feel free to contact us in case of any further query or comments.