我正在vb.net中编写FedEx API以使用我们的Universe数据库。到目前为止,一切都已完成,但我仍然坚持打印标签部分。 FedEx给我的代码将标签图像保存为pdf并从acrobat打印。问题是你无法真正对pdf图像做任何事情,或者至少我确定,这意味着我无法在4 x 6热敏标签上正确排列图像。我将如何做到这一点,还是有一个很好的方法来使用图像并分配x和y坐标而不会弄乱FedEx标签?这是将标签保存到打印的代码:
Sub ShowShipmentLabels(ByRef CompletedShipmentDetail As CompletedShipmentDetail, ByRef packageDetail As CompletedPackageDetail, ByVal isCodShipment As Boolean)
If (packageDetail.Label.Parts(0).Image IsNot Nothing) Then
' Save outbound shipping label
Dim FileName As String = getProperty("labelpath") + packageDetail.TrackingIds(0).TrackingNumber + ".pdf"
SaveLabel(FileName, packageDetail.Label.Parts(0).Image)
Mylabel.Print()
' Save COD Return label
If (isCodShipment) Then
FileName = getProperty("labelpath") + CompletedShipmentDetail.CompletedPackageDetails(0).TrackingIds(0).TrackingNumber + "CR.pdf"
SaveLabel(FileName, CompletedShipmentDetail.CompletedPackageDetails(0).CodReturnDetail.Label.Parts(0).Image)
End If
End If
End Sub
Sub SaveLabel(ByRef labelFileName As String, ByRef labelBuffer() As Byte)
' Save label buffer to file
Dim LabelFile As FileStream = New FileStream(labelFileName, FileMode.Create)
LabelFile.Write(labelBuffer, 0, labelBuffer.Length)
LabelFile.Close()
' Display label in Acrobat
DisplayLabel(labelFileName)
End Sub
Sub DisplayLabel(ByRef labelFileName As String)
Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(labelFileName)
info.UseShellExecute = True
info.CreateNoWindow = True
info.WindowStyle = ProcessWindowStyle.Hidden
info.Verb = "Print"
System.Diagnostics.Process.Start(info)
End Sub
答案 0 :(得分:0)
如果它在屏幕上看起来很好,但在打印机上没有正确对齐,那么您应该在设备本身或驱动程序中查看打印机设置。我想和司机一起,你可能需要具体说明媒体并调整边距。
答案 1 :(得分:0)
Chris,如果还没有解决,请在我们的数据库中查看此常见问题解答Shippo:http://support.goshippo.com/hc/en-us/articles/203804319-My-labels-are-not-printing-correctly-How-can-I-fix-this-
打印4x6起初可能有点令人头疼。如果它还没有为您工作,请随时评论您使用的打印机和打印机设置的详细信息。这将有助于进一步调试。
答案 2 :(得分:0)
您可以选择以ZPLII格式保存图像。这样做并将其另存为ListView(
children: <Widget>[
Card(child: ListTile(title: Text('One-line ListTile'))),
Card(
child: ListTile(
leading: FlutterLogo(),
title: Text('One-line with leading widget'),
),
),
Card(
child: ListTile(
title: Text('One-line with trailing widget'),
trailing: Icon(Icons.more_vert),
),
),
Card(
child: ListTile(
leading: FlutterLogo(),
title: Text('One-line with both widgets'),
trailing: Icon(Icons.more_vert),
),
),
Card(
child: ListTile(
title: Text('One-line dense ListTile'),
dense: true,
),
),
Card(
child: ListTile(
leading: FlutterLogo(size: 56.0),
title: Text('Two-line ListTile'),
subtitle: Text('Here is a second line'),
trailing: Icon(Icons.more_vert),
),
),
Card(
child: ListTile(
leading: FlutterLogo(size: 72.0),
title: Text('Three-line ListTile'),
subtitle:
Text('A sufficiently long subtitle warrants three lines.'),
trailing: Icon(Icons.more_vert),
isThreeLine: true,
),
),
Card(
child: InkWell(
splashColor: Colors.blue.withAlpha(30),
onTap: () {
print('Card tapped.');
},
child: Container(
width: 300,
height: 100,
child: Center(
child: Text(
'When tapped this Cards InkWell displays an ink splash that fills the entire card',
),
),
),
)),
],
)
。
将Zebra打印机共享为FedexThermal。
然后在他从vb飞来执行时创建一个print.cmd脚本...
$(function () {
navigator.geolocation.getCurrentPosition(showPosition, positionError);
function showPosition(position) {
var coordinates = position.coords;
$("#lat").val(coordinates.latitude);
$("#lon").val(coordinates.longitude);
}
function positionError(position) {
alert("oops! Error: " + position.code);
};
})
function getDistanceFromLatLonInKm(latitude1, longitude1, latitude2, longitude2, units) {
var p = 0.017453292519943295; //This is Math.PI / 180
var c = Math.cos;
var a = 0.5 - c((latitude2 - latitude1) * p) / 2 +
c(latitude1 * p) * c(latitude2 * p) *
(1 - c((longitude2 - longitude1) * p)) / 2;
var R = 6371; // Earth distance in km so it will return the distance in km
var dist = 2 * R * Math.asin(Math.sqrt(a));
document.getElementById("output").innerHTML = dist + "Km";
}
</script>"
然后在vb中创建一个进程来运行该脚本,
为我工作。