[英]WPF FixedDocument background image
Where to put the Background Image for a FixedDocument ?在哪里放置固定文档的背景图像? I see it in FlowDocument, but not in FixedDocument.我在 FlowDocument 中看到它,但在 FixedDocument 中没有看到。
In FlowDocument在 FlowDocument 中
<FlowDocument.Background>
<ImageBrush>
<ImageBrush.ImageSource>
<!--Image source here...-->
</ImageBrush.ImageSource>
</ImageBrush>
</FlowDocument.Background>
You should be able to set it page by page using FixedPage.Background
for each fixed page:您应该能够使用FixedPage.Background
为每个固定页面逐页设置它:
<DocumentViewer Name="mainRTB" >
<FixedDocument>
<FixedDocument.Resources>
<ImageBrush x:Key="backgroundImage" TileMode="Tile" Stretch="Fill" Viewport="0,0,1.0,0.33333333" AlignmentX="Center">
<ImageBrush.ImageSource>
<!--Image source here...-->
</ImageBrush.ImageSource>
</ImageBrush>
</FixedDocument.Resources>
<PageContent>
<!-- 7" x 9" page -->
<FixedPage Width="672" Height="864" Background="{StaticResource backgroundImage}">
<StackPanel Orientation="Vertical" FixedPage.Left="280" FixedPage.Top="150">
<Label FontFamily="Arial" FontWeight="Bold" FontSize="18" Content="Jane Eyre" HorizontalAlignment="Center"/>
<Label FontFamily="Arial" FontStyle="Italic" FontSize="14" Content="Charlotte Brontë" HorizontalAlignment="Center"/>
</StackPanel>
</FixedPage>
</PageContent>
<PageContent>
<FixedPage Width="672" Height="864" Background="{StaticResource backgroundImage}">
<StackPanel Margin="48">
<TextBlock FontFamily="Cambria" FontSize="14" Width="576" TextWrapping="Wrap">
There was no possibility etc.
</TextBlock>
<TextBlock FontFamily="Cambria" FontSize="14" Width="576" TextWrapping="Wrap" Margin="0,25,0,0">
I was glad of it etc.
</TextBlock>
</StackPanel>
</FixedPage>
</PageContent>
</FixedDocument>
</DocumentViewer>
Seems like it prints too -- at least I saw my background image show up when printing to PDF995.似乎它也能打印——至少我在打印到 PDF995 时看到了我的背景图像。
You can do it using this way :你可以用这种方式做到这一点:
<FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06"
Width="793.60" Height="1122.56" xml:lang="fr">
<Canvas>
<Path Data="M 0.00,0.00 L 0.00,3508.00 L 2480.00,3508.00 L 2480.00,0.00 Z">
<Path.Fill>
<ImageBrush ImageSource="xxx.jpg"
TileMode="None"
Viewbox="0,0,3306.67,4677.33"
ViewboxUnits="Absolute"
Viewport="0.00,0.00,2480.00,3508.00"
ViewportUnits="Absolute"/>
</Path.Fill>
</Path>
...
</Canvas>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.