コード例 #1
0
        private ActionResult <RenderResponseDto> RenderZpl(RenderRequestDto request)
        {
            IPrinterStorage printerStorage = new PrinterStorage();
            var             drawer         = new ZplElementDrawer(printerStorage);

            var analyzer    = new ZplAnalyzer(printerStorage);
            var analyzeInfo = analyzer.Analyze(request.ZplData);

            var labels = new List <RenderLabelDto>();

            foreach (var labelInfo in analyzeInfo.LabelInfos)
            {
                var imageData = drawer.Draw(labelInfo.ZplElements, request.LabelWidth, request.LabelHeight, request.PrintDensityDpmm);
                var label     = new RenderLabelDto
                {
                    ImageBase64 = Convert.ToBase64String(imageData)
                };
                labels.Add(label);
            }

            var response = new RenderResponseDto
            {
                Labels = labels.ToArray(),
                NonSupportedCommands = analyzeInfo.UnknownCommands
            };

            return(this.StatusCode(StatusCodes.Status200OK, response));
        }
コード例 #2
0
 public ActionResult <RenderResponseDto> Render(RenderRequestDto request)
 {
     try
     {
         return(RenderZpl(request));
     }
     catch (Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }