SfeRepGrafica.Core
2.1.0
dotnet add package SfeRepGrafica.Core --version 2.1.0
NuGet\Install-Package SfeRepGrafica.Core -Version 2.1.0
<PackageReference Include="SfeRepGrafica.Core" Version="2.1.0" />
<PackageVersion Include="SfeRepGrafica.Core" Version="2.1.0" />
<PackageReference Include="SfeRepGrafica.Core" />
paket add SfeRepGrafica.Core --version 2.1.0
#r "nuget: SfeRepGrafica.Core, 2.1.0"
#:package SfeRepGrafica.Core@2.1.0
#addin nuget:?package=SfeRepGrafica.Core&version=2.1.0
#tool nuget:?package=SfeRepGrafica.Core&version=2.1.0
SfeRepGrafica
Libreria .NET para la generacion de representaciones graficas (PDF) de facturas electronicas bajo la normativa del Sistema de Facturacion Electronica (SFE) de Bolivia.
Descripcion
SfeRepGrafica genera documentos PDF a partir de datos de facturacion, soportando multiples tipos de documentos fiscales definidos por el SIN (Servicio de Impuestos Nacionales). La libreria implementa el patron Strategy para generar dos formatos de factura:
- Ejecutiva (Carta): Factura en formato carta estandar (Letter) con cabecera, datos del cliente, detalle de productos, totales, leyendas y codigo QR.
- POS (Rollo): Factura en formato rollo/ticket para impresoras termicas POS.
Estructura del Proyecto
SfeRepGraficaSolution.sln
├── SfeRepGrafica.Core/ # Libreria principal (NuGet package)
│ ├── Engine/ # FacturaCreator, DTO, enums
│ ├── Enum/ # TipoDocumentoSectorEnum (53 tipos de documento)
│ ├── Helpers/ # FacturaFonts, ITextShapHelper, ImageManager, QR
│ ├── Impresion/ # IImpresionFactura, FacturaEjecutiva, FacturaPos
│ └── Value/ # Configuracion por tipo de documento fiscal
├── SfeRepGrafica.Client/ # Cliente de prueba (consola)
├── SfeRepGrafica.Api.Test/ # API de prueba
└── SfeRepGrafica.Test/ # Tests unitarios (MSTest)
Requisitos
- .NET 10.0 SDK
- Visual Studio 2022+ o VS Code
Instalacion
Como paquete NuGet
El proyecto SfeRepGrafica.Core genera un paquete NuGet al compilar:
dotnet build SfeRepGrafica.Core/SfeRepGrafica.Core.csproj -c Release
El paquete se genera en SfeRepGrafica.Core/bin/Release/SfeRepGrafica.Core.2.1.0.nupkg.
Referencia directa al proyecto
<ProjectReference Include="path/to/SfeRepGrafica.Core/SfeRepGrafica.Core.csproj" />
Uso
using SfeRepGrafica.Core.Engine;
using SfeRepGrafica.Core.Enum;
// Crear el generador
var facturaGenerador = new FacturaCreator();
// Preparar los datos de la factura
var datos = new FacturaRepGrafDto
{
NombreEmpresa = "Mi Empresa S.R.L.",
DatosSucursal = "Casa Matriz",
DatosDetalleSucursal = "Av. Principal #123",
TipoDocumentoSector = TipoDocumentoSectorEnum.FacturaCompraVenta,
NitEmisor = "1234567890",
Autorizacion = "27141900292138",
NroFactura = 1001,
NombreCliente = "Juan Perez",
NitCliente = "9876543",
Leyenda = "Ley N 453: Puedes presentar tu reclamo...",
LeyendaTipoNegocio = "CONTRIBUYENTE REGIMEN GENERAL",
FechaEmision = DateTime.Now,
Qr = "https://sfe.impuestos.gob.bo/...",
// ... demas campos
};
// Generar PDF formato Ejecutiva (Carta)
byte[] pdfCarta = facturaGenerador.GenerarRepresentacionGrafica(
EnumFacturaTipo.EJECUTIVA, datos);
// Generar PDF formato POS (Rollo/Ticket)
byte[] pdfPos = facturaGenerador.GenerarRepresentacionGrafica(
EnumFacturaTipo.POS, datos);
// Guardar el PDF
File.WriteAllBytes("factura.pdf", pdfCarta);
Merge de multiples PDFs
using SfeRepGrafica.Core.Helpers;
var pdfs = new List<byte[]> { pdf1, pdf2, pdf3 };
byte[] merged = ITextShapHelper.MergePDFs(pdfs);
Generar codigo QR
byte[] qrPng = ITextShapHelper.GenerarQr("datos-para-el-qr");
Tipos de Documento Soportados
La libreria soporta los 49 tipos de documentos fiscales definidos en TipoDocumentoSectorEnum (codigos 1-53 con saltos), incluyendo:
| Codigo | Tipo | Descripcion |
|---|---|---|
| 1 | FacturaCompraVenta |
Factura estandar de compra-venta |
| 2 | FacturaAlquilerBienInmueble |
Factura de alquiler de bien inmueble |
| 3 | FacturaComercialExportacion |
Factura comercial de exportacion |
| 4 | FacturaLibreConsignacion |
Factura de exportacion en libre consignacion |
| 5 | FacturaZonaFranca |
Factura de venta de zona franca |
| 6 | FacturaServicioTuristicoHospedaje |
Factura de servicio turistico y hospedaje |
| 7 | FacturaSeguridadAlimentaria |
Factura de seguridad alimentaria |
| 8 | FacturaTasaCero |
Factura tasa cero - transporte carga internacional |
| 9 | FacturaMonedaExtranjera |
Factura de compra y venta de moneda extranjera |
| 10 | FacturaDuttyFree |
Factura Dutty Free |
| 11 | FacturaSectorEducativo |
Factura sector educativo |
| 12 | FacturaComercializacionHidrocarburo |
Factura de comercializacion de hidrocarburos |
| 13 | FacturaServicioBasico |
Factura de servicios basicos |
| 14 | FacturaAlcanzadaIce |
Factura con Impuesto al Consumo Especifico |
| 15 | FacturaEntidadFinanciera |
Factura de entidad financiera |
| 16 | FacturaHotel |
Factura de hotel |
| 17 | FacturaHospitalClinica |
Factura de hospital/clinica |
| 18 | FacturaJuegoAzar |
Factura de juego de azar |
| 19 | FacturaHidrocarburo |
Factura de hidrocarburo |
| 20 | FacturaComercialExportacionMinera |
Factura comercial de exportacion minera |
| 21 | FacturaVentaMineral |
Factura de venta de minerales |
| 22 | FacturaTelecomunicacion |
Factura de telecomunicaciones |
| 23 | FacturaPrevalorada |
Factura prevalorada |
| 24 | NotaCreditoDebito |
Nota de credito/debito |
| 28 | FacturaComercialExportacionServicio |
Factura comercial de exportacion de servicios |
| 29 | NotaConciliacion |
Nota de conciliacion |
| 30 | FacturaBoletoAereo |
Boleto aereo |
| 31 | FacturaSuministroEnergia |
Factura de suministro de energia electrica |
| 32 | FacturaIceZonaFranca |
Factura ICE zona franca |
| 34 | FacturaSeguros |
Factura de seguros |
| 35 | FacturaCompraVentaBon |
Factura de compra-venta con bonificacion |
| 36 | FacturaPrevaloradaSD |
Factura prevalorada sin derecho |
| 37 | FacturaComercializacionGnv |
Factura de comercializacion de GNV |
| 38 | FacturaHidrocarburoNoAlcanzadaIehd |
Factura hidrocarburo no alcanzada IEHD |
| 39 | FacturaComercializacionGnGlp |
Factura de comercializacion de GN/GLP |
| 40 | FacturaServicioBasicoZf |
Factura de servicios basicos zona franca |
| 41 | FacturaCompraVentaTasas |
Factura de compra-venta con tasas |
| 42 | FacturaAlquilerZF |
Factura de alquiler zona franca |
| 43 | FacturaComercialExportacionHidro |
Factura comercial de exportacion de hidrocarburos |
| 44 | FacturaImportacionComercializacionLubricantes |
Factura de importacion y comercializacion de lubricantes |
| 45 | FacturaComercialExportacionPVenta |
Factura comercial de exportacion punto de venta |
| 46 | FacturaSectorEducativoZF |
Factura sector educativo zona franca |
| 47 | NotaCreditoDebitoDescuento |
Nota de credito/debito con descuento |
| 48 | NotaCreditoDebitoIce |
Nota de credito/debito ICE |
| 49 | FacturaTelecomunicacionZF |
Factura de telecomunicaciones zona franca |
| 50 | FacturaHospitalClinicaZF |
Factura hospital/clinica zona franca |
| 51 | FacturaEngarrafadoras |
Factura de engarrafadoras |
| 52 | FacturaVentaMineralBCB |
Factura de venta de minerales y metales BCB |
| 53 | FacturaImportacionComercializacionLubricantesIEHD |
Factura de importacion y comercializacion de lubricantes IEHD |
Cada tipo de documento tiene su propia configuracion de detalle (columnas, campos, formato) definida en ConfigRepGraficaDetalleValue.
Dependencias
| Paquete | Version | Uso |
|---|---|---|
| iTextSharp | 5.5.13.5 | Generacion de PDF |
| PDFsharp | 6.2.3 | Merge de multiples PDFs |
| QRCoder | 1.7.0 | Generacion de codigos QR |
| System.Text.Encoding.CodePages | 9.0.0 | Soporte de codificaciones |
Build y Tests
# Compilar la solucion
dotnet build SfeRepGraficaSolution.sln
# Ejecutar tests
dotnet test SfeRepGrafica.Test/SfeRepGrafica.Test.csproj
Autor
Deyvi Josue Ortiz Vidaurre
Configuraciones de Detalle por Tipo
Cada tipo de documento se mapea a una de 9 configuraciones de detalle en ConfigRepGraficaDetalleValue:
| Configuracion | Tipos que la usan |
|---|---|
ConfigFacturaNormal |
CompraVenta, Alquiler, ZonaFranca, Educativo, Telecomunicacion, Hotel, Hospital, Seguros, Hidrocarburos, BoletoAereo, y 20+ mas |
ConfigFacturaComercialExportacion |
ComercialExportacion, ComercialExportacionMinera, ComercialExportacionHidro, ComercialExportacionPVenta |
ConfigFacturaExportacionLibreConsignacion |
LibreConsignacion |
ConfigFacturaMonedaExtranjera |
MonedaExtranjera |
ConfigFacturaAlcanzadaICE |
AlcanzadaIce, IceZonaFranca |
ConfigFacturaSuministroEnergia |
SuministroEnergia |
ConfigNotaCreditoDebito |
NotaCreditoDebito, NotaCreditoDebitoDescuento |
ConfigNotaCreditoDebitoICE |
NotaCreditoDebitoIce |
ConfigNotaConciliacion |
NotaConciliacion |
Version
2.1.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- iTextSharp (>= 5.5.13.5)
- PDFsharp (>= 6.2.3)
- QRCoder (>= 1.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.