区别只是红色部分的几句代码。意思就是设置一下属性让打印服务知道那是矢量方式来打印。。
// tests trying to force vector printing mode
private
void
PrintVectorForced_Click(
object
sender, RoutedEventArgs e)
{
PrintDocument doc =
new
PrintDocument();
doc.PrintPage += (s, ea) =>
{
StackPanel printPanel =
new
StackPanel();
Random rnd =
new
Random();
for
(
int
i = 0; i < 30; i++)
{
TextBlock row =
new
TextBlock();
row.Opacity = (rnd.Next(3, 10)) / 10.0;
row.Text =
"This is row "
+ i +
" of the current page being printed. Opacity is "
+ row.Opacity;
printPanel.Children.Add(row);
}
ea.PageVisual = printPanel;
ea.HasMorePages =
false
;
};
PrinterFallbackSettings settings =
new
PrinterFallbackSettings();
settings.ForceVector =
true
;
settings.OpacityThreshold = 0.5;
doc.Print(
"Silverlight Forced Vector Print"
, settings);
}