2

カスタマイズされたQRコードを文字列で印刷しようとしています。

私が直面している問題は、文字列を正しい場所に配置できないことです。つまり、出力をカスタマイズできないことです。 サンプル画像

そして、私が得ているものはごちゃ混ぜです。テンプレートを作成して印刷できますか?

カスタマイズコード

 CurrentY = 0;
                CurrentX = 0;
                InvSubTitleHeight = (int)(InvSubTitleFont.GetHeight(g));
                // Get Titles Length:
                int lenInvSubTitle1 = (int)g.MeasureString("Bill ID : " + billId, InvSubTitleFont).Width;
                int lenInvSubTitle2 = (int)g.MeasureString("Bill Amount : " + billAmt, InvSubTitleFont).Width;
                int lenInvSubTitle3 = (int)g.MeasureString("Date : " + DateTime.Now.ToString("dd/MM/yyyy"), InvSubTitleFont).Width;

                // Set Titles Left:
                int xInvSubTitle1 = CurrentX + lenInvSubTitle1 / 2;
                int xInvSubTitle2 = CurrentX + lenInvSubTitle2 / 2;
                int xInvSubTitle3 = CurrentX + lenInvSubTitle3 / 2;

                // Draw Invoice Head:
                if (billId != "")
                {
                    CurrentY = CurrentY + InvSubTitleHeight;
                    g.DrawString("Bill ID : " + billId, InvSubTitleFont, BlackBrush, 0, CurrentY);
                }
                if (billAmt != "")
                {
                    CurrentY = CurrentY + InvSubTitleHeight + 5;
                    g.DrawString("Bill Amount : " + billAmt, InvSubTitleFont, BlackBrush, 0, CurrentY);
                }

                CurrentY = CurrentY + InvSubTitleHeight + 5;

                g.DrawString("Date : " + DateTime.Now.ToString("dd/MM/yyyy"), InvSubTitleFont, BlackBrush, 0, CurrentY);

                CurrentY = CurrentY + InvSubTitleHeight + 15;

                var image = QRValidation.CreateImage(img);
                var p = new Point(0, CurrentY);
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.DrawImage(image, p);
                CurrentY += image.Height + 20;

                //Add bottom Text

                g.DrawString("Scan the image above with your", InvSubTitleFont, BlackBrush, 0, CurrentY);
                CurrentY = CurrentY + InvSubTitleHeight + 2;
                g.DrawString("X app and earn reward", InvSubTitleFont, BlackBrush, 0, CurrentY);
                CurrentY = CurrentY + InvSubTitleHeight + 2;
                g.DrawString("points for your last purchase", InvSubTitleFont, BlackBrush, 0, CurrentY);
                CurrentY = CurrentY + InvSubTitleHeight + 25;
                g.DrawString("You can scan this QR Code only", new Font("Times New Roman", 10, FontStyle.Bold), BlackBrush, 0, CurrentY);
                CurrentY = CurrentY + InvSubTitleHeight + 3;
                g.DrawString("once.", new Font("Times New Roman", 10, FontStyle.Bold), BlackBrush, 90, CurrentY);
                // Draw line:
                CurrentY = CurrentY + InvSubTitleHeight + 25;
                var width = (int) g.MeasureString("Powered by X", InvSubTitleFont).Width;
                g.DrawLine(new Pen(Brushes.DarkCyan, 3), CurrentX, CurrentY, width+2, CurrentY);

                CurrentY = CurrentY + InvSubTitleHeight + 5;
                g.DrawString("Powered by X", InvSubTitleFont, BlackBrush, 0, CurrentY);
4

0 に答える 0