public IActionResult GetPackingListPDF(int id)
        {
            try
            {
                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");

                SPKDocs          model     = facade.ReadById(id);
                SPKDocsViewModel viewModel = mapper.Map <SPKDocsViewModel>(model);
                if (viewModel == null)
                {
                    throw new Exception("Invalid Id");
                }
                if (indexAcceptPdf < 0)
                {
                    return(Ok(new
                    {
                        apiVersion = ApiVersion,
                        statusCode = General.OK_STATUS_CODE,
                        message = General.OK_MESSAGE,
                        data = viewModel,
                    }));
                }
                else
                {
                    int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First());

                    //foreach (var item in viewModel.items)
                    //{
                    //    var garmentInvoice = invoiceFacade.ReadById((int)item.garmentInvoice.Id);
                    //    var garmentInvoiceViewModel = mapper.Map<GarmentInvoiceViewModel>(garmentInvoice);
                    //    item.garmentInvoice = garmentInvoiceViewModel;

                    //    foreach (var detail in item.details)
                    //    {
                    //        var deliveryOrder = deliveryOrderFacade.ReadById((int)detail.deliveryOrder.Id);
                    //        var deliveryOrderViewModel = mapper.Map<GarmentDeliveryOrderViewModel>(deliveryOrder);
                    //        detail.deliveryOrder = deliveryOrderViewModel;
                    //    }
                    //}

                    PackingListPdfTemplate PdfTemplateLocal = new PackingListPdfTemplate();
                    MemoryStream           stream           = PdfTemplateLocal.GeneratePdfTemplate(viewModel, serviceProvider, clientTimeZoneOffset);

                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = $"{viewModel.packingList}.pdf"
                    });
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public IActionResult Get(int id)
        {
            try
            {
                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");

                SPKDocs          model     = facade.ReadById(id);
                SPKDocsViewModel viewModel = mapper.Map <SPKDocsViewModel>(model);
                if (viewModel == null)
                {
                    throw new Exception("Invalid Id");
                }

                //if (indexAcceptPdf < 0)
                //{
                return(Ok(new
                {
                    apiVersion = ApiVersion,
                    statusCode = General.OK_STATUS_CODE,
                    message = General.OK_MESSAGE,
                    data = viewModel,
                }));
                // }
                //else
                //{
                //    int clientTimeZoneOffset = int.Parse(Request.Headers["x-timezone-offset"].First());

                //    PurchaseRequestPDFTemplate PdfTemplate = new PurchaseRequestPDFTemplate();
                //    MemoryStream stream = PdfTemplate.GeneratePdfTemplate(viewModel, clientTimeZoneOffset);

                //    return new FileStreamResult(stream, "application/pdf")
                //    {
                //        FileDownloadName = $"{viewModel.Code}.pdf"
                //    };
                //}
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public async Task <SPKDocsViewModel> MapToViewModel(List <SPKDocsCsvViewModel> csv, double source, string sourcec, string sourcen, double destination, string destinationc, string destinationn, DateTimeOffset date)
        {
            List <SPKDocsItemViewModel> sPKDocsItems = new List <SPKDocsItemViewModel>();

            //var itemx = GetItem();

            foreach (var i in csv)
            {
                var itemx = GetItem(i.code);
                if (itemx.Count() == 0 || itemx == null)
                {
                    //item = new ViewModels.NewIntegrationViewModel.ItemViewModel
                    //{
                    //articleRealizationOrder = i.articleRealizationOrder,
                    //_id = itemx.Id,
                    //code = i.code,
                    //domesticCOGS = Convert.ToDouble(i.domesticCOGS),
                    //domesticSale = Convert.ToDouble(i.domesticSale),
                    //name = i.name,
                    //size = i.size,
                    //uom = i.uom

                    //},
                    //quantity = Convert.ToDouble(i.quantity),
                    //remark = ""
                    //});
                    ItemCoreViewModel item = new ItemCoreViewModel
                    {
                        dataDestination = new List <ItemViewModelRead>
                        {
                            new ItemViewModelRead
                            {
                                ArticleRealizationOrder = i.articleRealizationOrder,
                                code = i.code,
                                name = i.name,
                                Size = i.size,
                                Uom  = i.uom,
                            }
                        },
                        DomesticCOGS      = Convert.ToDouble(i.domesticCOGS),
                        DomesticRetail    = 0,
                        DomesticSale      = Convert.ToDouble(i.domesticSale),
                        DomesticWholesale = 0,
                    };
                    string itemsUri   = "items/finished-goods";
                    var    httpClient = (IHttpClientService)serviceProvider.GetService(typeof(IHttpClientService));
                    var    response   = await httpClient.PostAsync($"{APIEndpoint.Core}{itemsUri}", new StringContent(JsonConvert.SerializeObject(item).ToString(), Encoding.UTF8, General.JsonMediaType));

                    response.EnsureSuccessStatusCode();

                    var item2 = GetItem(i.code);

                    sPKDocsItems.Add(new SPKDocsItemViewModel
                    {
                        item = new ViewModels.NewIntegrationViewModel.ItemViewModel
                        {
                            articleRealizationOrder = i.articleRealizationOrder,
                            _id          = item2.Single()._id,
                            code         = i.code,
                            domesticCOGS = Convert.ToDouble(i.domesticCOGS),
                            domesticSale = Convert.ToDouble(i.domesticSale),
                            name         = i.name,
                            size         = i.size,
                            uom          = i.uom
                        },
                        quantity     = Convert.ToDouble(i.quantity),
                        sendquantity = Convert.ToDouble(i.quantity),
                        remark       = ""
                    });
                }
                else
                {
                    sPKDocsItems.Add(new SPKDocsItemViewModel
                    {
                        item = new ViewModels.NewIntegrationViewModel.ItemViewModel
                        {
                            articleRealizationOrder = i.articleRealizationOrder,
                            _id          = itemx.Single()._id,
                            code         = i.code,
                            domesticCOGS = Convert.ToDouble(i.domesticCOGS),
                            domesticSale = Convert.ToDouble(i.domesticSale),
                            name         = i.name,
                            size         = i.size,
                            uom          = i.uom
                        },
                        quantity     = Convert.ToDouble(i.quantity),
                        sendquantity = Convert.ToDouble(i.quantity),
                        remark       = ""
                    });
                }
            }

            SPKDocsViewModel sPKDocsViews = new SPKDocsViewModel
            {
                code          = GenerateCode("EFR-PK/PBJ"),
                date          = date,
                packingList   = csv.FirstOrDefault().PackingList,
                password      = csv.FirstOrDefault().Password,
                reference     = csv.FirstOrDefault().PackingList,
                isDistributed = true,
                isReceived    = false,
                Weight        = 0,
                source        = new SourceViewModel
                {
                    _id  = (long)source,
                    code = sourcec,
                    name = sourcen
                },
                destination = new DestinationViewModel
                {
                    _id  = (long)destination,
                    code = destinationc,
                    name = destinationn
                },

                items = sPKDocsItems
            };

            return(sPKDocsViews);
        }
        public async Task <IActionResult> PostCSVFileAsync(double source, string sourcec, string sourcen, double destination, string destinationc, string destinationn, DateTimeOffset date)
        // public async Task<IActionResult> PostCSVFileAsync(double source, double destination,  DateTime date)
        {
            try
            {
                identityService.Username       = User.Claims.Single(p => p.Type.Equals("username")).Value;
                identityService.Token          = Request.Headers["Authorization"].FirstOrDefault().Replace("Bearer ", "");
                identityService.TimezoneOffset = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                if (Request.Form.Files.Count > 0)
                {
                    //VerifyUser();
                    var           UploadedFile = Request.Form.Files[0];
                    StreamReader  Reader       = new StreamReader(UploadedFile.OpenReadStream());
                    List <string> FileHeader   = new List <string>(Reader.ReadLine().Split(","));
                    var           ValidHeader  = facade.CsvHeader.SequenceEqual(FileHeader, StringComparer.OrdinalIgnoreCase);

                    if (ValidHeader)
                    {
                        Reader.DiscardBufferedData();
                        Reader.BaseStream.Seek(0, SeekOrigin.Begin);
                        Reader.BaseStream.Position = 0;
                        CsvReader Csv = new CsvReader(Reader);
                        Csv.Configuration.IgnoreQuotes = false;
                        Csv.Configuration.Delimiter    = ",";
                        Csv.Configuration.RegisterClassMap <PkbjMap>();
                        Csv.Configuration.HeaderValidated = null;

                        List <SPKDocsCsvViewModel> Data = Csv.GetRecords <SPKDocsCsvViewModel>().ToList();

                        SPKDocsViewModel Data1 = await facade.MapToViewModel(Data, source, sourcec, sourcen, destination, destinationc, destinationn, date);

                        Tuple <bool, List <object> > Validated = facade.UploadValidate(ref Data, Request.Form.ToList());

                        Reader.Close();

                        if (Validated.Item1) /* If Data Valid */
                        {
                            SPKDocs data = mapper.Map <SPKDocs>(Data1);
                            //foreach (var item in data)
                            //{
                            //    Transfrom(item);
                            //}
                            await facade.UploadData(data, identityService.Username);


                            Dictionary <string, object> Result =
                                new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE)
                                .Ok();
                            return(Created(HttpContext.Request.Path, Result));
                        }
                        else
                        {
                            using (MemoryStream memoryStream = new MemoryStream())
                            {
                                using (StreamWriter streamWriter = new StreamWriter(memoryStream))
                                    using (CsvWriter csvWriter = new CsvWriter(streamWriter))
                                    {
                                        csvWriter.WriteRecords(Validated.Item2);
                                    }

                                return(File(memoryStream.ToArray(), ContentType, FileName));
                            }
                        }
                    }
                    else
                    {
                        Dictionary <string, object> Result =
                            new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, General.CSV_ERROR_MESSAGE)
                            .Fail();

                        return(NotFound(Result));
                    }
                }
                else
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.NO_FILE_ERROR_MESSAGE)
                        .Fail();
                    return(BadRequest(Result));
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();

                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
        public MemoryStream GeneratePdfTemplate(SPKDocsViewModel viewModel, IServiceProvider serviceProvider, int clientTimeZoneOffset /*, IGarmentDeliveryOrderFacade DOfacad*/)
        {
            Font header_font  = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18);
            Font normal_font  = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 9);
            Font normal_font1 = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            Font bold_font    = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 20);
            Font bold_font1   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

            Document document = new Document(PageSize.A4, 40, 40, 40, 40);

            document.AddHeader("Header", viewModel.packingList);
            MemoryStream stream = new MemoryStream();
            PdfWriter    writer = PdfWriter.GetInstance(document, stream);

            writer.PageEvent = new PDFPages();
            document.Open();


            PdfPCell cellLeftNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellRightNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };

            Chunk        chkHeader = new Chunk(" ");
            Phrase       pheader   = new Phrase(chkHeader);
            HeaderFooter header    = new HeaderFooter(pheader, false);

            header.Border    = Rectangle.NO_BORDER;
            header.Alignment = Element.ALIGN_RIGHT;
            document.Header  = header;

            #region Header

            string    titleString = "BON PACKING LIST\n\n";
            Paragraph title       = new Paragraph(titleString, bold_font)
            {
                Alignment = Element.ALIGN_CENTER
            };
            document.Add(title);
            bold_font.SetStyle(Font.NORMAL);

            //string addressString = "PT DAN LIRIS" + "\n" + "JL. Merapi No.23" + "\n" + "Banaran, Grogol, Kab. Sukoharjo" + "\n" + "Jawa Tengah 57552 - INDONESIA" + "\n" + "PO.BOX 166 Solo 57100" + "\n" + "Telp. (0271) 740888, 714400" + "\n" + "Fax. (0271) 735222, 740777";
            //Paragraph address = new Paragraph(addressString, bold_font) { Alignment = Element.ALIGN_LEFT };
            //document.Add(address);
            //bold_font.SetStyle(Font.NORMAL);



            PdfPTable tableInternNoteHeader = new PdfPTable(2);
            tableInternNoteHeader.SetWidths(new float[] { 7.5f, 4.5f });
            PdfPCell cellInternNoteHeaderLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellInternNoteHeaderRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };

            cellInternNoteHeaderLeft.Phrase = new Phrase("PT. MAJOR MINOR KREASI NUSANTARA", bold_font1);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderLeft.Phrase = new Phrase("No. Packing List" + "       : " + viewModel.packingList, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Equity Tower 15th Floor Suite C, SCBD Lot 9, Jl. Jenderal Sudirman Kav 52-53 Jakarta 12190, Indonesia", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Password" + "                 : " + viewModel.password, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("Tanggal" + "                    : " + viewModel.CreatedUtc.ToString("dd MMMM yyyy", new CultureInfo("id-ID")) + "\n\n\n", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Dari" + "                           : " + viewModel.source.name, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Tujuan" + "                      : " + viewModel.destination.name, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Tanggal Kirim" + "           : " + viewModel.date.Value.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID")), normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Nomor Referensi" + "      : " + viewModel.reference, normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);

            cellInternNoteHeaderLeft.Phrase = new Phrase("", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderLeft);

            cellInternNoteHeaderRight.Phrase = new Phrase("Keterangan" + "      : " + "" + "\n\n", normal_font);
            tableInternNoteHeader.AddCell(cellInternNoteHeaderRight);



            PdfPCell cellInternNoteHeader = new PdfPCell(tableInternNoteHeader); // dont remove
            tableInternNoteHeader.ExtendLastRow = false;
            tableInternNoteHeader.SpacingAfter  = 10f;
            document.Add(tableInternNoteHeader);
            #endregion

            #region Table_Of_Content
            PdfPCell cellCenter = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            PdfPTable tableContent = new PdfPTable(5);
            tableContent.SetWidths(new float[] { 2f, 4f, 5f, 6.5f, 5.5f });
            cellCenter.Phrase = new Phrase("No", bold_font1);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Produk", bold_font1);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Nama Produk", bold_font1);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Kuantitas", bold_font1);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Harga", bold_font1);
            tableContent.AddCell(cellCenter);


            double totalPriceTotal = 0;
            double total           = 0;


            List <TableContent> TableContents = new List <TableContent>();
            int index = 1;
            foreach (SPKDocsItemViewModel item in viewModel.items)
            {
                TableContents.Add(new TableContent
                {
                    No          = index++,
                    Product     = item.item.code,
                    ProductName = item.item.name,
                    Quantity    = item.quantity,
                    Price       = String.Format("{0:n}", item.quantity * item.item.domesticSale)
                });

                totalPriceTotal += item.quantity * item.item.domesticSale;
                total           += item.quantity;
            }

            foreach (TableContent c in TableContents.OrderBy(o => o.No))
            {
                cellCenter.Phrase = new Phrase(c.No.ToString(), normal_font1);
                tableContent.AddCell(cellCenter);

                cellCenter.Phrase = new Phrase(c.Product, normal_font1);
                tableContent.AddCell(cellCenter);

                cellCenter.Phrase = new Phrase(c.ProductName, normal_font1);
                tableContent.AddCell(cellCenter);

                cellCenter.Phrase = new Phrase(c.Quantity.ToString(), normal_font1);
                tableContent.AddCell(cellCenter);

                cellCenter.Phrase = new Phrase(c.Price, normal_font1);
                tableContent.AddCell(cellCenter);
            }

            PdfPCell cellContent = new PdfPCell(tableContent); // dont remove
            tableContent.ExtendLastRow = false;
            tableContent.SpacingAfter  = 20f;
            document.Add(tableContent);
            #endregion
            #region Total
            PdfPTable tabletotal = new PdfPTable(3);
            tabletotal.SetWidths(new float[] { 11f, 6.5f, 5.5f });
            PdfPCell cellTotalContent = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };
            cellTotalContent.Phrase = new Phrase("Total", normal_font1);
            tabletotal.AddCell(cellTotalContent);
            cellTotalContent.Phrase = new Phrase("" + total, normal_font1);
            tabletotal.AddCell(cellTotalContent);
            cellTotalContent.Phrase = new Phrase("" + String.Format("{0:n}", totalPriceTotal), normal_font1);
            tabletotal.AddCell(cellTotalContent);
            PdfPCell cellTotal = new PdfPCell(tabletotal); // dont remove
            tabletotal.ExtendLastRow = false;
            tabletotal.SpacingBefore = 20f;
            tabletotal.SpacingAfter  = 20f;
            document.Add(tabletotal);
            #endregion
            //PdfPTable tableContent2 = new PdfPTable(3);
            //tableContent2.SetWidths(new float[] { 13f, 4.5f, 5.5f });
            //List<TableContent2> tableContents2 = new List<TableContent2>();
            //tableContents2.Add(new TableContent2
            //{
            //    Total = "Total",
            //    QtyTotal = total.ToString(),
            //    PriceTotal = String.Format("{0:n}", totalPriceTotal.ToString())
            //});
            //foreach (TableContent2 c in tableContents2)
            //{
            //    cellLeft.Phrase = new Phrase(c.Total, normal_font1);
            //    tableContent.AddCell(cellLeft);

            //    cellLeft.Phrase = new Phrase(c.QtyTotal, normal_font1);
            //    tableContent.AddCell(cellLeft);

            //    cellLeft.Phrase = new Phrase(c.PriceTotal, normal_font1);
            //    tableContent.AddCell(cellLeft);
            //}
            //PdfPCell cellContent2 = new PdfPCell(tableContent2); // dont remove
            //tableContent.ExtendLastRow = false;
            //tableContent.SpacingAfter = 20f;
            //document.Add(tableContent);

            //#region Footer

            //PdfPTable tableFooter = new PdfPTable(2);
            //tableFooter.SetWidths(new float[] { 1f, 1f });

            //PdfPTable tableFooterLeft = new PdfPTable(2);
            //tableFooterLeft.SetWidths(new float[] { 3f, 5f });

            //PdfPCell cellInternNoteFooterLeft = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT };
            //PdfPCell cellInternNoteFooterRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT };
            ////foreach (var unit in units)
            ////{
            ////    if (unit.Value == 0)
            ////    {

            ////        cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font);
            ////        tableFooterLeft.AddCell(cellLeftNoBorder);
            ////        cellLeftNoBorder.Phrase = new Phrase($":   -", normal_font);
            ////        tableFooterLeft.AddCell(cellLeftNoBorder);
            ////    }
            ////    else
            ////    {
            ////        cellLeftNoBorder.Phrase = new Phrase($"Total {unit.Key}", normal_font);
            ////        tableFooterLeft.AddCell(cellLeftNoBorder);
            ////        cellLeftNoBorder.Phrase = new Phrase($":   {unit.Value.ToString("n", new CultureInfo("id-ID"))}", normal_font);
            ////        tableFooterLeft.AddCell(cellLeftNoBorder);
            ////    }
            ////}

            //PdfPTable tableFooterRight = new PdfPTable(2);
            //tableFooterRight.SetWidths(new float[] { 5f, 5f });

            ////cellLeftNoBorder.Phrase = new Phrase($"Total Harga Pokok (DPP)", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + totalPriceTotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase("Mata Uang", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + viewModel.currency.Code, normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase("Total Harga Pokok (Rp)", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + total.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase("Total Nota Koreksi", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////if (correctionNote != null)
            ////{
            ////    cellLeftNoBorder.Phrase = new Phrase($": " + totalcorrection.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////    tableFooterRight.AddCell(cellLeftNoBorder);
            ////}
            ////else
            ////{
            ////    cellLeftNoBorder.Phrase = new Phrase($": " + 0, normal_font);
            ////    tableFooterRight.AddCell(cellLeftNoBorder);
            ////}

            ////cellLeftNoBorder.Phrase = new Phrase("Total Nota PPn", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + ppn.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase("Total Nota PPh", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + pph.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase("Total yang Harus Dibayar", normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            ////cellLeftNoBorder.Phrase = new Phrase($": " + maxtotal.ToString("N", new CultureInfo("id-ID")), normal_font);
            ////tableFooterRight.AddCell(cellLeftNoBorder);

            //PdfPCell cellFooterLeft = new PdfPCell(tableFooterLeft) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER };
            //tableFooter.AddCell(cellFooterLeft);
            //PdfPCell cellFooterRight = new PdfPCell(tableFooterRight) { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER };
            //tableFooter.AddCell(cellFooterRight);


            //PdfPCell cellFooter = new PdfPCell(tableFooter); // dont remove
            //tableFooter.ExtendLastRow = false;
            //tableFooter.SpacingAfter = 20f;
            //document.Add(tableFooter);

            //#endregion

            #region TableSignature

            PdfPTable tableSignature = new PdfPTable(3);

            PdfPCell cellSignatureContent = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellSignatureContent.Phrase = new Phrase("", bold_font1);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("", bold_font1);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Yang Membuat\n\n\n\n\n\n\n(________________________________)", bold_font1);
            tableSignature.AddCell(cellSignatureContent);


            PdfPCell cellSignature = new PdfPCell(tableSignature); // dont remove
            tableSignature.ExtendLastRow = false;
            tableSignature.SpacingBefore = 20f;
            tableSignature.SpacingAfter  = 20f;
            document.Add(tableSignature);

            #endregion

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }