Skip to content

Commit 8e5afa3

Browse files
Merge pull request #178 from SyncfusionExamples/966446
966446: Added new features sample project.
2 parents 6786932 + 1bdf8cf commit 8e5afa3

File tree

17 files changed

+363
-0
lines changed

17 files changed

+363
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Export_checkbox_values", "Export_checkbox_values\Export_checkbox_values.csproj", "{7719AB70-75F7-4C57-BC73-0DCEAA9C889A}"
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+
{7719AB70-75F7-4C57-BC73-0DCEAA9C889A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7719AB70-75F7-4C57-BC73-0DCEAA9C889A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7719AB70-75F7-4C57-BC73-0DCEAA9C889A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7719AB70-75F7-4C57-BC73-0DCEAA9C889A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>

Forms/Export_checkbox_values/.NET/Export_checkbox_values/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Syncfusion.Pdf.Interactive;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Drawing;
4+
5+
//Create a new PDF document
6+
PdfDocument document = new PdfDocument();
7+
//Add a new page to the PDF document.
8+
PdfPage page = document.Pages.Add();
9+
10+
//Create the form.
11+
PdfForm form = document.Form;
12+
13+
//Enable the field auto naming.
14+
form.FieldAutoNaming = false;
15+
16+
//Set default appearance as false.
17+
document.Form.SetDefaultAppearance(false);
18+
19+
// Create First checkbox field
20+
PdfCheckBoxField checkBoxField1 = new PdfCheckBoxField(page, "CheckBox");
21+
checkBoxField1.Bounds = new RectangleF(10, 150, 50, 20);
22+
checkBoxField1.BorderColor = Color.Red;
23+
checkBoxField1.BorderWidth = 3;
24+
checkBoxField1.BackColor = Color.Yellow;
25+
26+
//Set the Export value
27+
checkBoxField1.ExportValue = "Value";
28+
checkBoxField1.Checked = true;
29+
30+
// Add to form
31+
form.Fields.Add(checkBoxField1);
32+
33+
// Create Second checkbox field
34+
PdfCheckBoxField checkBoxField2 = new PdfCheckBoxField(page, "CheckBox");
35+
checkBoxField2.Bounds = new RectangleF(10, 250, 50, 20);
36+
checkBoxField2.BorderColor = Color.Green;
37+
checkBoxField2.BorderWidth = 2;
38+
checkBoxField2.BackColor = Color.YellowGreen;
39+
40+
// Add to form
41+
form.Fields.Add(checkBoxField2);
42+
43+
//Create file stream.
44+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
45+
{
46+
//Save the PDF document to file stream.
47+
document.Save(outputFileStream);
48+
}
49+
//Close the document.
50+
document.Close(true);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Font_Subsetting_in_PDFA_conversion", "Font_Subsetting_in_PDFA_conversion\Font_Subsetting_in_PDFA_conversion.csproj", "{A6B4226C-2B95-4A14-9AF4-465525D9DD48}"
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+
{A6B4226C-2B95-4A14-9AF4-465525D9DD48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A6B4226C-2B95-4A14-9AF4-465525D9DD48}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A6B4226C-2B95-4A14-9AF4-465525D9DD48}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A6B4226C-2B95-4A14-9AF4-465525D9DD48}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="*" />
12+
</ItemGroup>
13+
14+
</Project>

PDF Conformance/Font_Subsetting_in_PDFA_conversion/.NET/Font_Subsetting_in_PDFA_conversion/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using Syncfusion.Pdf.Parsing;
2+
using Syncfusion.Pdf;
3+
using System.Reflection.Metadata;
4+
using Syncfusion.Drawing;
5+
using Syncfusion.Pdf.Graphics;
6+
using SkiaSharp;
7+
8+
//Get stream from an existing PDF document.
9+
FileStream docStream = new FileStream(Path.GetFullPath(@"Data/Input.pdf"), FileMode.Open, FileAccess.Read);
10+
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
11+
12+
//Sample level font event handling
13+
loadedDocument.SubstituteFont += LoadedDocument_SubstituteFont;
14+
15+
//Create conformance options
16+
PdfConformanceOptions options = new PdfConformanceOptions();
17+
//Set the conformance level
18+
options.ConformanceLevel = PdfConformanceLevel.Pdf_A1B;
19+
20+
//Embed fonts as subsets
21+
options.SubsetFonts = true;
22+
23+
// Convert to PDF/A conformance
24+
loadedDocument.ConvertToPDFA(options);
25+
26+
//Create file stream.
27+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
28+
{
29+
//Save the PDF document to file stream.
30+
loadedDocument.Save(outputFileStream);
31+
}
32+
33+
//Close the document.
34+
loadedDocument.Close(true);
35+
docStream.Close();
36+
37+
static void LoadedDocument_SubstituteFont(object sender, PdfFontEventArgs args)
38+
{
39+
//get the font name
40+
string fontName = args.FontName.Split(',')[0];
41+
42+
//get the font style
43+
PdfFontStyle fontStyle = args.FontStyle;
44+
SKFontStyle sKFontStyle = SKFontStyle.Normal;
45+
46+
if (fontStyle != PdfFontStyle.Regular)
47+
{
48+
if (fontStyle == PdfFontStyle.Bold)
49+
{
50+
sKFontStyle = SKFontStyle.Bold;
51+
}
52+
else if (fontStyle == PdfFontStyle.Italic)
53+
{
54+
sKFontStyle = SKFontStyle.Italic;
55+
}
56+
else if (fontStyle == (PdfFontStyle.Italic | PdfFontStyle.Bold))
57+
{
58+
sKFontStyle = SKFontStyle.BoldItalic;
59+
}
60+
}
61+
62+
SKTypeface typeface = SKTypeface.FromFamilyName(fontName, sKFontStyle);
63+
SKStreamAsset typeFaceStream = typeface.OpenStream();
64+
MemoryStream memoryStream = null;
65+
if (typeFaceStream != null && typeFaceStream.Length > 0)
66+
{
67+
//Create the fontData from the type face stream.
68+
byte[] fontData = new byte[typeFaceStream.Length];
69+
typeFaceStream.Read(fontData, typeFaceStream.Length);
70+
typeFaceStream.Dispose();
71+
72+
//Create the new memory stream from the font data.
73+
memoryStream = new MemoryStream(fontData);
74+
}
75+
76+
//set the font stream to the event args.
77+
args.FontStream = memoryStream;
78+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Redaction-fill-color-customization", "Redaction-fill-color-customization\Redaction-fill-color-customization.csproj", "{965B76D5-EB6B-401A-9715-2DAFCAF89573}"
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+
{965B76D5-EB6B-401A-9715-2DAFCAF89573}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{965B76D5-EB6B-401A-9715-2DAFCAF89573}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{965B76D5-EB6B-401A-9715-2DAFCAF89573}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{965B76D5-EB6B-401A-9715-2DAFCAF89573}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

0 commit comments

Comments
 (0)