我需要使用自定義打印模板打印多個頁面的一些幫助。打印模板(一個Silverlight用戶控件)由兩個文本塊(標題和內容顯示並隨後打印相應的文本)組成。我遇到的問題是它唯一能夠打印1頁,我如何擴展它以打印多個頁面。這是工作流程 - 第一次嵌入在子窗口(樣定製消息框的)文本塊上顯示使用自定義打印模板(用戶控件)在Silverlight 4中進行多頁打印
- 含量(待印刷其可以是非常大)。
- 此內容需要打印,所以我創建了一個自定義打印模板,它將分別打印標題和內容。
- 現在,我不確定如何將其擴展爲打印多個頁面。
這裏是我的XAML -
<StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,10,10" >
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="10" BorderThickness="5" Background="White" Height="50" >
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="2" TextWrapping="Wrap" Name="TitleTextBlock" FontSize="16"
TextAlignment="Center" FontFamily="Times New Roman" FontStyle="Italic" FontWeight="SemiBold" >
</TextBlock>
</Border>
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="10" Margin="0,10,0,0" BorderThickness="5" Background="White" Height="950" >
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10" TextWrapping="Wrap" Name="ContentTextBlock" FontSize="14"
FontFamily="Times New Roman" FontWeight="Normal" >
</TextBlock>
</Border>
</StackPanel>
和我的代碼 -
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
printDoc.Print("MyTest")
End Sub
Private Sub printDoc_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim printPage As New PrintingPageTemplate
'printPage.PageTitle = Me.Title.ToString
'printPage.PageContent = Me.txtMessage.Text
printPage.TitleTextBlock.Text = Me.Title.ToString
printPage.ContentTextBlock.Text = Me.txtMessage.Text 'The txtMessage is a text block which consists of data to be printed and it can have very large content
e.PageVisual = printPage
'e.HasMorePages = True ' This doesn't work
End Sub
需要一些邏輯將檢查TitleTextBlock的總規模,創造PrintingTemplate的新實例。有人可以請指出我怎麼能做到這一點? (我希望我能夠爲我的問題提供足夠的信息)。