我正在创建一个条形码页面以适应onlinelabels.com (ol2050LP)。
我已经成功制作了条形码,并且还可以像我期望的那样在桌子上很好地展示它们。
我遇到的问题是,页面上有一些幻影页眉和页脚推送页面的最后两行条形码。
我的结果:
以下是我的方法:
public void CreatePDF(List<BarcodeLib.Barcode.DataMatrix> listOfBarcodes)
{
if (listOfBarcodes.Count >= 1)
{
Document document = new Document();
PdfPTable table = new PdfPTable(13);
document.SetPageSize(PageSize.A4);
document.SetMargins(0.25f, 0.25f, 0.2505f, 0.2505f);
try
{
PdfWriter.GetInstance(document, new FileStream(@"test.pdf", FileMode.CreateNew));
document.Open();
foreach (BarcodeLib.Barcode.DataMatrix image in listOfBarcodes)
{
iTextSharp.text.Image dmatrix = iTextSharp.text.Image.GetInstance(image.drawBarcodeAsBytes(), true);
dmatrix.SetDpi(300, 300);
dmatrix.ScaleAbsolute(37, 37);
table.AddCell(dmatrix);
}
document.Add(table);
document.Close();
}
catch (DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch (IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}
}
}