Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to see chinese characters in pdf or png? #271

Open
buketgul opened this issue Sep 10, 2024 · 1 comment
Open

Is it possible to see chinese characters in pdf or png? #271

buketgul opened this issue Sep 10, 2024 · 1 comment

Comments

@buketgul
Copy link

I am trying to prepare pdf or png label from zpl code. I want to be able to use chinese characters in label. I prepared zpl code to make this. I am able to see characters on labelary. But I cannot see on https://binarykits-zpl-viewer.azurewebsites.net/.

Screenshot 2024-09-10 at 11 57 17

I also cannot see these characters using the BinaryKits.Zpl.Viewer in the code.

I will not use any printer, I just want to get correct pdf or png. This is my code to get this.

            var zpl = @$"^XA
                        ^CI28
                        ^FX First section with bar code.
                        ^BY4,2,150
                        ^FO60,140^BCN,150,N^FDUM2408100000^FS
                        ^FX Second section with address
                        ^CF0,40
                        ^FO50,300^FDDelivery Address^FS
                        ^CFJ,30
                        ^FO50,350^FD中国, 山东省, 青岛市^FS
                        ^CFJ,30
                        ^FO50,400^FD香港东路6号, 5号楼, 8号^FS
                        ^XZ";

            var drawOptions = new DrawerOptions()
            {
                PdfOutput = true
            };
            IPrinterStorage printerStorage = new PrinterStorage();
            var drawer = new ZplElementDrawer(printerStorage, drawOptions);

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

            foreach (var labelInfo in analyzeInfo.LabelInfos)
            {
                var imageData = drawer.DrawPdf(labelInfo.ZplElements, 100, 100, 8);
                File.WriteAllBytes("label.pdf", imageData);
            }

Here is the output for this code.
label.pdf

@masternan
Copy link

masternan commented Sep 12, 2024

pls refer code as flowing

private static DrawerOptions BuildDrawOption(string fontName = "NotoSansSC-SemiBold") { var fontFile = Path.Combine(AppContext.BaseDirectory, "fonts", $"{fontName}.ttf"); var drawOptions = new DrawerOptions { FontLoader = fontName => { return SKTypeface.FromFile(fontFile); }, OpaqueBackground = false, PdfOutput = false, RenderFormat = SKEncodedImageFormat.Png, RenderQuality = 100, Antialias = true, ReplaceDashWithEnDash = false }; return drawOptions; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants