title: C# - Using ZXing.Net to Create and download SVG QR Code
body: <p>I am working on a QR Code project and one of the requirements is to be able to download the generated QR Code in SVG format. I was able to display the generated QR Code in PNG format, but I have been trying to download it in SVG format.</p>
  <p>I am using XZing library to generate the QR Code in PNG</p>
  <pre><code>        Color barcodeColor = System.Drawing.ColorTranslator.FromHtml(colorHex);
  
          BarcodeWriter barcodeWriter = new BarcodeWriter
          {
              Format = BarcodeFormat.QR_CODE,
              Options = new EncodingOptions
              {
                  Width = width,
                  Height = height,
                  PureBarcode = true
              },
              Renderer = new BitmapRenderer
              {
                  Foreground = barcodeColor
              }
          };
  
          Bitmap barCodeBitmap = barcodeWriter.Write(qrContent);
          var memoryStream = new MemoryStream();
  
          // save to stream as PNG
          barCodeBitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
  
          HttpResponseMessage response = new HttpResponseMessage();
          response.Content = new ByteArrayContent(memoryStream.ToArray());
          response.Content.Headers.ContentType = new MediaTypeHeaderValue(&quot;image/jpeg&quot;);
          response.StatusCode = HttpStatusCode.OK;
  
          return response;
  </code></pre>
  <p>I was able to create a BarcodeWriterSvg object but I wasn't able to convert it into a stream and pass it in the header like the PNG</p>
  <pre><code>        BarcodeWriterSvg barcodeWriter = new BarcodeWriterSvg
          {
              Format = BarcodeFormat.QR_CODE,
              Options = new EncodingOptions
              {
                  Width = width,
                  Height = height,
                  PureBarcode = true
              },
              Renderer = new SvgRenderer
              {
                  Foreground = barcodeColor
              }
          };
          var barCodeBitmap = barcodeWriter.Write(qrContent);
          var memoryStream = new MemoryStream();
          HttpResponseMessage response = new HttpResponseMessage();
          ...
  </code></pre>
  <p>My question is how to be able to convert the object into a stream and pass it in the header? The ultimate goal is to be able to download the file without actually creating a physical copy.</p>