传递生成的guid作为qrcode数据 - LeadTools

时间:2013-05-24 13:48:02

标签: c# asp.net-mvc qr-code leadtools-sdk

所以我遇到这个问题,qrcode数据值需要是字符串类型,但我想在随机指南中添加值。我坐在一个guid的字符串上遇到了一些麻烦。这是我的代码明智:

QR码:

public void QRBarcode(string fileName)
    {
        BarcodeEngine engine = new BarcodeEngine();
        string outputFile = @"C:\QRCodeTesting\CreatedQRCode.pdf";
        int resolution = 300;

        using (RasterImage image = RasterImage.Create((int)(8.5 * resolution), (int)(11.0 * resolution), 1, resolution, RasterColor.FromKnownColor(RasterKnownColor.White)))
        {
            //Guid guidValue = new Guid();
            // Write two QR barcodes
            WriteBarcode(engine.Writer, image, QRBarcodeSymbolModel.Model1AutoSize, "need to add a guid", true);

        }
}

写二维码:

private void WriteBarcode(BarcodeWriter writer, RasterImage image, QRBarcodeSymbolModel symbolModel, string guidValue, bool topLeft)
    {
        // Create the barcode data
        QRBarcodeData barcode = BarcodeData.CreateDefaultBarcodeData(BarcodeSymbology.QR) as QRBarcodeData;
        barcode.SymbolModel = symbolModel;
        barcode.Value = guidValue;

         .......
    }

1 个答案:

答案 0 :(得分:0)

一些早些时候发布了答案,但现在即使它是正确的,它也会被删除。

Guid stringGUID = Guid.NewGuid().toString();