参考: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. tomcat和iis共用80端口的简明手册

    ​​对于使用tomcat-connector实现iis与tomcat实现80端口共用的问题,网上的信息异常混乱,很多地方误人子弟,浪费时间.本文给出简明手册式的做法: 首先列出我们需要做的事项: 1. ...

  2. Vue 编程式导航(通过js跳转页面)以及路由hash模式和history模式

    第一种方法: this.$router.push({path:'shopcontent?aid=3'}   第二种方法   this.$router.push({name:'news'}} 通过在ma ...

  3. JS面试Q&A(续2): Rest parameter,Arrow function 等

    rest parameter 和 Destructuring assignment. function fun1(...theArgs) { console.log(theArgs.length);} ...

  4. redis在实践中的一些常见问题以及优化思路

    1.fork耗时导致高并发请求延时 RDB和AOF的时候,其实会有生成RDB快照,AOF rewrite,耗费磁盘IO的过程,主进程fork子进程 fork的时候,子进程是需要拷贝父进程的空间内存页表 ...

  5. json文件转换成excel

    1.环境 python2.7 2.库 xlwt.demjson.json 3.code # -*- coding: utf-8 -*- import xlwt,demjson,json if __na ...

  6. css常见布局问题

    1.如何实现一个盒子在页面中上下左右居中 方法一:(盒子宽高固定时) .box{ width:400px; height:200px; background:#000; position:absolu ...

  7. 【转】【测试用例设计】WEB通用测试用例

    易用性 1.便于使用.理解.并能减少用户发生错误选择的可能性 2.当数据字段过多时,使用便于用户迅速吸取信息的方式表现信息,突出重点信息,标红等方式 3.显示与当前操作相关的信息,给出操作提示. 4. ...

  8. (python基础 函数)

    关键字参数:关键字参数和函数调用关系紧密,函数调用使用关键字参数来确定传入的参数值.使用关键字参数允许函数调用时参数的顺序与声明时不一致,因为 Python 解释器能够用参数名匹配参数值 必需参数:必 ...

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

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

  10. PG数据库基本命令——查询(笔记)

    1.插入数据(insert 语句) 语法: INSERT INTO TABLE_NAME (column1, column2, column3,...columnN) VALUES (value1, ...