/// <summary> /// Generate barcode, the generated barcode image will be saved on provided disk location /// </summary> /// <param name="text">The code text</param> /// <param name="type">Barcode type</param> /// <param name="format">Result format</param> /// <param name="enableChecksum">Sets if checksum will be generated</param> /// <param name="localPathWithFileNameAndExtension">Local disk path with filename and extension to save the generated barcode image. It will overwrite the file if it already exists</param> /// <param name="resolutionX">Horizontal resolution in DPI. Default is 96</param> /// <param name="resolutionY">Vertical resolution in DPI. Default is 96</param> /// <param name="dimensionX">Smallest width of barcode unit (bar or space). Default is 0.7</param> /// <param name="dimensionY">Smallest height of barcode unit (for 2D barcodes). Default is 2</param> public void GenerateBarCode(string text, BarCodeType type, BarCodeImageFormat format, string localPathWithFileNameAndExtension, EnableChecksum enableChecksum = EnableChecksum.No, float resolutionX = 96, float resolutionY = 96, double dimensionX = 0.7, float dimensionY = 2) { // GET barcode/generate?appSid={appSid}&text={text}&type={type}&format={format}&resolutionX={resolutionX} // &resolutionY={resolutionY}&dimensionX={dimensionX}&dimensionY={dimensionY}&enableChecksum={enableChecksum} string apiUrl = string.Format(@"barcode/generate?text={0}&type={1}&format={2}&resolutionX={3}&resolutionY={4}&dimensionX={5}&dimensionY={6}&enableChecksum={7}", text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, enableChecksum); using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey)) using (Stream file = File.OpenWrite(localPathWithFileNameAndExtension)) { ServiceController.CopyStream(responseStream, file); } }
/// <summary> /// Generate barcode and save on server /// </summary> /// <param name="name">The image name.</param> /// <param name="text">Barcode's text.</param> /// <param name="type">The barcode type.</param> /// <param name="format">The image format.</param> /// <param name="codeLocation">Property of the barcode.</param> /// <param name="grUnit">Measurement of barcode properties.</param> /// <param name="autoSize">Sets if barcode size will be updated automatically.</param> /// <param name="barHeight">Height of the bar.</param> /// <param name="imageHeight">Height of the image.</param> /// <param name="imageWidth">Width of the image.</param> /// <param name="imageQuality">Determines quality of the barcode image.</param> /// <param name="rotAngle">Angle of barcode orientation.</param> /// <param name="topMargin">Top margin.</param> /// <param name="bottomMargin">Bottom margin.</param> /// <param name="leftMargin">Left margin.</param> /// <param name="rightMargin">Right margin.</param> /// <param name="enableChecksum">Sets if checksum will be generated.</param> /// <param name="storage">Image's storage.</param> /// <param name="folder">Image's folder.</param> /// <param name="resolutionX">Horizontal resolution in DPI. Default is 96</param> /// <param name="resolutionY">Vertical resolution in DPI. Default is 96</param> /// <param name="dimensionX">Smallest width of barcode unit (bar or space). Default is 0.7</param> /// <param name="dimensionY">Smallest height of barcode unit (for 2D barcodes). Default is 2</param> public void GenerateBarCodeAndSaveOnServer(string name, string text, BarCodeType type, float barHeight, float imageHeight, float imageWidth, float rotAngle, float topMargin, float bottomMargin, float leftMargin, float rightMargin, string storage, string folder, BarCodeImageFormat format = BarCodeImageFormat.PNG, CodeLocation codeLocation = CodeLocation.Below, GrUnit grUnit = GrUnit.MM, bool autoSize = true, ImageQuality imageQuality = ImageQuality.Default, EnableChecksum enableChecksum = EnableChecksum.No, float resolutionX = 96, float resolutionY = 96, double dimensionX = 0.7, float dimensionY = 2) { // PUT barcode/{name}/generate?appSid={appSid}&text={text}&type={type}&format={format}&resolutionX={resolutionX}&resolutionY={resolutionY}&dimensionX={dimensionX}&dimensionY={dimensionY}&codeLocation={codeLocation}&grUnit={grUnit}&autoSize={autoSize}&barHeight={barHeight}&imageHeight={imageHeight}&imageWidth={imageWidth}&imageQuality={imageQuality}&rotAngle={rotAngle}&topMargin={topMargin}&bottomMargin={bottomMargin}&leftMargin={leftMargin}&rightMargin={rightMargin}&enableChecksum={enableChecksum}&storage={storage}&folder={folder} string apiUrl = string.Format(@"barcode/{0}/generate?text={1}&type={2}&format={3}&resolutionX={4}&resolutionY={5}&dimensionX={6}&dimensionY={7}&codeLocation={8}&grUnit={9}&autoSize={10}&barHeight={11}&imageHeight={12}&imageWidth={13}&imageQuality={14}&rotAngle={15}&topMargin={16}&bottomMargin={17}&leftMargin={18}&rightMargin={19}&enableChecksum={20}&storage={21}&folder={22}", name, text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, codeLocation, grUnit, autoSize, barHeight, imageHeight, imageWidth, imageQuality, rotAngle, topMargin, bottomMargin, leftMargin, rightMargin, enableChecksum, storage, folder); ServiceController.Put(apiUrl, AppSid, AppKey); }