BstLabelPrinter 9.5.1
How to use
Import the folder "label-designer" present in ContentFiles to your vendors folder
Extra fields example
public class PrintingJobFields : PrintingJobExtraFields {
[MaxLength(500)][PrintingJobValue("Categoria")] public string Category { get; set; }
[MaxLength(500)][PrintingJobValue("Variedade")] public string Variety { get; set; }
[MaxLength(500)][PrintingJobValue("Marca")] public string Brand { get; set; }
[MaxLength(500)][PrintingJobValue("Entreposto")] public string Store { get; set; }
}
Add automapper
services.AddAutoMapper(typeof(Program), typeof(BstLabelPrinter.LabelPrinter));
Add services
services.AddLabelPrinterServices<PrintingJobFields>();
DbContext
protected override void OnModelCreating(ModelBuilder builder) {
builder.ConfigureLabelPrinter(typeof(PrintingJobFields));
}
Controller example
[HttpGet]
public IActionResult Index() {
ViewBag.Model = dbContext.Set<LabelTemplate>().AsQueryable();
return View("../Labels/LabelDesigner/Index");
}
[HttpGet]
public IActionResult Create() {
return View("../Labels/LabelDesigner/Form");
}
[HttpGet("{id:int}")]
public async Task<IActionResult> Edit(int id) {
var model = await dbContext.Set<LabelTemplate>().FirstOrDefaultAsync(l => l.Id == id);
if (model == null) return NotFound();
return View("../Labels/LabelDesigner/Form", labelDesignerService.GetDto(model));
}
[HttpPost]
[ApiAction]
public async Task<IActionResult> Save(LabelTemplateDto dto) {
var returnValue = await labelDesignerService.SaveDto(dbContext, dto);
if (!returnValue.success) return BadRequest(returnValue.error);
if (dto.Id == null) return Ok(Url.Action(nameof(Edit), new { returnValue.id }));
return Ok("Template alterado com sucesso");
}
[HttpPost]
[ApiAction]
public async Task<IActionResult> Print(int id, string printerName) {
var template = await dbContext.Set<LabelTemplate>().FirstOrDefaultAsync(l => l.Id == id);
var printingJob = labelPrinterService.GetExamplePrintingJob(printerName, template);
printingJob.PrintingJobExtraFields = new PrintingJobFields() {
Brand = "Marca",
Category = "Categoria",
Store = "Loja",
Variety = "Variedade",
};
labelPrinterService.Print(template, printingJob);
return Ok();
}
[HttpGet("{id:int}")]
public async Task<IActionResult> Duplicate(int id) {
var model = await dbContext.Set<LabelTemplate>().FirstOrDefaultAsync(a => a.Id == id);
if (model == null) return NotFound();
var duplicated = labelDesignerService.CloneTemplate(model);
duplicated.Name = $"{model.Name} - C�pia";
dbContext.Set<LabelTemplate>().Add(duplicated);
flashMessage.Success("Etiqueta duplicada com sucesso");
await dbContext.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
[HttpPost("{id:int}")]
public async Task<IActionResult> Delete(int id) {
var model = await dbContext.Set<LabelTemplate>().FirstOrDefaultAsync(a => a.Id == id);
if (model == null) return NotFound();
dbContext.Set<LabelTemplate>().Remove(model);
flashMessage.Success("Etiqueta apagada com sucesso");
dbContext.Set<LabelTemplate>().Remove(model);
await dbContext.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
View Index example
@(Html
.Grid(templates)
.Build(columns =>
{
columns.Add(m => m.Name).Titled("Nome");
columns.AddActions(m => m.AddEdit()
.AddShow("Duplicate", text: "Duplicar", icon: "content_copy").AddDelete());
})
.Pageable()
.Empty()
)
View Form example
@section Style {
<link rel="stylesheet" type="text/css" href="~/vendors/label-designer/css/label-designer.css" asp-append-version="true" />
}
<div class="card">
<div class="card-header">Desenho de etiqueta</div>
<div class="card-body pb-3">
<div>
<div id="LabelDesigner"></div>
</div>
</div>
</div>
@section Scripts {
<script src="~/vendors/label-designer/js/label-designer.min.js" asp-append-version="true"></script>
<script type="text/javascript">
$(function () {
labelDesigner({
id: @(Model?.Id?.ToString(CultureInfo.InvariantCulture) ?? "null"),
cancelUrl: "@Url.Action(nameof(LabelDesignerController.Index), typeof(LabelDesignerController).GetControllerName())",
printers: @Html.Raw(JsonConvert.SerializeObject(PrintersRepository.GetPrinters())),
width: @(Model?.Width.ToString(CultureInfo.InvariantCulture) ?? "null"),
height: @(Model?.Height.ToString(CultureInfo.InvariantCulture) ?? "null"),
name: "@(Html.Raw(Model?.Name))",
containerId: "LabelDesigner",
textPlaceholders: @(Html.Raw(JsonConvert.SerializeObject(LabelPrinterService.GetPlaceholders().Select(s => new { name = s.description, value = s.placeholder }).OrderBy(s => s.name)))),
code128Placeholders: @(Html.Raw(JsonConvert.SerializeObject(LabelPrinterService.GetCode128Placeholders().Select(s => new { name = s.description, value = s.propertyName, ai = s.ai }).OrderBy(s => s.name)))),
data: @Html.Raw(JsonConvert.SerializeObject(Model, new JsonSerializerSettings {
ContractResolver = new CamelCasePropertyNamesContractResolver()
}
)),
beginCreate: function(){
showLoader();
},
beginEdit: function(){
showLoader();
},
saveUrl: "@Url.Action(nameof(LabelDesignerController.Save), typeof(LabelDesignerController).GetControllerName())",
printUrl: "@Url.Action(nameof(LabelDesignerController.Print), typeof(LabelDesignerController).GetControllerName())",
createSuccess: function(data){
location.href = data;
hideLoader();
},
createError: function(xhr){
showMessage("Ocorreu um erro ao gravar", -1);
hideLoader();
},
editSuccess: function(data){
showMessage(data, 1);
hideLoader();
},
editError: function(xhr){
showMessage("Ocorreu um erro ao gravar", -1);
hideLoader();
},
});
});
</script>
}
No packages depend on BstLabelPrinter.
.NET 9.0
- AutoMapper (>= 14.0.0)
- BstBarCodes (>= 9.3.2)
- BstLogger (>= 9.1.0)
- Microsoft.EntityFrameworkCore (>= 9.0.5)
- Microsoft.EntityFrameworkCore.Abstractions (>= 9.0.5)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.5)
- Newtonsoft.Json (>= 13.0.3)
- System.Drawing.Common (>= 9.0.5)
| Version | Downloads | Last updated |
|---|---|---|
| 10.0.1 | 2 | 11/11/2025 |
| 9.5.8 | 1 | 20/10/2025 |
| 9.5.7 | 1 | 20/10/2025 |
| 9.5.6 | 3 | 15/10/2025 |
| 9.5.5 | 3 | 24/09/2025 |
| 9.5.4 | 4 | 06/09/2025 |
| 9.5.3 | 6 | 15/07/2025 |
| 9.5.2 | 6 | 12/06/2025 |
| 9.5.1 | 11 | 21/05/2025 |
| 9.5.0 | 8 | 21/05/2025 |
| 9.4.9 | 9 | 20/05/2025 |
| 9.4.8 | 9 | 15/05/2025 |
| 9.4.7 | 10 | 14/05/2025 |
| 9.4.6 | 10 | 07/05/2025 |
| 9.4.4 | 9 | 07/05/2025 |
| 9.4.3 | 9 | 07/05/2025 |
| 9.4.2 | 8 | 06/05/2025 |
| 9.4.1 | 10 | 10/04/2025 |
| 9.4.0 | 10 | 05/04/2025 |
| 9.3.9 | 10 | 04/04/2025 |
| 9.3.8 | 8 | 03/04/2025 |
| 9.3.7 | 8 | 03/04/2025 |
| 9.3.6 | 7 | 02/04/2025 |
| 9.3.5 | 8 | 28/03/2025 |
| 9.3.4 | 9 | 20/03/2025 |
| 9.3.3 | 6 | 19/03/2025 |
| 9.3.2 | 8 | 19/03/2025 |
| 9.3.1 | 12 | 17/02/2025 |
| 9.3.0 | 9 | 17/02/2025 |
| 9.0.1 | 8 | 17/02/2025 |