I am creating a Pdf with a barcode in the header...
private void BuildHeader(RepeatingAreaBuilder builder)
{
var tableBuilder = builder.AddTable();
tableBuilder
.SetWidth(XUnit.FromPercent(100))
.SetBorder(Stroke.None)
.AddColumnPercentToTable("", 30)
.AddColumnPercentToTable("", 50)
.AddColumnToTable("", 20);
var rowBuilder = tableBuilder.AddRow();
var cellBuilder = rowBuilder.AddCell()
.SetVerticalAlignment(VerticalAlignment.Center)
.SetPadding(17, 0, 0, 0);
cellBuilder.AddParagraph("APP/PipeKing").SetFont(FNT20B);
cellBuilder = rowBuilder.AddCell();
cellBuilder.AddParagraph(_mixer.MixPlantName + " Mixing Sheet").SetFont(FNT20B);
cellBuilder = rowBuilder.AddCell();
cellBuilder.AddParagraph()
.AddBarcodeToParagraph("12345678", BarcodeType.EAN_8);
}
this fails at
**cellBuilder.AddParagraph()
.AddBarcodeToParagraph("12345678", BarcodeType.EAN_8);**
with the following error message:
Gehtsoft.PDFFlow.Models.Exceptions.NotEnoughSpaceException: 'The inline image is larger than the available space on the page. Width: 81, Height: 65.75'
How do I get the barcode to display?
I have tried numerous .FromHeight
and .FromWidth
scenarios to no avail.
I have found the answer:
byte[] _barcode;
_barcode = BarcodesMaker.GetBarcode("01234501",
BarcodeType.EAN_8,
System.Drawing.Color.Black,
System.Drawing.Color.White,
true,
MeasureBarcodeUnit.FromPixel(0));
cellBuilder = rowBuilder.AddCell();
cellBuilder.AddImage(_barcode, 100f, 50, ScalingMode.None);