-
Notifications
You must be signed in to change notification settings - Fork 48
830501- Added Compress PDFs samples #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jeyalakshmit
wants to merge
4
commits into
master
Choose a base branch
from
Compress_FT_Sample
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Compression/Compress_secured_PDF_NET/.NET-Standard/Compress_secured_PDF_NET.sln
This file contains hidden or 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.6.33417.168 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compress_secured_PDF_NET", "Compress_secured_PDF_NET\Compress_secured_PDF_NET.csproj", "{A7643DD4-589A-41FC-AFE0-4C6316ED1AB0}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A7643DD4-589A-41FC-AFE0-4C6316ED1AB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A7643DD4-589A-41FC-AFE0-4C6316ED1AB0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A7643DD4-589A-41FC-AFE0-4C6316ED1AB0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A7643DD4-589A-41FC-AFE0-4C6316ED1AB0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {01627C7B-49BA-4C53-ACD4-9F9D2739263F} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
...ss_secured_PDF_NET/.NET-Standard/Compress_secured_PDF_NET/Compress_secured_PDF_NET.csproj
This file contains hidden or 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>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="21.2.9" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+1.77 MB
...ession/Compress_secured_PDF_NET/.NET-Standard/Compress_secured_PDF_NET/Data/SecurePDF.pdf
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
Compression/Compress_secured_PDF_NET/.NET-Standard/Compress_secured_PDF_NET/Program.cs
This file contains hidden or 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,30 @@ | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf.Security; | ||
using Syncfusion.Pdf; | ||
|
||
namespace Compress_secured_PDF_NET { | ||
internal class Program { | ||
static void Main(string[] args) { | ||
//Load existing PDF document. | ||
FileStream fileStream = new FileStream(Path.GetFullPath("../../../Data/SecurePDF.pdf"), FileMode.Open, FileAccess.Read); | ||
PdfLoadedDocument document = new PdfLoadedDocument(fileStream, "sample123"); | ||
|
||
//Create a new compression option. | ||
PdfCompressionOptions options = new PdfCompressionOptions(); | ||
//Enable the compress image. | ||
options.CompressImages = true; | ||
//Set the image quality. | ||
options.ImageQuality = 50; | ||
|
||
//Assign the compression option to the document | ||
document.Compress(options); | ||
//Create file stream. | ||
using (FileStream outputFileStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) { | ||
//Save the PDF document to file stream. | ||
document.Save(outputFileStream); | ||
} | ||
//Close the document. | ||
document.Close(true); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Compression/Merge_and_compress_PDF_NET/.NET-Standard/Merge_and_compress_PDF_NET.sln
This file contains hidden or 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.6.33417.168 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Merge_and_compress_PDF_NET", "Merge_and_compress_PDF_NET\Merge_and_compress_PDF_NET.csproj", "{57645AC9-37C6-4DF8-AD81-30EE1290FA49}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{57645AC9-37C6-4DF8-AD81-30EE1290FA49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{57645AC9-37C6-4DF8-AD81-30EE1290FA49}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{57645AC9-37C6-4DF8-AD81-30EE1290FA49}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{57645AC9-37C6-4DF8-AD81-30EE1290FA49}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {11312D7C-18D0-4A8D-996D-1044D027BE7F} | ||
EndGlobalSection | ||
EndGlobal |
Binary file added
BIN
+907 KB
...ion/Merge_and_compress_PDF_NET/.NET-Standard/Merge_and_compress_PDF_NET/Data/imageDoc.pdf
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
...mpress_PDF_NET/.NET-Standard/Merge_and_compress_PDF_NET/Merge_and_compress_PDF_NET.csproj
This file contains hidden or 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>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="21.2.9" /> | ||
</ItemGroup> | ||
|
||
</Project> |
47 changes: 47 additions & 0 deletions
47
Compression/Merge_and_compress_PDF_NET/.NET-Standard/Merge_and_compress_PDF_NET/Program.cs
This file contains hidden or 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,47 @@ | ||
using Syncfusion.Pdf.Parsing; | ||
using Syncfusion.Pdf; | ||
|
||
namespace Merge_and_compress_PDF_NET { | ||
internal class Program { | ||
static void Main(string[] args) { | ||
// Create a PDF document. | ||
using (PdfDocument finalDocument = new PdfDocument()) { | ||
|
||
// Get the stream from an existing PDF documents. | ||
using (FileStream firstStream = new FileStream(Path.GetFullPath("../../../Data/imageDoc.pdf"), FileMode.Open, FileAccess.Read)) | ||
|
||
using (FileStream secondStream = new FileStream(Path.GetFullPath("../../../Data/imageDoc.pdf"), FileMode.Open, FileAccess.Read)) { | ||
|
||
// Create a PDF stream for merging. | ||
Stream[] streams = { firstStream, secondStream }; | ||
|
||
// Merge PDF documents. | ||
PdfDocumentBase.Merge(finalDocument, streams); | ||
|
||
// Save the document into a stream. | ||
MemoryStream outputStream = new MemoryStream(); | ||
finalDocument.Save(outputStream); | ||
|
||
// Create a new PdfLoadedDocument object from the file stream. | ||
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(outputStream)) { | ||
|
||
// Create a new PdfCompressionOptions object. | ||
PdfCompressionOptions options = new PdfCompressionOptions(); | ||
|
||
// Enable the compress image and set image quality. | ||
options.CompressImages = true; | ||
options.ImageQuality = 50; | ||
|
||
// Compress the PDF document. | ||
loadedDocument.Compress(options); | ||
|
||
// Save the document into memory stream. | ||
using (FileStream memoryStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite)) { | ||
loadedDocument.Save(memoryStream); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.