я хочу создать несколько страниц против одного элемента, помогите мне - PullRequest
0 голосов
/ 30 мая 2019

Я хочу создать несколько штрих-кодовых страниц для одного элемента, например, элемент имеет 3 цвета, это означает, что автоматически создаются три страницы, если элемент имеет 3 цвета и размер 3, а его страницы создаются таким образом.

Я искал его больше3 дня, но не могу найти решения

private byte[] GenerateItemBarCodePDF(int ItemId, int ItemDetailID, int ColorID)
{
    dsrptInventory ds = new dsrptInventory();
    ds.EnforceConstraints = false;
    dsrptInventoryTableAdapters.vItemBarcodeTableAdapter _taItemBarCode = new dsrptInventoryTableAdapters.vItemBarcodeTableAdapter();
    _taItemBarCode.Fill(ds.vItemBarcode, ItemId,ItemDetailID,ColorID);
    if (ds.vItemBarcode.Count > 0)
    {
        using (MemoryStream output = new MemoryStream())
        {
                var item = ds.vItemBarcode[0];

                iTextSharp.text.Rectangle small = new iTextSharp.text.Rectangle(144f, 72f);
                iTextSharp.text.Font smallfont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8);
                Document document = new Document(small, 15, 15, 10, 0);
                PdfWriter writer = PdfWriter.GetInstance(document, output);
                document.Open();

                PdfPTable table = new PdfPTable(1);
                table.WidthPercentage = 110;
                table. DefaultCell. Border = iTextSharp. text. Rectangle .NO_BORDER;
                PdfContentByte cb = writer.DirectContent;
                Barcode128 code128 = new Barcode128();
                code128.CodeType = iTextSharp.text.pdf.Barcode.CODE128;
                code128.ChecksumText = true;
                code128.GenerateChecksum = true;
                code128.StartStopText = true;
                code128.Font = null;
                code128.Code = item.ItemCode;
                code128.BarHeight = 18;
                table.AddCell(barCodeCell);
                PdfPCell itemNameCell = new PdfPCell(new Phrase(item.ItemName, smallfont));
                itemNameCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                itemNameCell.VerticalAlignment = Element.ALIGN_CENTER;
                itemNameCell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(itemNameCell);
                PdfPCell itemCodeCell = new PdfPCell(new Phrase(item.ItemCode, smallfont));
                itemCodeCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                itemCodeCell.VerticalAlignment = Element.ALIGN_CENTER;
                itemCodeCell.HorizontalAlignment = Element.ALIGN_CENTER;
                itemCodeCell.UseAscender = true;
                table.AddCell(itemCodeCell);
                document.Add(table);
                    document.Close();
            return output.ToArray();
        }
    }
    return null;
}
...