参考:https://www.cnblogs.com/guogangj/archive/2013/02/27/2934733.html

模板:JDFlowDocument.xaml

<FlowDocument PageWidth="" PagePadding="0 0 0 0" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" FontFamily="微软雅黑" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" TextOptions.TextFormattingMode="Display">
<Paragraph>
<Grid>
<WrapPanel Width="" Margin="-35 -40 0 0">
<StackPanel Width="">
<StackPanel Width="" Height="" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">
<Label>
<TextBlock FontSize="" TextWrapping="Wrap">标准快递</TextBlock>
</Label>
</StackPanel>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 5 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--大头笔-->
<StackPanel Width="" Height="" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0 -10 0 0">
<Label Content="{Binding BigShotName}" FontWeight="Bold" FontSize=""></Label>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 10 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--集包地名称-->
<WrapPanel Width="" Height="" Margin="0 3 0 0" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Width="">
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Width="" Height="" CornerRadius="" BorderBrush="Black" BorderThickness="">
<TextBlock Text="集" FontSize="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</StackPanel>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center">
<Label Content="{Binding GatherCenterName}" FontSize="" FontWeight="Bold"/>
</StackPanel>
</WrapPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 3 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--收件、寄件-->
<WrapPanel Width="" Margin="0 -5 0 0">
<!--收件-->
<WrapPanel Width="" Height="">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Width="" Height="">
<Label>
<TextBlock TextWrapping="Wrap" Text="收" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</StackPanel>
<StackPanel>
<WrapPanel>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToFullName}" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToMobile}" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToTelephone}" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</WrapPanel>
<WrapPanel Width="" Margin="0 -10 0 0">
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToFullAddress}" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</WrapPanel>
</StackPanel>
</WrapPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 -5 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--寄件-->
<WrapPanel Width="" Margin="0 -5 0 0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Width="" Height="">
<Label>
<TextBlock TextWrapping="Wrap" Text="寄" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</StackPanel>
<StackPanel>
<WrapPanel>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromFullName}" FontSize="" ></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromMobile}" FontSize="" ></TextBlock>
</Label>
</WrapPanel>
<StackPanel Width="" HorizontalAlignment="Left" Margin="0 -8 0 0">
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromFullAddress}" FontSize="" ></TextBlock>
</Label>
</StackPanel>
</StackPanel>
</WrapPanel>
</WrapPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 0 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--面单号 条形码-->
<StackPanel Width="" Height="" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 5 0 0">
<StackPanel Width="" Height="" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Source="{Binding WaybillCodeBarCodeUrl1}" />
</StackPanel>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 5 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--签收人-->
<WrapPanel Width="" Height="">
<StackPanel Width="">
<Label Height="" Margin="0 -5 0 0">
<TextBlock TextWrapping="Wrap" Text="{Binding Time1}" FontSize=""></TextBlock>
</Label>
<Label Height="" Margin="0 -10 0 0">
<TextBlock TextWrapping="Wrap" Text="{Binding Time2}" FontSize=""></TextBlock>
</Label>
<Label Height="" Margin="0 -10 0 0">
<TextBlock TextWrapping="Wrap" Text="{Binding Numbers}" FontSize=""></TextBlock>
</Label>
</StackPanel>
<StackPanel Width="">
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding SignDes}" FontSize=""></TextBlock>
</Label>
</StackPanel>
<!--快递公司二维码 承运商编码-->
<StackPanel Width="" Height="" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Width="" Height="" Source="{Binding ProviderCodeBarCodeUrl}" />
</StackPanel>
</StackPanel>
</WrapPanel> <!--撕单分隔线--> <!--面单号 条形码-->
<StackPanel Width="" Margin="0 50 0 0">
<StackPanel Width="" Height="" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">
<Image Source="{Binding WaybillCodeBarCodeUrl2}" />
</StackPanel>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 0 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--收件、寄件-->
<WrapPanel Width="" Margin="0 -5 0 0">
<StackPanel Width="">
<!--收件-->
<WrapPanel Width="" Height="">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Width="" Height="">
<Label>
<TextBlock TextWrapping="Wrap" Text="收" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</StackPanel>
<StackPanel Width="" Height="">
<WrapPanel >
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToFullName}" FontSize="" ></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToMobile2}" FontSize=""></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToTelephone}" FontSize=""></TextBlock>
</Label>
</WrapPanel>
<WrapPanel Width="" Margin="0 -8 0 0">
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding ToFullAddress}" FontSize=""></TextBlock>
</Label>
</WrapPanel>
</StackPanel>
</WrapPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--寄件-->
<WrapPanel Width="" Margin="0 -5 0 0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Width="" Height="">
<Label>
<TextBlock TextWrapping="Wrap" Text="寄" FontSize="" FontWeight="Bold"></TextBlock>
</Label>
</StackPanel>
<StackPanel Width="" Height="">
<WrapPanel>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromFullName}" FontSize="" ></TextBlock>
</Label>
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromMobile}" FontSize="" ></TextBlock>
</Label>
</WrapPanel>
<StackPanel Width="" Margin="0 -8 0 0">
<Label>
<TextBlock TextWrapping="Wrap" Text="{Binding FromFullAddress}" FontSize="" ></TextBlock>
</Label>
</StackPanel>
</StackPanel>
</WrapPanel>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 0 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<!--电子面单码-->
<StackPanel Width="" Height="" HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Image Width="" Height="" Source="{Binding WaybillCodeQRCodeUrl}" />
</StackPanel>
</StackPanel>
</WrapPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 -5 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border> <StackPanel Width="" Height="" HorizontalAlignment="Left">
<TextBlock TextWrapping="Wrap" Text="{Binding CustomArea}" HorizontalAlignment="Left" FontSize=""></TextBlock>
</StackPanel>
<StackPanel Width="" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<Label Content="已验视" FontSize="" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0 0 10 0"></Label>
</StackPanel>
<Border Width="" Height="" CornerRadius="" BorderThickness="" Margin="0 5 0 0">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset=""/>
<GradientStop Color="Black" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="Black" Offset="0.8"/>
<GradientStop Color="Black" Offset=""/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
</WrapPanel>
</Grid>
</Paragraph>
</FlowDocument>

代码:Dispatcher.Invoke可以防止报错:调用线程必须为 STA,因为许多 UI 组件都需要。

public void PrintIt()
{
WaybillData waybill = new WaybillData();//TODO:自己构造数据
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action<WaybillData>(PrintAction), waybill);
}
public void PrintAction(WaybillData t)
{
PrintDialog pdlg = new PrintDialog();
FlowDocument doc = PrintPreviewWindow.LoadDocumentAndRender("JDFlowDocument.xaml", t);
Dispatcher.Invoke(new DoPrintMethod(DoPrint), DispatcherPriority.ApplicationIdle, pdlg, ((IDocumentPaginatorSource)doc).DocumentPaginator);
}
private delegate void DoPrintMethod(PrintDialog pdlg, DocumentPaginator paginator);
private void DoPrint(PrintDialog pdlg, DocumentPaginator paginator)
{
pdlg.PrintDocument(paginator, "JDFlowDocument");
}

WPF打印京东电子面单(可以异步)的更多相关文章

  1. 通过快递100获取快递单号,结合c-lodop热敏纸打印 – 通过菜鸟ISV/自研ERP使用菜鸟电子面单

    https://www.1024cc.cn/index.php/2019/04/29/%E6%89%93%E5%8D%B0%E7%94%B5%E5%AD%90%E9%9D%A2%E5%8D%95/ 打 ...

  2. WPF打印票据

    最近工作的内容是有关于WPF的,整体开发没有什么难度,主要是在打印上因为没有任何经验,犯了一些难,不过还好,解决起来也不是很费劲. WPF打印票据或者是打印普通纸张区别不大,只是说打印票据要把需要打的 ...

  3. EMS电子面单接口对接使用-免费版

    快递鸟电子面单接口,可一次对接15家快递公司, 无需和每一家快递公司做对接.支持快递有四通一达.顺丰.EMS.宅急送.德邦.优速等15家快递公司,对顺丰有电子面单服务需求的可以选择顺丰自有的电子面单或 ...

  4. 快递鸟电子面单API对接方法?

    之前说了一下快递公司.菜鸟和快递鸟的电子面单接口,很多人不知道快递鸟要怎么对接,现在为大家讲解一下.快递鸟是全球物流接口服务商,为电商 ERP.电商平台.仓储.清关公司提供物流跟踪.电子面单.智选物流 ...

  5. 电商平台如何接入快递鸟电子面单API?

    快递鸟是全球物流接口服务商,为电商 ERP.电商平台.仓储.清关公司提供物流跟踪.电子面单.智选物流.物流金融.在线下单等服务,解决电商的物流管理模块和金融模块.现就对快递鸟电子面单API做基本描述, ...

  6. 各种电子面单_Api接口

    电子面单是一种通过热敏纸打印输出纸质物流面单的物流服务.通过热感应显示文字,打印速度比传统针式打印速度提升4~6倍.电子面单以接口形式嵌入到自己的系统.网站上,可以在自己的平台操作打印电子面单.   ...

  7. 使用java Graphics 绘图工具生成顺丰快递电子面单

    最近公司需要开发一个公司内部使用的快递下单系统,给我的开发任务中有一个生成电子面单功能,为了下单时更方便,利用此功能使用快递公司给我们的打印机直接打印出电子面单,刚接到这个任务时我想这应该很简单,不就 ...

  8. 快递鸟顺丰电子面单接口API-JAVA

    一.电子面单对接案例 1.接口描述 接口支持的消息接收方式:HTTP POST 请求方法的编码格式(utf-8):"application/x-www-form-urlencoded;cha ...

  9. 基于PHP的对接电子面单接口平台案例

    电子面单接口目前有三种对接方式,快递电子面单接口.菜鸟电子面单接口和快递鸟电子面单接口.这三种接口各有特点. 一.电子面单接口定义 1. 快递电子面单接口:快递公司自己开发的电子面单服务, 商家使用必 ...

随机推荐

  1. 淘宝App直播宝贝数据采集

    淘宝App直播宝贝数据采集   前段时间,有人问我关于淘宝app直播频道宝贝如何采集?我尝试了下可以获取的到,模拟器登录不了淘宝,这里有一个坑就是,模拟器有时候会跳到登录页面,登录不了淘宝: 一.用A ...

  2. C# VS2017的.net Core1.0项目在版本升级为2.0后找不到程序集的处理办法

    最近不小心升级了VS2017,然后原来的.net web core1.0的项目是引用了DataBaseLib的程序集,如图  ,升级之后安装了2.0的框架,发现项目就报错了,,这个是还是之后报的错误, ...

  3. solr参数之facet

    facet就像sql语句中的group一样,是对某一个字段进行group并count,即能够按照Facet的字段进行分组并统计. 一.基本使用: 必须属性:facet=true&facet.f ...

  4. darknet训练yolov3时的一些注意事项

    训练需要用到的文件: 1)       .data文件.该文件包含一些配置信息,具体为训练的总类别数,训练数据和验证数据的路径,类别名称,模型存放路径等. 例如coco.data classes= 8 ...

  5. (17/24) webpack实战技巧:生产环境和开发环境并行设置,实现来回切换

    1. 概述 生产环境和开发环境所需依赖是不同: --开发依赖:就是开发中用到而发布时用不到的.在package.json里面对应的就是devDependencies下面相关配置. --生产依赖: 就是 ...

  6. Linux下的常见压缩解压缩命令

    Linux常见压缩解压缩命令 常见压缩文件扩展名 .Z compress 程序压缩的文件: .zip zip 程序压缩的文件: .gz gzip 程序压缩的文件: .bz2 bzip2 程序压缩的文件 ...

  7. activiti官网实例项目activiti-explorer之获取流程节点

    如上图在保存步骤中添加获取节点信息方法nodes(); 方法如下: //获取所有节点    JsonNode modelNode = new ObjectMapper().readTree(repos ...

  8. mysql查询正在执行的sql

    mysql> SHOW VARIABLES LIKE "general_log%"; +------------------+------------------------ ...

  9. ubuntu 外接显示器

    xrandr --help xrandr   # 列出显示器 sudo xrandr --output eDP-1 --off   # 关闭eDP-1显示器 sudo xrandr --output ...

  10. Cordova开发App使用USB进行真机调试

    在使用cordova开发app时,不像浏览器中可以直接使用浏览器的开发者工具进行调试.为了看到app的显示效果, 一种是使用模拟器进行展示,一种是使用真机进行展示. 模拟器:可以使用Android s ...