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

Free Support Forum - aspose.com

BarCode does not render after DOCX to PDF conversion using .NET

Some of our word documents contain a barcode which is added via word function

image.png (28.1 KB)

The barcode is shown properly within word and also when i save the word document as pdf.

I then use the following code to convert the docx to a pdf using aspose

        string FilePath = @"C:\Users\test\Desktop\MeinBarcode.docx";
        Aspose.Words.Document doc = new Aspose.Words.Document(FilePath);
        doc.Save(@"C:\Users\test\Desktop\Document.Doc2PdfSave Out.pdf", 
        Aspose.Words.SaveFormat.Pdf);

The resulting pdf then doesn’t show the barcode:
image.png (4.8 KB)

I do understand there is an implementation sample CustomBarcodeGenerator(), but i do have the following question:
Do i need to implement the CustomBarcodeGenerator if i just want to display the same barcode as is already shown in word, or can i tell aspose just to show the same barcode as word already has?

@manuelk

Could you please ZIP and attach your input Word document here for testing? We will investigate the issue and provide you more information on it.

Here you are:
MeinBarcode.zip (9.7 KB)

@manuelk

Thanks for sharing the detail. You need to implement IBarcodeGenerator interface to get the desired output. Please read the following article for more detail.
How to Generate a Custom BarCode Image for DISPLAYBARCODE Field

Yes, i already found this documentation.
But we don’t know whether a word document contains any barcode definition using the DISPLAYBARCODE field.
And if it does, we don’t know the type of the barcode which is used.

Does this means we now always have to use this CustomBarcodeGenerator when saving a pdf from a word even if it doesn’t contain a barcode?

@manuelk

To generate the barcode and render it in output PDF, you need to use CustomBarcodeGenerator. Please let us us know if you have any more queries.

This answers my question.
It means aspose cannot be used for saving a word document into a pdf if you don’t know the content.
Do you have plans to improve the save to pdf functionality regarding barcodes?

@manuelk

Your document contains the DISPLAYBARCODE field and it requires Aspose.BarCode to render it as image in output PDF. As per our understanding, you do not want to use Aspose.BarCode while rendering document to PDF.

We have logged your requirement in our issue tracking system as WORDSNET-20476 . We will check the possibility of implementation of this feature and update you via this forum thread.

@manuelk

It is to inform you that we have closed this issue with Won’t Fix resolution.

There is no generated picture retained in the DISPLAYBARCODE field’s result. Hence there’s no way for Aspose.Words to preserve it during rendering to PDF. You need to use Aspose.BarCode to generate barcode image.