File tree Expand file tree Collapse file tree 9 files changed +115
-0
lines changed
Printing-Examples/programmatically-print-currentpage Expand file tree Collapse file tree 9 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ <Solution >
2+ <Project Path =" Progamatic_printpage/Progamatic_printpage.csproj" />
3+ </Solution >
Original file line number Diff line number Diff line change 1+ <Application x : Class =" Progamatic_printpage.App"
2+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns : local =" clr-namespace:Progamatic_printpage"
5+ StartupUri =" MainWindow.xaml" >
6+ <Application .Resources>
7+
8+ </Application .Resources>
9+ </Application >
Original file line number Diff line number Diff line change 1+ using System . Configuration ;
2+ using System . Data ;
3+ using System . Windows ;
4+
5+ namespace Progamatic_printpage
6+ {
7+ /// <summary>
8+ /// Interaction logic for App.xaml
9+ /// </summary>
10+ public partial class App : Application
11+ {
12+ }
13+
14+ }
Original file line number Diff line number Diff line change 1+ using System . Windows ;
2+
3+ [ assembly: ThemeInfo (
4+ ResourceDictionaryLocation . None , //where theme specific resource dictionaries are located
5+ //(used if a resource is not found in the page,
6+ // or application resource dictionaries)
7+ ResourceDictionaryLocation . SourceAssembly //where the generic resource dictionary is located
8+ //(used if a resource is not found in the page,
9+ // app, or any theme specific resource dictionaries)
10+ ) ]
Original file line number Diff line number Diff line change 1+ <Window x : Class =" Progamatic_printpage.MainWindow"
2+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
5+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
6+ xmlns : local =" clr-namespace:Progamatic_printpage"
7+ xmlns : syncfusion =" clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
8+ mc : Ignorable =" d"
9+ Title =" MainWindow" Height =" 450" Width =" 800" >
10+ <Grid >
11+ <Grid .RowDefinitions>
12+ <RowDefinition Height =" Auto" />
13+ <RowDefinition Height =" *" />
14+ </Grid .RowDefinitions>
15+ <Button x : Name =" Print" Content =" Print" Width =" 100" Height =" 30" Margin =" 10" Click =" Print_Click" />
16+ <syncfusion : PdfViewerControl x : Name =" pdfViewer" Grid.Row=" 1" ></syncfusion : PdfViewerControl >
17+ </Grid >
18+ </Window >
Original file line number Diff line number Diff line change 1+ using System . Text ;
2+ using System . Windows ;
3+ using System . Windows . Controls ;
4+ using System . Windows . Data ;
5+ using System . Windows . Documents ;
6+ using System . Windows . Input ;
7+ using System . Windows . Media ;
8+ using System . Windows . Media . Imaging ;
9+ using System . Windows . Navigation ;
10+ using System . Windows . Shapes ;
11+
12+ namespace Progamatic_printpage
13+ {
14+ /// <summary>
15+ /// Interaction logic for MainWindow.xaml
16+ /// </summary>
17+ public partial class MainWindow : Window
18+ {
19+ public MainWindow ( )
20+ {
21+ InitializeComponent ( ) ;
22+ pdfViewer . Load ( "../../../Input.pdf" ) ;
23+ }
24+ private void Print_Click ( object sender , RoutedEventArgs e )
25+ {
26+ BitmapSource bitmapImage = pdfViewer . ExportAsImage ( pdfViewer . CurrentPageIndex - 1 ) ;
27+ Image image = new Image ( ) ;
28+ image . Source = bitmapImage ;
29+ PrintDialog printDialog = new PrintDialog ( ) ;
30+ bool ? result = printDialog . ShowDialog ( ) ;
31+ if ( result == true )
32+ {
33+ printDialog . PrintVisual ( image , "PDF current page" ) ;
34+ }
35+ }
36+
37+ }
38+
39+ }
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+
3+ <PropertyGroup >
4+ <OutputType >WinExe</OutputType >
5+ </PropertyGroup >
6+
7+ <ItemGroup >
8+ <PackageReference Include =" Syncfusion.PdfViewer.WPF" Version =" *" />
9+ </ItemGroup >
10+ <Import Project =" targets\MultiTargeting.targets" />
11+
12+ </Project >
Original file line number Diff line number Diff line change 1+ <Project >
2+ <PropertyGroup >
3+ <TargetFrameworks >net462;net8.0-windows;net9.0-windows;net10.0-windows</TargetFrameworks >
4+ <UseWPF >true</UseWPF >
5+ <GenerateAssemblyInfo >False</GenerateAssemblyInfo >
6+ <GenerateDocumentationFile >True</GenerateDocumentationFile >
7+ <EnableDefaultItems >True</EnableDefaultItems >
8+ <EnableDefaultEmbeddedResourceItems >True</EnableDefaultEmbeddedResourceItems >
9+ </PropertyGroup >
10+ </Project >
You can’t perform that action at this time.
0 commit comments