Skip to content

Commit 78adbb7

Browse files
Added sample for KB How to create a new document with exsisting document pages in pdfViewer?
1 parent 682ab26 commit 78adbb7

File tree

15 files changed

+441
-0
lines changed

15 files changed

+441
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
5+
</startup>
6+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="PDFViewer_WPF.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:PDFViewer_WPF"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
9+
namespace PDFViewer_WPF
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
}
17+
}
206 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf" xmlns:PdfViewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" x:Class="WPF_Sample_FW.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:WPF_Sample_FW"
7+
mc:Ignorable="d"
8+
Title="MainWindow" Height="450" Width="800">
9+
<Grid>
10+
<PdfViewer:PdfViewerControl Name="PDFViewer"/>
11+
</Grid>
12+
</Window>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using Syncfusion.Pdf;
2+
using Syncfusion.Pdf.Graphics;
3+
using Syncfusion.Pdf.Parsing;
4+
using Syncfusion.Pdf.Security;
5+
using Syncfusion.Windows.PdfViewer;
6+
using System;
7+
using System.Drawing;
8+
using System.IO;
9+
using System.Windows;
10+
using System.Windows.Controls;
11+
using System.Windows.Media;
12+
using Bitmap = System.Drawing.Bitmap;
13+
using Path = System.Windows.Shapes.Path;
14+
15+
namespace WPF_Sample_FW
16+
{
17+
/// <summary>
18+
/// Interaction logic for MainWindow.xaml
19+
/// </summary>
20+
public partial class MainWindow : Window
21+
{
22+
string filePath = "../../../Data/";
23+
bool addSignature = false;
24+
public MainWindow()
25+
{
26+
InitializeComponent();
27+
28+
//Load a PDF document
29+
PdfLoadedDocument ldoc = new PdfLoadedDocument(filePath + "Input.pdf");
30+
31+
ldoc.FlattenAnnotations();
32+
33+
if(ldoc.Form != null && ldoc.Form.Fields.Count > 0)
34+
ldoc.Form.FlattenFields();
35+
36+
//Create a new instance of PdfDocument class
37+
PdfDocument document = new PdfDocument();
38+
39+
//Set page margin value as 0
40+
document.PageSettings.Margins.All = 0;
41+
42+
//Set page size as A3
43+
document.PageSettings.Size = PdfPageSize.A3;
44+
45+
for (int i = 0; i < ldoc.Pages.Count; i++)
46+
{
47+
//Get loaded page as template
48+
PdfTemplate template = ldoc.Pages[i].CreateTemplate();
49+
50+
//Create new page
51+
PdfPage page = document.Pages.Add();
52+
53+
//Create Pdf graphics for the page
54+
PdfGraphics g = page.Graphics;
55+
56+
//Draw template with the size as page size
57+
g.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(page.GetClientSize().Width, page.GetClientSize().Height));
58+
59+
}
60+
document.Save( filePath + "Output.pdf");
61+
PDFViewer.Load(filePath + "Output.pdf");
62+
}
63+
}
64+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
<PackageReference Include="System.Drawing.Common" Version="9.0.8" />
10+
</ItemGroup>
11+
<Import Project="targets\MultiTargeting.targets" />
12+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36401.2
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFViewer_WPF", "PDFViewer_WPF.csproj", "{0FAA7523-B034-4EA9-860A-A8936DFFD40E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {BAAD6341-6945-42C7-8438-919E9DB8EB03}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System.Reflection;
2+
using System.Resources;
3+
using System.Runtime.CompilerServices;
4+
using System.Runtime.InteropServices;
5+
using System.Windows;
6+
7+
// General Information about an assembly is controlled through the following
8+
// set of attributes. Change these attribute values to modify the information
9+
// associated with an assembly.
10+
//[assembly: AssemblyTitle("PDFViewer_WPF")]
11+
//[assembly: AssemblyDescription("")]
12+
//[assembly: AssemblyConfiguration("")]
13+
//[assembly: AssemblyCompany("")]
14+
//[assembly: AssemblyProduct("PDFViewer_WPF")]
15+
//[assembly: AssemblyCopyright("Copyright © 2025")]
16+
//[assembly: AssemblyTrademark("")]
17+
//[assembly: AssemblyCulture("")]
18+
19+
// Setting ComVisible to false makes the types in this assembly not visible
20+
// to COM components. If you need to access a type in this assembly from
21+
// COM, set the ComVisible attribute to true on that type.
22+
[assembly: ComVisible(false)]
23+
24+
//In order to begin building localizable applications, set
25+
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
26+
//inside a <PropertyGroup>. For example, if you are using US english
27+
//in your source files, set the <UICulture> to en-US. Then uncomment
28+
//the NeutralResourceLanguage attribute below. Update the "en-US" in
29+
//the line below to match the UICulture setting in the project file.
30+
31+
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32+
33+
34+
//[assembly: ThemeInfo(
35+
// ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36+
// //(used if a resource is not found in the page,
37+
// // or application resource dictionaries)
38+
// ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39+
// //(used if a resource is not found in the page,
40+
// // app, or any theme specific resource dictionaries)
41+
//)]
42+
43+
44+
// Version information for an assembly consists of the following four values:
45+
//
46+
// Major Version
47+
// Minor Version
48+
// Build Number
49+
// Revision
50+
//
51+
//[assembly: AssemblyVersion("1.0.0.0")]
52+
//[assembly: AssemblyFileVersion("1.0.0.0")]

Create_NewPDF_From_Exsisting_document_pages/Properties/Resources.Designer.cs

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)