Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Create_NewPDF_From_Exsisting_document_pages/Data/Input.pdf
Binary file not shown.
7 changes: 6 additions & 1 deletion Create_NewPDF_From_Exsisting_document_pages/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<PdfViewer:PdfViewerControl Name="PDFViewer"/>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<PdfViewer:PdfViewerControl Name="PDFViewer" Grid.Row="1"/>
<Button HorizontalAlignment="Center" VerticalAlignment="Center" Content="Create document" Margin="45,10,0,0" Click="Button_Click" RenderTransformOrigin="-0.112,0.559"/>
</Grid>
</Window>
13 changes: 9 additions & 4 deletions Create_NewPDF_From_Exsisting_document_pages/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ public MainWindow()
{
InitializeComponent();

PDFViewer.Load(filePath + "Input.pdf");
}

private void Button_Click(object sender, RoutedEventArgs e)
{
//Load a PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument(filePath + "Input.pdf");
PdfLoadedDocument ldoc = new PdfLoadedDocument(filePath + "Input.pdf");

ldoc.FlattenAnnotations();

if(ldoc.Form != null && ldoc.Form.Fields.Count > 0)
ldoc.Form.FlattenFields();
if (ldoc.Form != null && ldoc.Form.Fields.Count > 0)
ldoc.Form.FlattenFields();

//Create a new instance of PdfDocument class
PdfDocument document = new PdfDocument();
Expand All @@ -56,7 +61,7 @@ public MainWindow()
g.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(page.GetClientSize().Width, page.GetClientSize().Height));

}
document.Save( filePath + "Output.pdf");
document.Save(filePath + "Output.pdf");
PDFViewer.Load(filePath + "Output.pdf");
}
}
Expand Down