Javascript 在c#中生成的打印图像对于Zebra ZXP 3来说太大

Javascript 在c#中生成的打印图像对于Zebra ZXP 3来说太大,javascript,c#,asp.net,model-view-controller,printing,Javascript,C#,Asp.net,Model View Controller,Printing,我想通过名为-Zebra ZXP 3的打印机打印C#生成的图像。 这台打印机有86毫米x 54毫米的卡片,打印速度为300 DPI 我用这种方式生成了图像(徽章高度是从数据库中以mm为单位获得的,然后用私有方法转换为像素,所以我在下面写下了这个变量的值) 宽度=1016 高度=638 var bitmap = new Bitmap(badgeWidth, badgeHeight); bitmap.SetResolution(300, 300); SetBackgroundColor(ba

我想通过名为-Zebra ZXP 3的打印机打印C#生成的图像。 这台打印机有86毫米x 54毫米的卡片,打印速度为300 DPI

我用这种方式生成了图像(徽章高度是从数据库中以mm为单位获得的,然后用私有方法转换为像素,所以我在下面写下了这个变量的值)

宽度=1016 高度=638

 var bitmap = new Bitmap(badgeWidth, badgeHeight);

 bitmap.SetResolution(300, 300);
 SetBackgroundColor(badgeTemplateData, bitmap);
然后我有两种方法在位图上画一些东西,看起来像(一些方法生成图片,一些文本,一些条形码等)

最后,我有了一种将此图像转换为Base64的方法:

//This is class which generate Image (look above):
var imageGenerator = new ImageGenerator(badgeTemplate);
var badgeTemplateBitmap = imageGenerator.MapBadgeTemplateToPng(badgeSide);

var memoryStream = new MemoryStream();

badgeTemplateBitmap.Save(memoryStream, ImageFormat.Png);

var byteImage = memoryStream.ToArray();

var badgeTemplateBase64 = Convert.ToBase64String(byteImage);

return badgeTemplateBase64;
最后一步是将此图片发送到浏览器,因此我调用了高于base64的Ajax:

$.ajax({
        url: "/Guests/PrintSingleFrontBadgeTemplate",
        type: "post",
        data: { guestTypeId: guestTypeId, guestId: guestId },
        success: function (response) {
            var popupWin = window.open('', '_blank', 'width=1200,height=800');
            popupWin.document.open();
            popupWin.document.write('<html><head></head><body"><img alt="Embedded Image" src="data:image/png;base64,' + response.frontBadgeTemplate + '" /></html>');
            popupWin.document.close();
            popupWin.print();
            popupWin.close();
        }
    });
$.ajax({
url:“/Guests/PrintSingleFrontBadgeTemplate”,
类型:“post”,
数据:{guestTypeId:guestTypeId,guestId:guestId},
成功:功能(响应){
var popupWin=window.open(“”,"u blank’,“宽度=1200,高度=800”);
popupWin.document.open();
popupWin.document.write('
$.ajax({
        url: "/Guests/PrintSingleFrontBadgeTemplate",
        type: "post",
        data: { guestTypeId: guestTypeId, guestId: guestId },
        success: function (response) {
            var popupWin = window.open('', '_blank', 'width=1200,height=800');
            popupWin.document.open();
            popupWin.document.write('<html><head></head><body"><img alt="Embedded Image" src="data:image/png;base64,' + response.frontBadgeTemplate + '" /></html>');
            popupWin.document.close();
            popupWin.print();
            popupWin.close();
        }
    });