我试图将以下C#代码发送给Ruby(1.8.7 - 其他原因我不能将此代码移至1.9)代码来自Stamps.com手册。
我将此标记为PERL,因为似乎有PERL经验的人可以给我一个提示,我可以用Ruby来解决这个问题。
Smui.PDK5 pdk = new Smui.PDK5Class();
Smui.InternetPostage3 internet_postage = pdk.InternetPostage3;
Smui.SDCPrintJob5 print_job = pdk.CreatePrintJob5();
print_job.MailClass = 0; // first class
print_job.MailPieceFormFactor = 1; // envelope
print_job.MediaID = 2; // #10 envelope
print_job.PrinterName = "\\\\stamps1\\Dev1";
print_job.MailPieceWeight = 1;
print_job.AddRecipient("Stamps.com\r\n3420 Ocean Park Blvd Ste 1040\r\nSanta Monica, CA 90405");
internet_postage.PrintPostageEx(1, print_job, null);
ruby代码如下所示:
pdk = WIN32OLE.new("StampsDotCom.PDK5")
internet_postage = pdk.InternetPostage3
print_job = pdk.CreatePrintJob5
print_job.MailClass = 0 # first class
print_job.MailpieceFormFactor = 1 # envelope
print_job.MediaID = 2 ##10 envelope
print_job.PrinterName = "\\\\stamps1\\Dev1"
print_job.MailpieceWeight = 1
print_job.AddRecipient("Stamps.com\r\n3420 Ocean Park Blvd Ste 1040\r\nSanta Monica, CA 90405")
internet_postage.PrintPostageEx(1, print_job)
最后一次死亡的死亡事件导致红色死亡:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
我尝试过一个更简单的案例,更换失败的行,而不是调用
internet_postage.PrintShippingLabel("Stamps.com\r\n3420 Ocean Park Blvd Ste 1040\r\nSanta Monica, CA 90405")
这很好用。
我认为最大的区别是PrintShippingLabelEx正在传递一个由前一个调用创建的OLE对象。我是否必须以某种方式标记或转换此对象?
如果可能的话,我可以在较低级别执行此代码,如果可能的话,只需要这几行代码即可。