参考: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. MJRefresh在Xode6中报错处理

      MJRefresh在Xcode6中会报错,objc_msgSend(self.beginRefreshingTaget, self.beginRefreshingAction, self),简单调 ...

  2. 自学大数据(hadoop)小插曲__虚拟机工具

    安装VMware Tools VMware 版本:10.0.1 ubuntu(linux) 版本:16.04 LTS 序言:本来第一天可以访问共享文件夹,第二天重新安装了四个ubuntu,可惜确无法访 ...

  3. Object详解(转)

    Object类是Java中其他所有类的祖先,没有Object类Java面向对象无从谈起.作为其他所有类的基类,Object具有哪些属性和行为,是Java语言设计背后的思维体现. Object类位于ja ...

  4. java 日志脱敏框架 sensitive-v0.0.4 系统内置常见注解,支持自定义注解

    项目介绍 日志脱敏是常见的安全需求.普通的基于工具类方法的方式,对代码的入侵性太强.编写起来又特别麻烦. 本项目提供基于注解的方式,并且内置了常见的脱敏方式,便于开发. 特性 基于注解的日志脱敏. 可 ...

  5. vue.js 自定义事件

    <div id="app"> <h2>{{num}}</h2> <h1>全局组件</h1> <my-compone ...

  6. nginx跨域配置(windos走过的坑)

    nginx下载地址: http://nginx.org/en/download.html 红圈区域是稳定版 解压之后放在文件夹就可以了. 解压后: 注意:这里面有个nginx.exe文件,一般情况下双 ...

  7. Nagios Email告警 发不了,可能是 /var/spool/mqueue nagios用户没权限

    Nagios邮件报警   Nagios邮件报警 准备 yum - y install ntp        ntpdate time.windows.com   同步时间,否则无法发送邮件 yum - ...

  8. 70.纯 CSS 创作一只徘徊的果冻怪兽

    原文地址:https://segmentfault.com/a/1190000015484852 感想:monster中边框角.上下动画.旋转动画.左右动画,眼睛中transform:scaleY(n ...

  9. Java运行时数据区域分析

    Java虚拟机在执行Java程序的过程中会把它所管理的内存划分为若干个不同的数据区域.这些区域都有各自的用途,以及创建和销毁的时间,有的区域随着虚拟机进程的启动而存在,有些区域则依赖用户线程的启动和结 ...

  10. UVa514 Rails (栈)

    题意:一列有n节车厢的火车按顺序进站,给你一个出站顺序,问你该火车的车厢能否以该顺序出站? 分析:出站的车厢满足后进先出的关系,所以我们考虑采用栈s 假设车厢一共有n节,n = 5: 进站顺序A:1 ...