private static void SetHeader(Document document, PurchasingTextileDto purchasingTextile) { var table = new PdfPTable(1) { WidthPercentage = 100 }; var cell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE }; var rightCell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE }; var centeredCell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE }; cell.Phrase = new Phrase("PT. DANLIRIS", _headerFont); table.AddCell(cell); cell.Phrase = new Phrase("Kel. Banaran (Sel. Laweyan) Telp. 714400", _smallFont); table.AddCell(cell); cell.Phrase = new Phrase("PO. Box. 166 Solo-57100 Indonesia", _smallFont); table.AddCell(cell); centeredCell.Phrase = new Phrase("BUKTI MEMORIAL", _biggerFont); centeredCell.PaddingTop = 5; table.AddCell(centeredCell); rightCell.Phrase = new Phrase($"No. Memo: {purchasingTextile.MemoDetail.DocumentNo}", _smallFont); rightCell.PaddingBottom = 10; table.AddCell(rightCell); document.Add(table); }
public static MemoryStream Generate(PurchasingTextileDto purchasingTextile, string username, int timeoffset) { var document = new Document(PageSize.A4, 25, 25, 25, 25); var stream = new MemoryStream(); PdfWriter.GetInstance(document, stream); document.Open(); SetHeader(document, purchasingTextile); SetTable(document, purchasingTextile); SetFooter(document, purchasingTextile, timeoffset); document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public PurchasingTextileDto Read(int id) { var model = _dbContext.PurchasingMemoTextiles.FirstOrDefault(entity => entity.Id == id); if (model != null) { var items = _dbContext.PurchasingMemoTextileItems.Where(entity => entity.PurchasingMemoTextileId == id).ToList(); var result = new PurchasingTextileDto(model.Id, new AccountingBookDto(model.AccountingBookId, model.AccountingBookCode, model.AccountingBookType), new MemoDetailDto(model.MemoDetailId, model.MemoDetailDocumentNo, model.MemoDetailDate, new CurrencyDto(model.MemoDetailCurrencyId, model.MemoDetailCurrencyCode, model.MemoDetailCurrencyRate)), model.Remark, new List <FormItemDto>(), ""); foreach (var item in items) { result.Items.Add(new FormItemDto(new ChartOfAccountDto(item.ChartOfAccountId, item.ChartOfAccountCode, item.ChartOfAccountName), item.DebitAmount, item.CreditAmount)); } return(result); } else { return(null); } }
private static void SetFooter(Document document, PurchasingTextileDto purchasingTextile, int offSet) { PdfPTable table = new PdfPTable(3) { WidthPercentage = 100 }; table.SetWidths(new float[] { 1f, 1f, 1f }); PdfPCell cell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, }; PdfPCell cellColspan2 = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Colspan = 2 }; cellColspan2.Phrase = new Phrase($"Keterangan : {purchasingTextile.Remark}", _smallFont); cellColspan2.PaddingBottom = 10; table.AddCell(cellColspan2); cell.Phrase = new Phrase(); table.AddCell(cell); //cellColspan2.Phrase = new Phrase("Nomor Memo Pusat :", _smallFont); //table.AddCell(cellColspan2); //cell.Phrase = new Phrase(); //table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase("Mengetahui", _smallFont); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase($"Solo, {DateTime.UtcNow.AddHours(offSet).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", _smallFont); table.AddCell(cell); cell.Phrase = new Phrase("Kepala Pembukuan", _smallFont); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase("Yang Membuat", _smallFont); table.AddCell(cell); for (var i = 0; i < 4; i++) { cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); } cell.Phrase = new Phrase("(..................)", _smallFont); table.AddCell(cell); cell.Phrase = new Phrase(); table.AddCell(cell); cell.Phrase = new Phrase($"(..................)", _smallFont); table.AddCell(cell); document.Add(table); }
private static void SetTable(Document document, PurchasingTextileDto purchasingTextile) { var table = new PdfPTable(5) { WidthPercentage = 100 }; table.SetWidths(new float[] { 5f, 12f, 23f, 15f, 15f }); SetTableHeader(table); var cell = new PdfPCell() { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE }; var cellColspan3 = new PdfPCell() { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Colspan = 3 }; var cellAlignRight = new PdfPCell() { HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE }; var cellAlignLeft = new PdfPCell() { HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE }; double totalDebit = 0; double totalCredit = 0; int no = 1; foreach (var detail in purchasingTextile.Items) { cell.Phrase = new Phrase(no + "", _smallerFont); table.AddCell(cell); cell.Phrase = new Phrase(detail.ChartOfAccount.Code, _smallFont); table.AddCell(cell); cellAlignLeft.Phrase = new Phrase(detail.ChartOfAccount.Name, _smallFont); table.AddCell(cellAlignLeft); cellAlignRight.Phrase = new Phrase(detail.DebitAmount.ToString("#,##0.#0"), _smallFont); table.AddCell(cellAlignRight); cellAlignRight.Phrase = new Phrase(detail.CreditAmount.ToString("#,##0.#0"), _smallFont); table.AddCell(cellAlignRight); totalDebit += detail.DebitAmount; totalCredit += detail.CreditAmount; no++; } cellColspan3.Phrase = new Phrase("Jumlah Total", _smallBoldFont); table.AddCell(cellColspan3); cellAlignRight.Phrase = new Phrase(totalDebit.ToString("#,##0.#0"), _smallBoldFont); table.AddCell(cellAlignRight); cellAlignRight.Phrase = new Phrase(totalCredit.ToString("#,##0.#0"), _smallBoldFont); table.AddCell(cellAlignRight); document.Add(table); }