-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
90020bb
commit db5288f
Showing
37 changed files
with
583 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
.../Add_bookmarks_to_merge_PDF_document_NET/.NET/Add_bookmarks_to_merge_PDF_document_NET.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add_bookmarks_to_merge_PDF_document_NET", "Add_bookmarks_to_merge_PDF_document_NET\Add_bookmarks_to_merge_PDF_document_NET.csproj", "{FDE5360D-5996-4B5B-8492-FA8DB10C9F60}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{FDE5360D-5996-4B5B-8492-FA8DB10C9F60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FDE5360D-5996-4B5B-8492-FA8DB10C9F60}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FDE5360D-5996-4B5B-8492-FA8DB10C9F60}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FDE5360D-5996-4B5B-8492-FA8DB10C9F60}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {08181FD2-8C7B-41F1-8F18-F1F7A3E5866A} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
...ET/Add_bookmarks_to_merge_PDF_document_NET/Add_bookmarks_to_merge_PDF_document_NET.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.NET" Version="21.2.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+16.7 KB
...ookmarks_to_merge_PDF_document_NET/.NET/Add_bookmarks_to_merge_PDF_document_NET/File1.pdf
Binary file not shown.
Binary file added
BIN
+250 KB
...ookmarks_to_merge_PDF_document_NET/.NET/Add_bookmarks_to_merge_PDF_document_NET/File2.pdf
Binary file not shown.
41 changes: 41 additions & 0 deletions
41
...okmarks_to_merge_PDF_document_NET/.NET/Add_bookmarks_to_merge_PDF_document_NET/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Drawing; | ||
using System.Reflection.Metadata; | ||
|
||
// Create a PDF document. | ||
using (PdfDocument finalDocument = new PdfDocument()) | ||
{ | ||
//Load the first PDF document. | ||
using (FileStream firstStream = new FileStream(Path.GetFullPath("../../../File1.pdf"), FileMode.Open, FileAccess.Read)) | ||
//Load the second PDF document. | ||
using (FileStream secondStream = new FileStream(Path.GetFullPath("../../../File2.pdf"), FileMode.Open, FileAccess.Read)) | ||
{ | ||
//Create a list of streams to merge. | ||
Stream[] streams = { firstStream, secondStream }; | ||
//Merge the PDF documents. | ||
PdfDocumentBase.Merge(finalDocument, streams); | ||
//Create a bookmark for the first PDF file. | ||
PdfBookmark bookmark1 = finalDocument.Bookmarks.Add("Chapter 1 - Barcodes"); | ||
//Sets the destination page for first bookmark. | ||
bookmark1.Destination = new PdfDestination(finalDocument.Pages[0]); | ||
//Sets the destination location for first bookmark. | ||
bookmark1.Destination.Location = new PointF(20, 20); | ||
//Create a bookmark for the second PDF file. | ||
PdfBookmark bookmark2 = finalDocument.Bookmarks.Add("Chapter 2 - HTTP Succinctly"); | ||
//Sets the destination page for second bookmark. | ||
bookmark2.Destination = new PdfDestination(finalDocument.Pages[3]); | ||
//Sets the destination location for second bookmark. | ||
bookmark2.Destination.Location = new PointF(20, 20); | ||
|
||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
finalDocument.Save(outputFileStream); | ||
} | ||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ombine_and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Combine_and_digitally_sign_the_PDF_files", "Combine_and_digitally_sign_the_PDF_files\Combine_and_digitally_sign_the_PDF_files.csproj", "{14EE31C3-85BD-40C3-ACD2-5636FC81D969}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{14EE31C3-85BD-40C3-ACD2-5636FC81D969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{14EE31C3-85BD-40C3-ACD2-5636FC81D969}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{14EE31C3-85BD-40C3-ACD2-5636FC81D969}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{14EE31C3-85BD-40C3-ACD2-5636FC81D969}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {DB76F8CB-8546-4A5E-98F9-D4411F645BF4} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
.../Combine_and_digitally_sign_the_PDF_files/Combine_and_digitally_sign_the_PDF_files.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.NET" Version="21.2.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+16.7 KB
..._and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files/File1.pdf
Binary file not shown.
Binary file added
BIN
+250 KB
..._and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files/File2.pdf
Binary file not shown.
Binary file added
BIN
+2.27 KB
...ne_and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files/PDF.pfx
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
...and_digitally_sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using Syncfusion.Drawing; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Pdf.Security; | ||
using System.Reflection.Metadata; | ||
|
||
//Create a new PDF document. | ||
PdfDocument finalDocument = new PdfDocument(); | ||
|
||
//Get the stream from an existing PDF documents. | ||
FileStream stream1 = new FileStream(Path.GetFullPath("../../../File1.pdf"), FileMode.Open, FileAccess.Read); | ||
FileStream stream2 = new FileStream(Path.GetFullPath("../../../File2.pdf"), FileMode.Open, FileAccess.Read); | ||
//Creates a PDF stream for merging. | ||
Stream[] streams = { stream1, stream2 }; | ||
//Merges PDF documents. | ||
PdfDocumentBase.Merge(finalDocument, streams); | ||
|
||
//Creates a certificate instance from PFX file with private key. | ||
FileStream certificateStream = new FileStream(Path.GetFullPath("../../../PDF.pfx"), FileMode.Open, FileAccess.Read); | ||
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "syncfusion"); | ||
|
||
//Creates a digital signature. | ||
PdfSignature signature = new PdfSignature(finalDocument, finalDocument.Pages[0], pdfCert, "Signature"); | ||
//Sets an image for signature field. | ||
FileStream imageStream = new FileStream(Path.GetFullPath("../../../signature.png"), FileMode.Open, FileAccess.Read); | ||
//Sets an image for signature field. | ||
PdfBitmap signatureImage = new PdfBitmap(imageStream); | ||
//Sets signature information. | ||
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100)); | ||
signature.ContactInfo = "[email protected]"; | ||
signature.LocationInfo = "Honolulu, Hawaii"; | ||
signature.Reason = "I am author of this document."; | ||
|
||
//Draw the image in signature appearance. | ||
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0, 0, 100, 100)); | ||
|
||
//Create file stream | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream | ||
finalDocument.Save(outputFileStream); | ||
} | ||
|
||
//Close the document | ||
finalDocument.Close(true); | ||
|
Binary file added
BIN
+13.7 KB
..._sign_the_PDF_files/.NET/Combine_and_digitally_sign_the_PDF_files/signature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
...o_portrait_and_merge_PDF_files/.NET/Convert_landscape_to_portrait_and_merge_PDF_files.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert_landscape_to_portrait_and_merge_PDF_files", "Convert_landscape_to_portrait_and_merge_PDF_files\Convert_landscape_to_portrait_and_merge_PDF_files.csproj", "{48485EA1-D6AC-4E5C-AC4A-6825EE9806E6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{48485EA1-D6AC-4E5C-AC4A-6825EE9806E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{48485EA1-D6AC-4E5C-AC4A-6825EE9806E6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{48485EA1-D6AC-4E5C-AC4A-6825EE9806E6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{48485EA1-D6AC-4E5C-AC4A-6825EE9806E6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {C4FE4876-2775-4FFD-BD2A-C0B5D85EB37B} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
..._to_portrait_and_merge_PDF_files/Convert_landscape_to_portrait_and_merge_PDF_files.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.NET" Version="21.2.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+16.7 KB
...rait_and_merge_PDF_files/.NET/Convert_landscape_to_portrait_and_merge_PDF_files/File1.pdf
Binary file not shown.
Binary file added
BIN
+250 KB
...rait_and_merge_PDF_files/.NET/Convert_landscape_to_portrait_and_merge_PDF_files/File2.pdf
Binary file not shown.
50 changes: 50 additions & 0 deletions
50
...ait_and_merge_PDF_files/.NET/Convert_landscape_to_portrait_and_merge_PDF_files/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
using System.Reflection.Metadata; | ||
using Syncfusion.Pdf.Graphics; | ||
using System.Xml.Linq; | ||
using Syncfusion.Drawing; | ||
|
||
//Create a new PDF document. | ||
PdfDocument finalDocument = new PdfDocument(); | ||
//Change the page orientation to landscape. | ||
finalDocument.PageSettings.Orientation = PdfPageOrientation.Landscape; | ||
//Set margin to 0 in PDF document. | ||
finalDocument.PageSettings.Margins.All = 0; | ||
|
||
//Load an existing PDF document. | ||
FileStream stream1 = new FileStream(Path.GetFullPath("../../../File1.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream1); | ||
|
||
for (int i = 0; i < loadedDocument.Pages.Count; i++) | ||
{ | ||
//Load the page. | ||
PdfLoadedPage loadedPage = loadedDocument.Pages[i] as PdfLoadedPage; | ||
//Create the template from the page. | ||
PdfTemplate template = loadedPage.CreateTemplate(); | ||
//Add the page. | ||
PdfPage page = finalDocument.Pages.Add(); | ||
//Create the graphics. | ||
PdfGraphics graphics = page.Graphics; | ||
//Draw the template. | ||
graphics.DrawPdfTemplate(template, PointF.Empty, new SizeF(page.Size.Width, page.Size.Height)); | ||
} | ||
|
||
//Load an existing PDF document. | ||
FileStream stream2 = new FileStream(Path.GetFullPath("../../../File2.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument loadedDocument2 = new PdfLoadedDocument(stream2); | ||
finalDocument.ImportPageRange(loadedDocument2, 0, loadedDocument2.Pages.Count - 1); | ||
|
||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
finalDocument.Save(outputFileStream); | ||
} | ||
|
||
//Close the document. | ||
finalDocument.Close(true); | ||
loadedDocument.Close(true); | ||
loadedDocument2.Close(true); |
25 changes: 25 additions & 0 deletions
25
Merge PDFs/Crop_PDF_pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crop_PDF_pages_and_merge_NET", "Crop_PDF_pages_and_merge_NET\Crop_PDF_pages_and_merge_NET.csproj", "{1564C082-9545-482F-8D3A-FFDADD64805B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{1564C082-9545-482F-8D3A-FFDADD64805B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1564C082-9545-482F-8D3A-FFDADD64805B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1564C082-9545-482F-8D3A-FFDADD64805B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1564C082-9545-482F-8D3A-FFDADD64805B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1C68240E-31B9-44A0-A2BF-679DEC2703DE} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
...pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET/Crop_PDF_pages_and_merge_NET.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.NET" Version="21.2.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+16.7 KB
Merge PDFs/Crop_PDF_pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET/File1.pdf
Binary file not shown.
Binary file added
BIN
+250 KB
Merge PDFs/Crop_PDF_pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET/File2.pdf
Binary file not shown.
54 changes: 54 additions & 0 deletions
54
Merge PDFs/Crop_PDF_pages_and_merge_NET/.NET/Crop_PDF_pages_and_merge_NET/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using Syncfusion.Pdf.Interactive; | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
using Syncfusion.Pdf.Graphics; | ||
using Syncfusion.Drawing; | ||
|
||
//Get the stream from an existing PDF document. | ||
FileStream stream1 = new FileStream(Path.GetFullPath("../../../File1.pdf"), FileMode.Open, FileAccess.Read); | ||
//Load the PDF document. | ||
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(stream1); | ||
//Load the page. | ||
PdfLoadedPage loadedPage = loadedDocument.Pages[0] as PdfLoadedPage; | ||
//Create the template from the page. | ||
PdfTemplate template = loadedPage.CreateTemplate(); | ||
//Create a new PDF document. | ||
PdfDocument document = new PdfDocument(); | ||
//Calculate height from inches. | ||
float inches = 6f; | ||
float height = inches * 72; | ||
//Set the document margin and height. | ||
document.PageSettings.Height = height; | ||
//Add the page to new PDF docment. | ||
PdfPage page = document.Pages.Add(); | ||
//Create the graphics. | ||
PdfGraphics graphics = page.Graphics; | ||
//Draw the template. | ||
graphics.DrawPdfTemplate(template, new PointF(0, 0)); | ||
|
||
//Save the PDF document to stream. | ||
MemoryStream stream = new MemoryStream(); | ||
document.Save(stream); | ||
//Close the PDF documents. | ||
document.Close(true); | ||
loadedDocument.Close(true); | ||
|
||
//Creates a PDF document. | ||
PdfDocument finalDocument = new PdfDocument(); | ||
//Get the stream from an existing PDF documents. | ||
FileStream stream2 = new FileStream(Path.GetFullPath("../../../File2.pdf"), FileMode.Open, FileAccess.Read); | ||
Stream[] streams = { stream, stream2 }; | ||
//Merges PDF documents. | ||
PdfDocumentBase.Merge(finalDocument, streams); | ||
|
||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Output.pdf"), FileMode.Create, FileAccess.ReadWrite)) | ||
{ | ||
//Save the PDF document to file stream. | ||
finalDocument.Save(outputFileStream); | ||
} | ||
|
||
//Close the documents. | ||
finalDocument.Close(true); |
25 changes: 25 additions & 0 deletions
25
...erge_PDF_files_and_fill_form_fields_NET/.NET/Merge_PDF_files_and_fill_form_fields_NET.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32819.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge_PDF_files_and_fill_form_fields_NET", "Merge_PDF_files_and_fill_form_fields_NET\Merge_PDF_files_and_fill_form_fields_NET.csproj", "{0306C6D2-AED9-4306-B8D4-CC38EF592E63}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0306C6D2-AED9-4306-B8D4-CC38EF592E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0306C6D2-AED9-4306-B8D4-CC38EF592E63}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0306C6D2-AED9-4306-B8D4-CC38EF592E63}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0306C6D2-AED9-4306-B8D4-CC38EF592E63}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7EE2F660-613C-414B-8F8E-6E7346A7A76A} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+124 KB
...DF_files_and_fill_form_fields_NET/.NET/Merge_PDF_files_and_fill_form_fields_NET/File1.pdf
Binary file not shown.
Binary file added
BIN
+13.4 KB
...DF_files_and_fill_form_fields_NET/.NET/Merge_PDF_files_and_fill_form_fields_NET/File2.pdf
Binary file not shown.
Oops, something went wrong.