三菱 CPD90D 打印机 C#
Posted
技术标签:
【中文标题】三菱 CPD90D 打印机 C#【英文标题】:MITSUBISHI CPD90D printer from C# 【发布时间】:2016-10-05 13:37:58 【问题描述】:我正在尝试通过 MITSUBISHI CPD90D 打印机使用 CK-D868 类型的纸张从我的 C# 代码打印 4"*6" (10*15 cm) 的图像。
我已经通过这台打印机通过 windows 打印了图像,现在我正在尝试通过代码打印。
我在尝试运行我的代码时遇到的错误是
'打印机驱动的纸张尺寸和色带类型不匹配'
这是我的代码:
public void Print(string imagePath, int copies)
var doc = new PrintDocument();
PrintController printController = new StandardPrintController();
doc.PrintController = printController;
doc.PrinterSettings.PrinterName = PhotosConfig.PrinterName;
doc.PrinterSettings.Copies = (short)copies;
doc.PrinterSettings.DefaultPageSettings.PaperSize = new PaperSize("10x15x2(4x6\"x2)", 100, 150);
doc.PrinterSettings.DefaultPageSettings.Margins = new Margins(0,0,0,0);
doc.DefaultPageSettings.PaperSize = new PaperSize("10x15x2(4x6\"x2)", 100, 150);
doc.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
doc.OriginAtMargins = true;
doc.PrintPage += (sender, args) =>
Image i = Image.FromFile(imagePath);
//Point p = new Point();
args.Graphics.DrawImage(i, args.MarginBounds);
;
doc.Print();
任何帮助将不胜感激!
谢谢, 尼尔
【问题讨论】:
你能指定一个 PaperType 吗? 纸张类型为CK-D868(也在评论中编辑) 您找到解决方案了吗?如何 ?我有同样的问题,我发现:social.msdn.microsoft.com/Forums/en-US/… @barpas 我们最终确实找到了解决方案,但那是很久以前的事了,我无法找到它。据我记得,它与代码中的一些配置有关,但我现在不记得更多了。对不起.. 【参考方案1】:我们使用了 .Net 的 System.Drawing.Printing, 所以我们修改(和工作)的代码看起来像这样:
var doc = new PrintDocument(); var printController = new StandardPrintController();
var ps = new PrinterSettings
PrinterName = PhotosConfig.PhotosPrinterName,
Copies = (short)copies,
DefaultPageSettings =
Landscape = true,
Margins = new Margins()
Top = 0,
Bottom = 0,
Left = 0,
Right = 0
;
doc.OriginAtMargins = false;
doc.PrinterSettings = ps;
doc.PrintController = printController;
doc.DefaultPageSettings.PaperSize = ps.PaperSizes[1]; var doc = new PrintDocument();
var printController = new StandardPrintController();
var ps = new PrinterSettings
PrinterName = PhotosConfig.PhotosPrinterName,
Copies = (short)copies,
DefaultPageSettings =
Landscape = true,
Margins = new Margins()
Top = 0,
Bottom = 0,
Left = 0,
Right = 0
;
doc.OriginAtMargins = false;
doc.PrinterSettings = ps;
doc.PrintController = printController;
doc.DefaultPageSettings.PaperSize = ps.PaperSizes[1];
doc.PrintPage += (sender, args) =>
var i = Image.FromFile(imagePath);
args.Graphics.DrawImage(i, args.MarginBounds);
;
doc.Print();
问题与适当的纸张尺寸有关,因此这里是完整列表:
// * paper sizes:
// [0] [PaperSize 9x13(3.5x5") Kind=Custom Height=520 Width=362] object System.Drawing.Printing.PaperSize
//+ [1] [PaperSize 10x15(4x6") Kind=Custom Height=618 Width=409] object System.Drawing.Printing.PaperSize
//+ [2] [PaperSize 13x18(5x7") Kind=Custom Height=713 Width=520] object System.Drawing.Printing.PaperSize
//+ [3] [PaperSize 15x20(6x8") Kind=Custom Height=811 Width=618] object System.Drawing.Printing.PaperSize
//+ [4] [PaperSize 15x21(6x8.5") Kind=Custom Height=858 Width=618] object System.Drawing.Printing.PaperSize
//+ [5] [PaperSize 15x23 (6x9") Kind=Custom Height=913 Width=618] object System.Drawing.Printing.PaperSize
//+ [6] [PaperSize 10x15x2 (4x6"x2) Kind=Custom Height=831 Width=618] object System.Drawing.Printing.PaperSize
//+ [7] [PaperSize 5x15x2 Type1(2x6"x2) Kind=Custom Height=618 Width=409] object System.Drawing.Printing.PaperSize
//+ [8] [PaperSize 5x15x2 Type2(2x6"x2) Kind=Custom Height=618 Width=205] object System.Drawing.Printing.PaperSize
//+ [9] [PaperSize 5x15(2x6") Kind=Custom Height=618 Width=209] object System.Drawing.Printing.PaperSize
//+ [10] [PaperSize 15x15(6x6") Kind=Custom Height=618 Width=610] object System.Drawing.Printing.PaperSize
//+ [11] [PaperSize 13x13(5x5") Kind=Custom Height=520 Width=512] object System.Drawing.Printing.PaperSize
//+ [12] [PaperSize 9x13(3.5x5") white border Kind=Custom Height=520 Width=362] object System.Drawing.Printing.PaperSize
//+ [13] [PaperSize 10x15(4x6") white border Kind=Custom Height=618 Width=413] object System.Drawing.Printing.PaperSize
//+ [14] [PaperSize 13x18(5x7") white border Kind=Custom Height=713 Width=520] object System.Drawing.Printing.PaperSize
//+ [15] [PaperSize 15x20(6x8") white border Kind=Custom Height=811 Width=618] object System.Drawing.Printing.PaperSize
//+ [16] [PaperSize 15x23(6x9") white border Kind=Custom Height=913 Width=618] object System.Drawing.Printing.PaperSize
【讨论】:
以上是关于三菱 CPD90D 打印机 C#的主要内容,如果未能解决你的问题,请参考以下文章