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

Free Support Forum - aspose.com

Error! Bar code generator is not set. Aspose.Words.Document.save(".pdf")

I got a .docx template file with a DisplayBarcode Field Code to paint QR codes which is saved correctly in .docx but when I try to save it in pdf the file does not show the QR code but shows the string “Error! Bar code generator is not set”.

DOCX:
image.png (110.7 KB)

PDF:
image.png (54.0 KB)

I tried to instantiate the field Document.FieldOptions.BarcodeGenerator with a custom class which implements IBarCodeGenerator but I do not know how to build the QR image inside the method GetBarcodeImage.

Is there another way to avoid the issue?

Note: I am using the last version of Aspose.Words.

Thanks.

@bizagi-engineering Most likely in your document you are using DisplayBarcode field like the following: in.docx (12.1 KB)

{ DisplayBarcode "http://www.microsoft.com" QR \q 3 }

In this case you should use a customer barcode generator to update value of this field. You can implement IBarcodeGenerator to achieve this. For example see CustomBarcodeGenerator implementation using Aspose.Barcode.
Then using the following code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.FieldOptions.BarcodeGenerator = new CustomBarcodeGenerator();
doc.Save(@"C:\Temp\out.pdf");

You will get the desired output: out.pdf (2.6 KB)