Hi,
I'm trying to add a barcode inside a FlowDocumentEditor.
public static ImageInline InsertQRCode(this RadFlowDocumentEditor editor, string code, double width = 96)
{
// Barcode
const double imgWidth = 1000;
var barcode = new RadBarcode
{
Width = imgWidth,
Height = imgWidth,
Symbology = new QRCode()
{
ErrorCorrectionLevel = ErrorCorrectionLevel.H,
CodeMode = CodeMode.Alphanumeric
},
Value = code
};
barcode.BeginInit();
barcode.Measure(new Size(imgWidth, imgWidth));
barcode.Arrange(new Rect(new Size(imgWidth, imgWidth)));
barcode.UpdateLayout();
barcode.EndInit();
using (var stream = new MemoryStream())
{
Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(barcode, stream, new PngBitmapEncoder());
stream.Position = 0;
return editor.InsertImageInline(new Telerik.Windows.Documents.Media.ImageSource(stream, "png"),
new Size(96, 96));
}
At barcode.Measure, I've got an NullException. This didn't happen with old RadBarCodeQR component.
Any ideas?