Skip to content

Commit a3c9164

Browse files
Merge pull request #202 from SyncfusionExamples/260113
260113: Added proper sample code for quiet Zone.
2 parents 11f4036 + ee3d0b3 commit a3c9164

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed
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.36408.4 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adding-quiet-zones-to-a-barcode", "Adding-quiet-zones-to-a-barcode\Adding-quiet-zones-to-a-barcode.csproj", "{BB75FA4B-4A5C-4149-9B1E-6B288022F021}"
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+
{BB75FA4B-4A5C-4149-9B1E-6B288022F021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{BB75FA4B-4A5C-4149-9B1E-6B288022F021}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{BB75FA4B-4A5C-4149-9B1E-6B288022F021}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{BB75FA4B-4A5C-4149-9B1E-6B288022F021}.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 = {14BAC825-761B-4A6D-B26F-E4EB41AF355D}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Adding_quiet_zones_to_a_barcode</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="*" />
13+
</ItemGroup>
14+
15+
</Project>

Barcode/Adding-quiet-zones-to-a-barcode/.NET/Adding-quiet-zones-to-a-barcode/Output/gitkeep.txt

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Syncfusion.Drawing;
2+
using Syncfusion.Pdf;
3+
using Syncfusion.Pdf.Barcode;
4+
using Syncfusion.Pdf.Graphics;
5+
6+
//Create a new PDF document.
7+
PdfDocument document = new PdfDocument();
8+
9+
//Create a new page.
10+
PdfPage page = document.Pages.Add();
11+
12+
// Create barcode with quiet zones
13+
PdfCode128Barcode barcode = new PdfCode128Barcode
14+
{
15+
Text = "SYNCFUSION",
16+
BarHeight = 40,
17+
QuietZone = new PdfBarcodeQuietZones
18+
{
19+
Left = 15, // 15 points = ~5.3mm
20+
Right = 15,
21+
Top = 8, // 8 points = ~2.8mm
22+
Bottom = 8
23+
}
24+
};
25+
26+
//Draw a barcode on the new page.
27+
barcode.Draw(page, new PointF(10, 10));
28+
29+
//Draw a rectangle based on the barcode size.
30+
page.Graphics.DrawRectangle(PdfPens.Red, new RectangleF(10, 10, barcode.Size.Width, barcode.Size.Height));
31+
32+
//Create file stream.
33+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
34+
{
35+
//Save the PDF document to file stream.
36+
document.Save(outputFileStream);
37+
}
38+
39+
//Close the document.
40+
document.Close(true);

0 commit comments

Comments
 (0)