We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

DISPLAYBARCODE in Word 2016 document is not printed

Hello,

I have created a simple docx document with MS Word 2016 containing only the field DISPLAYBARCODE “123456789012” EAN13 \t. The barcode is properly printed by MS Word. However, when I try to do the same with Aspose.Words, the barcode is not printed and only a blank page comes out of the printer. I am using the NuGet package Aspose.Words v17.5.0. I did the printing with the following code:

var doc = new Document(filename);
doc.Print();

Thank you in advance,
David

@davidpasch,

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page format and print it. You need to install fonts that are used in your document on the machine where you’re printing the document. Please refer to the following article:

How Aspose.Words Uses True Type Fonts

If you still face problem, please ZIP and attach your input Word document along with fonts that are used in your document here for testing. We will investigate the issue on our side and provide you more information.

Unfortunately, I do not know, how to figure out which fonts are used in a Word 2016 document.

I tried however the following. I chose in Word to embed the fonts in the document, but this did not help either.
You can find the document attached.

doc_with_barcode_simple.zip (1.6 MB)

Further, I would like to point out that the document is correctly saved by Aspose.Words, if I use the following code:

var doc = new Document(input_filename);
doc.WarningCallback = new MissingFontsWarning();
doc.Save(output_filename);

As you can see, I also added a WarningCallback to the document:

    private class MissingFontsWarning : IWarningCallback
    {
        public void Warning(WarningInfo info)
        {
            switch (info.WarningType)
            {
                case WarningType.FontEmbedding:
                    Console.WriteLine($"{nameof(WarningType.FontEmbedding)}: {info.Description}");
                    break;
                case WarningType.FontSubstitution:
                    Console.WriteLine($"{nameof(WarningType.FontSubstitution)}: {info.Description}");
                    break;
            }
        }
    }

But I do not get any warning in the console.

I used the following code to determine the fonts used in the document:

        foreach (FontInfo fontInfo in doc.FontInfos)
        {
            Console.WriteLine(fontInfo.Name);
        }

I attached the respective fonts from my system.

calibri1.zip (1.3 MB)
calibri2.zip (1.1 MB)
calibri3.zip (1.0 MB)
segoeui1.zip (1.3 MB)
segoeui2.zip (1.6 MB)
segoeui3.zip (1.3 MB)
times.zip (2.2 MB)

@davidpasch,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16778. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@davidpasch,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-16778) as ‘Not a Bug’.

Please refer to the following article.
How to Generate a Custom BarCode Image for DISPLAYBARCODE Field
Please use FieldOptions.BarcodeGenerator property as shown below to get the desired output.

Document doc = new Document(MyDir + "doc_with_barcode_simple.docx");
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
doc.Print();

Please excuse me for the late answer. I had no opportunity to take a look at this issue until now.

If I understand this correctly, then in order to print a barcode from a DISPLAYBARCODE field with Aspose.Words I need the Aspose.Barcode package?

@davidpasch,

Thanks for your inquiry. Yes, you need to use Aspose.Words and Aspose.BarCode. Aspose.Words has an interface for generating custom barcodes which makes it very easy to use Aspose.Words and Aspose.BarCode together to render barcode images in output documents. For example, you can load a DOC, OOXML or RTF document containing DISPLAYBARCODE Field into Aspose.Words, provide your implementation of custom barcode generator and save to fixed page formats such as PDF, XPS etc or print the document.

Thank you very much!