Skip to content

Commit 74d363e

Browse files
Adding Barcode generator sample
1 parent c163ff1 commit 74d363e

31 files changed

Lines changed: 1334 additions & 2 deletions

App.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>

MyBlazorApp.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.2" PrivateAssets="all" />
12+
<PackageReference Include="Syncfusion.Blazor.BarcodeGenerator" Version="19.4.0.56" />
13+
<PackageReference Include="Syncfusion.Blazor.Buttons" Version="19.4.0.56" />
14+
</ItemGroup>
15+
16+
</Project>

MyBlazorApp.sln

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.1.32210.238
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyBlazorApp", "MyBlazorApp.csproj", "{9994B11B-3089-44A7-AB29-5C5C554EFC01}"
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+
{9994B11B-3089-44A7-AB29-5C5C554EFC01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9994B11B-3089-44A7-AB29-5C5C554EFC01}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9994B11B-3089-44A7-AB29-5C5C554EFC01}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9994B11B-3089-44A7-AB29-5C5C554EFC01}.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 = {DE6020DC-9720-446D-B36A-3329638D1046}
24+
EndGlobalSection
25+
EndGlobal

Pages/Counter.razor

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}

Pages/FetchData.razor

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@page "/fetchdata"
2+
@inject HttpClient Http
3+
4+
<PageTitle>Weather forecast</PageTitle>
5+
6+
<h1>Weather forecast</h1>
7+
8+
<p>This component demonstrates fetching data from the server.</p>
9+
10+
@if (forecasts == null)
11+
{
12+
<p><em>Loading...</em></p>
13+
}
14+
else
15+
{
16+
<table class="table">
17+
<thead>
18+
<tr>
19+
<th>Date</th>
20+
<th>Temp. (C)</th>
21+
<th>Temp. (F)</th>
22+
<th>Summary</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
@foreach (var forecast in forecasts)
27+
{
28+
<tr>
29+
<td>@forecast.Date.ToShortDateString()</td>
30+
<td>@forecast.TemperatureC</td>
31+
<td>@forecast.TemperatureF</td>
32+
<td>@forecast.Summary</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
}
38+
39+
@code {
40+
private WeatherForecast[]? forecasts;
41+
42+
protected override async Task OnInitializedAsync()
43+
{
44+
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
45+
}
46+
47+
public class WeatherForecast
48+
{
49+
public DateTime Date { get; set; }
50+
51+
public int TemperatureC { get; set; }
52+
53+
public string? Summary { get; set; }
54+
55+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
56+
}
57+
}

Pages/Index.razor

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@page "/"
2+
@using Syncfusion.Blazor.Buttons;
3+
4+
<SfButton OnClick="OnExport">Export</SfButton>
5+
6+
<SfBarcodeGenerator @ref="BarcodeInst" Value="SYNC123"
7+
Type="BarcodeType.Code39"
8+
Height="100px"
9+
Width="200px"
10+
ForeColor="Red">
11+
<BarcodeGeneratorDisplayText Text="CODE39-BARCODE"></BarcodeGeneratorDisplayText>
12+
</SfBarcodeGenerator>
13+
14+
@code{
15+
SfBarcodeGenerator BarcodeInst;
16+
17+
private void OnExport()
18+
{
19+
BarcodeInst.Export("Syncfusion-image", BarcodeExportType.JPG);
20+
}
21+
}
22+
23+
<SfQRCodeGenerator Value="SYNC123"
24+
Height="100px"
25+
Width="200px"
26+
ForeColor="Red">
27+
<QRCodeGeneratorDisplayText Text="Syncfusion"></QRCodeGeneratorDisplayText>
28+
</SfQRCodeGenerator>
29+
30+
<SfDataMatrixGenerator Value="SYNCUser"
31+
Height="100px"
32+
Width="200px"
33+
ForeColor="Red"></SfDataMatrixGenerator>

Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Components.Web;
2+
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
3+
using MyBlazorApp;
4+
using Syncfusion.Blazor;
5+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NTkyMTQ5QDMxMzkyZTM0MmUzMEVXUE9pUll5VTdDZ1o4YXhuVWdLY2NuVlZXWnhmTnZJdzR1NEt3V1JaUEE9");
6+
var builder = WebAssemblyHostBuilder.CreateDefault(args);
7+
builder.RootComponents.Add<App>("#app");
8+
builder.RootComponents.Add<HeadOutlet>("head::after");
9+
builder.Services.AddSyncfusionBlazor(options => { options.IgnoreScriptIsolation = true; });
10+
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
11+
12+
await builder.Build().RunAsync();

Properties/launchSettings.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:46741",
7+
"sslPort": 44370
8+
}
9+
},
10+
"profiles": {
11+
"MyBlazorApp": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
16+
"applicationUrl": "https://localhost:7212;http://localhost:5212",
17+
"environmentVariables": {
18+
"ASPNETCORE_ENVIRONMENT": "Development"
19+
}
20+
},
21+
"IIS Express": {
22+
"commandName": "IISExpress",
23+
"launchBrowser": true,
24+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
29+
}
30+
}

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
# getting-started-with-blazor-barcode-and-qrcode-generator
2-
A quick-start project that shows how to add the Syncfusion Barcode and QR Code Generator components to a Blazor WebAssembly application. This project contains the code to generate different barcode types, QR code and data matrix, and how to customize the control like changing its dimensions, color, and font.
1+
# Getting Started with the Blazor Barcode and QR Code Generator
2+
3+
A quick-start project that shows how to add the Syncfusion Barcode and QR Code Generator components to a Blazor WebAssembly application. This project contains the code to generate different barcode types, QR code and data matrix, and how to customize the control like changing its dimensions, color, and font.
4+
5+
Documentation: https://blazor.syncfusion.com/documentation/barcode/getting-started
6+
7+
Online examples: https://blazor.syncfusion.com/demos/barcodes/default-functionalities
8+
9+
## Project prerequisites
10+
Make sure that you have the compatible versions of [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/ ) and [.NET Core SDK 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) or later version in your machine before starting to work on this project.
11+
12+
## How to run this application
13+
To run this application, you need to first clone the `getting-started-with-blazor-barcode-and-qrcode-generator` repository and then open it in Visual Studio 2019. Now, simply build and run your project to view the output.

Shared/MainLayout.razor

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<div class="sidebar">
5+
<NavMenu />
6+
</div>
7+
8+
<main>
9+
<div class="top-row px-4">
10+
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
11+
</div>
12+
13+
<article class="content px-4">
14+
@Body
15+
</article>
16+
</main>
17+
</div>

0 commit comments

Comments
 (0)