Free Support Forum - aspose.com

Font Size Issue when SaveAsEmf Method Used

When trying to save any barcode symbology as an EMF file with the .SaveAsEmf() method, I have to choose a very large font size to make the number read properly. Otherwise, the number is unreadably small. However, when increasing the font size, there is a lot of whitespace at the bottom of the barcode image file. It does not matter what font is used: all fonts have this behavior. Setting the font size to 192pt seems unreasonable, but it’s what works. I know it’s also a function of the resolution. If the resolution is set to 300, for example, the font size would need to be 48.



Another note: resolution is a little odd when dealing with EMF files because it’s a vector format, which is supposed to be independent of resolution. How does setting a resolution matter for SaveAsEmf()?



The files in the attached ZIP were generated with the following code: I am using UPC-A to more easily show the issue.



BarCodeBuilder b = new BarCodeBuilder(“850006000029”);

b.SymbologyType = Symbology.UPCA;

b.CodeTextFont = new Font(“OCR B Std”, 16.0f);

b.CodeTextSpace = 0.5f; // This appears to have no effect

b.GraphicsUnit = GraphicsUnit.Millimeter;

b.xDimension = 0.66f;

b.BarHeight = 45.70f;

b.Resolution = new Resolution(1200.0f, 1200.0f, ResolutionMode.Customized);

b.SaveAsEmf(“sample16pt.emf”);

b.CodeTextFont = new Font(“OCR B Std”, 192.0f);

b.SaveAsEmf(“sample192pt.emf”);



Any help looking into this issue would be greatly appreciated.

Hi,

Many thanks for contacting Aspose support. We are currently reviewing the concerns you shared and will write back to you soon with more updates.

If there is anything else we could do to help during the interim, please be sure to let us know.

Thanks for the reply and I look forward to hearing back.

For further information I neglected to include (I have another thread which had a followup reply), these samples are with the .NET 7.1.0 version from the NuGet repository. I do have a valid license, and threw together the sample code/images quickly. If you need further samples without the evaluation mark, I can generate. However, no difference in the samples.

Hi Tony,


Thank you for being patient. It appears as you are stuck in the barcode and font sizes in parallel. You can generate minimum possible UPCA barcode against your sample code text and then extend its size as per the necessity. Please note, the Bitmap class allows you to save barcode in EMF format. Please refer to the following help topic: Generate Barcode Using Custom Width Support

Otherwise, please provide us your font file in this forum thread for testing purposes. It’ll help us to reproduce the problem on our side.

We’re looking forward to help you.

Thanks Imran. The font file is the one I sent to you via e-mail a short time ago for the other thread (UPC-A Barcode Last Digit Cut-Off…). Same font file for this related but separate issue. Please let me know if you received it.



By “minimum possible”, do you mean the resolution? The xDimension and BarHeight are not changeable: there are other combinations of those that greatly affect the UPC-A generation. So if you mean setting the Resolution to something smaller, like 100 DPI, then I get it and will test it out.



One note: the EMF format isn’t a bitmap/raster format but a vector one. I’ll look at the Bitmap class, but I suspect it would generate a bitmap file as an EMF, which is not what I am looking for.

Hi Tony,


Thank you for providing font file. We managed to replicate the problem of extra white space at bottom of the barcode image. We’ve logged an investigation under ticket id BARCODENET-34229 in our issue tracking system. Your post has also been linked to this issue. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Hi Tony,

abadger:
Setting the font size to 192pt seems unreasonable, but it’s what works.
We would like to reconfirm from yours that you really need to set the font size up to 192 PT, because it is not the normal size. When you are setting the largest resolution (1200 x 1200), on that moment it is adding extra white space at the bottom. Please let us know your feedback on it.

Thanks for checking back. The sample file ZIP has an example of when a normal font size is used, like 16pt. “sample16pt.emf” The whitespace does not appear then, but the HRI string is incredible small.

As a summary:
1200 DPI with 16pt font. No whitespace, but the font size is way too small.
1200 DPI with 192pt font. Lots of whitespace, and the font size is correct.

Also, in my initial post I made the comment that defining a DPI for vectors is odd because vectors are independent of resolution. I think the EMF format does contain some resolution information in the metadata to help a program opening up the EMF file to display it. But the actual vector information contained in the EMF file is independent of the DPI. No matter what resolution I use, the overall size of the files never changes (about 8KB). But the apparent size when opening them up does. Hope that helps out a bit in figuring this out.

Hi Tony,

Thank you for the details. Please note, when you are setting the resolution up to 1200 DPI, it is increasing the actual barcode size in respect of height and width (we're not talking about the barcode image file size) and the code text string size remains up to 16 PT. It looks small because the actual barcode size is larger. So our point is you really need to generate so large barcode with 1200 DPI and 192 code text font.

In reference of the Resolution property, please note, we're generating a non-vector format picture in the background and then converting it to the vector format. This property matters in respect of the barcode size. We think, it clears the confusion cause.

imran.rafique:
Please note, when you are setting the resolution up to 1200 DPI, it is increasing the actual barcode size in respect of height and width (we're not talking about the barcode image file size) and the code text string size remains up to 16 PT. It looks small because the actual barcode size is larger.
That is not what happens when saving to PNG. If you change the b.SaveAsEmf("sample16pt.emf") line to b.Save("sample16pt.png", BarCodeImageFormat.Png), the font size is 16pt and the font is not small but appropriately sized. I've attached that sample (same one from the thread about the UPC-A being cut off). The small font is only happening when using SaveAsEmf.

Hi Tony,


Thank you for clarifying the scenario. In reference of the 16 PT font size, we have logged two issues as follows:

BARCODENET-34242 - Incorrect code text font when saving UPCA code in the EMF format
BARCODENET-34243 - The rightmost character of the UPCA code is being cut off

Your post has been linked to these issues. We’ll let you know once a significant progress has been made in this regard. We’re sorry for the inconvenience caused.

Hi Tony,

Thank you for being patient. We have a good news for you that the issue ids BARCODENET-34242 and BARCODENET-34243 have now been resolved. If there is no issue in the QA phase, then their fixes will be included in the next version of Aspose.BarCode for .NET 7.2.0. We'll inform you via this forum thread as soon as the new release is published.

Thanks for the update, Imran. Am I correct in assuming that BARCODENET-34229 is also considered closed? That was for the investigation of the problem, and appears that was turned into the 2 issue IDs BARCODENET-34242 and BARCODENET-34243.

Just making sure nothing is missed for the next release. Thanks!

Hi Tony,


Thank you for asking about the current status. In reference of ticket id BARCODENET-34229, we’re also able to reproduce the problem with font 192 PT. We have downgraded its priority to Low level. Its fix will be included in the future release. However, the fixes of the other two issues will allow you to keep using our Aspose.BarCode APIs in your application projects.

The issues you have found earlier (filed as BARCODENET-34243;BARCODENET-34242) have been fixed in Aspose.BarCode for .NET 7.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi Tony,

Thank you for being patient. We have a good news for you that the issue id BARCODENET-34229 has now been resolved. If there is no issue in the QA phase, then this fix will be included in the future version of Aspose.BarCode for .NET 7.4.0. We'll inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as BARCODENET-34229) have been fixed in Aspose.BarCode for .NET 7.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.