WPF 打印不显示的元素
<Window x:Class="_097打印不显示的元素.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="184" Width="269">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Label>Scale Percentage:</Label>
<TextBox MinWidth="50" Name="txtScale">500</TextBox>
</StackPanel>
<Button Grid.Row="1" Name="btnPrint" Click="btnPrint_Click_1">Print</Button>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace _097打印不显示的元素
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnPrint_Click_1(object sender, RoutedEventArgs e)
{
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
Run run = new Run("This is a test of printing function");
TextBlock visual = new TextBlock();
visual.Inlines.Add(run);
visual.Margin = new Thickness(15);
visual.TextWrapping = TextWrapping.Wrap;
double zoom;
if (double.TryParse(txtScale.Text, out zoom))
{
visual.LayoutTransform = new ScaleTransform(zoom / 100, zoom / 100);
Size pageSize = new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight);
visual.Measure(pageSize);
visual.Arrange(new Rect(0, 0, pageSize.Width, pageSize.Height));
dialog.PrintVisual(visual, "A Scaled Drawing");
}
else
{
MessageBox.Show("Invalid Scale Value");
}
}
}
}
}
WPF 打印不显示的元素的更多相关文章
- 对页面制定区域进行打印,以及打印不显示页脚URL的方法
第一种方式 - 此种方式简单易用,但不能进行页面设置,会在底部显示页面的URL地址. 打印命令:只需在页面上的按钮事件调用这段JS代码 javascript:window.print(); ===== ...
- WPF笔记(1.3 属性元素)——Hello,WPF!
原文:WPF笔记(1.3 属性元素)--Hello,WPF! 这一节中“属性元素”的概念可以用匪夷所思形容.1.WPF用标签元素实现对象建模,有两种:Control和Container,都用来装载内容 ...
- [WPF疑难]ErrorTemplate显示与隐藏问题
原文:[WPF疑难]ErrorTemplate显示与隐藏问题 [WPF疑难]ErrorTemplate显示与隐藏问题 周 ...
- jquery可见性选择器(匹配匹配所有显示的元素)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- WPF打印票据
最近工作的内容是有关于WPF的,整体开发没有什么难度,主要是在打印上因为没有任何经验,犯了一些难,不过还好,解决起来也不是很费劲. WPF打印票据或者是打印普通纸张区别不大,只是说打印票据要把需要打的 ...
- ecshop订单打印页显示商品缩略图和序号
ecshop订单打印页显示商品缩略图和序号 订单打印页显示商品缩略图,在论坛没找到适合2.7.2相关的文章,特意贴上来给大家研究一下.1.找到 $sql = "SELECT o.*, IF( ...
- javascript full screen 全屏显示 页面元素
javascript full screen 全屏显示 页面元素 要想让页面的某个元素全屏显示,就像在网页上看视频的时候,可以全屏观看一样,该怎么实现呢? 一种最简单的方式,就是动态改变你想要全屏显示 ...
- AvalonEdit-基于WPF的代码显示控件
AvalonEdit是基于WPF的代码显示控件,项目地址:https://github.com/icsharpcode/AvalonEdit,支持C#,javascript,C++,XML,HTML, ...
- CSS之选择符、链接、盒子模型、显示隐藏元素
<html> <head> <meta charset="utf-8"> <title>选择符.链接.盒子模型.显示隐藏元素< ...
随机推荐
- linux下如何查找nginx配置文件的位置
nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件. locate nginx.conf /usr/local/etc/nginx/ng ...
- [ES6] Use ES6 Proxies
A JavaScript Proxy allows you to intercept operations performed on objects, arrays, or functions lik ...
- [GraphQL] Add an Interface to a GraphQL Schema
As we start building out more complex GraphQL schemas, certain fields start to repeat across differe ...
- 网络异常与SQL Server事务
SQL Server事务遭遇网络异常时的处理机制浅析 SQL Server数据库中,如果应用程序正在执行一个事务的时候突然遭遇了网络异常,例如网络掉包,网络中断等,那么这个事务会怎么样? SQL Se ...
- 后台返回的HTML整个页面代码打开方法
后台返回的html代码片段,需要插入html标签中,而返回的整个html文档,则需要重写整个页面. 解决方法: 需要一个中转页面,用document.write()方法重写整个页面: // POST任 ...
- github上最全的资源教程-前端涉及的所有知识体系【转】
github上最全的资源教程-前端涉及的所有知识体系[转自:蓝猫的博客] 综合类 综合类 地址 前端知识体系 http://www.cnblogs.com/sb19871023/p/3894452.h ...
- 5.3.3.1 deque其他使用方式
在本节里提供了一些关于deque其他使用方式. 提供相似UNIX中的命令tail的功能,显示一个文件最后面一段文本: def tail(filename, n=10): '返回文件最后的n行文本' w ...
- 小强的HTML5移动开发之路(33)—— jqMobi基础
一.什么是jqMobi jqMobi是由appMobi针对HTML5浏览器和移动设备开发的javascript框架,是个极快速的查询选择库,支持W3C查询. 版本 jqMobi源码最初在2012年1月 ...
- QQ欢乐豆斗地主心得体会(四):合谋赢豆
刚刚又在玩QQ欢乐斗地主,只可惜,这次不够欢乐. 本金,300万豆,运气比较好,赢到将近400万.突然,形势急转直下,一直输,一直到180多万豆.本来这一局,有硬炸在手,但是没有癞子,基本被吊打的节奏 ...
- Python应用库大全总结
学python,想必大家都是从爬虫开始的吧.毕竟网上类似的资源很丰富,开源项目也非常多. python学习网络爬虫主要分3个大的版块:抓取,分析,存储 当我们在浏览器中输入一个url后回车,后台会发生 ...