Pergunta

So i am running into this problem that the qrcode data value needs to be of type string but i want to add in a random guide as the value. I am having some trouble with sitting what is meant to be a string to a guid. Here is what i have code wise:

QR Code:

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);

        }
}

Write QR Code:

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;

         .......
    }
Foi útil?

Solução

Some earlier posted the answer but now it is removed even though it was right.

Guid stringGUID = Guid.NewGuid().toString();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top