参考: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. MVC 5 调用存储过程参数配置方法-Procedure or function 'UP_***' expects parameter '@****', which was not supplied.

    MVC 5 调用存储过程参数配置方法-Procedure or function 'UP_***' expects parameter '@****', which was not supplied. ...

  2. 初识Velocity

    哇,好长时间没有写文章啦~ 楼主最近在工作中认识了一个叫做Velocity的java的模板引擎,小白的我去网上看了一下,应用还蛮多的,然而我目前接触到的只是用于基于模板生成这块的知识,想写个文章记下, ...

  3. DOM随时记

    1.node-type 返回元素的节点类型:可以在标签上进行设置 node-type="item"   ---来自新浪微博的首页写法

  4. all-document

    1.memorymanagement-whitepaper J2SE5.0 JVM 垃圾回收器相关英文 链接: https://pan.baidu.com/s/1mzkMxuFE82sfeVOToMb ...

  5. QAC静态测试配置及使用教程

    使用前提:安装成功QAC软件. . 1.打开软件如上 . 2.file->Auto-Create-Project,出现如下所示对话框 1-工程名字 2-将要分析的代码路径 3-代码报告输出路径 ...

  6. JEECG3.8 全套实战视频全部开放,免费下载!

    JEECG快速开发平台V3.8版本自去年10月份发布以来,下载使用数屡创新高,并受到众多开发者积极反馈.为帮助更多初学者能够快速上手,JEECG V3.8版本实战教程现已全面开放,免费下载!本教程深入 ...

  7. hbase版本升级的api对比

    前言 今天来介绍一下,hbase的2.1.0版本升级之后和1.2.6版本的api方法的一些不同之处. hbase的工具类 在介绍hbase的相关的java api之前,这里先介绍一下hbase的工具类 ...

  8. Python3 多线程、多进程

    python中的线程是假线程,不同线程之间的切换是需要耗费资源的,因为需要存储线程的上下文,不断的切换就会耗费资源.. python多线程适合io操作密集型的任务(如socket server 网络并 ...

  9. socket.io诡异的问题

    在socket.io客户端连接的时候,如果传入的query包含“sid”这个键时会报错,不知道具体原因.

  10. ReactiveX 学习笔记(25)使用 RxJS + Vue.js 调用 REST API

    JSON : Placeholder JSON : Placeholder (https://jsonplaceholder.typicode.com/) 是一个用于测试的 REST API 网站. ...