示例#1
0
        private Log GerarMarcadAgua(HttpRequest httpRequest, string nomeArquivo)
        {
            NomeArquivo   = nomeArquivo;
            Transparencia = double.Parse(httpRequest.Params["transparencia"]);
            Texto         = httpRequest.Params["texto"];
            XFolhaEmPe    = int.Parse(httpRequest.Params["xfolhaEmPe"]);
            XFolhaDeitada = int.Parse(httpRequest.Params["xfolhaDeitada"]);
            YFolhaEmPe    = int.Parse(httpRequest.Params["yfolhaEmPe"]);
            YFolhaDeitada = int.Parse(httpRequest.Params["yfolhaDeitada"]);
            Angulo        = int.Parse(httpRequest.Params["angulo"]);
            Tamanho       = int.Parse(httpRequest.Params["tamanho"]);
            Cor           = httpRequest.Params["cor"];
            Fonte         = httpRequest.Params["fonte"];

            int contadorDePaginas = 0;

            // Cria instancia de PDF manager.
            PdfManager objPDF = new PdfManager();

            // Chave licença
            objPDF.RegKey = ConfigurationManager.AppSettings["chavePdf"];

            //Abre PDF
            PdfDocument objDoc = objPDF.OpenDocument(HttpContext.Current.Server.MapPath("/Arquivos/" + nomeArquivo));

            foreach (PdfPage page in objDoc.Pages)
            {
                contadorDePaginas++;

                var GState = objDoc.CreateGState("BlendMode=1; Alpha=" + Transparencia.ToString().Replace(',', '.') + "; FillAlpha=" + Transparencia.ToString().Replace(',', '.'));
                page.Canvas.SetGState(GState);

                if (page.Rotate.Equals(0) || page.Rotate.Equals(180))
                {
                    page.Canvas.DrawText(Texto, "x=" + XFolhaEmPe + "; y=" + YFolhaEmPe + "; angle=" + Angulo + "; size=" + Tamanho + "; color=&" + Cor, objDoc.Fonts[Fonte]);
                }
                else
                {
                    page.Canvas.DrawText(Texto, "x=" + XFolhaDeitada + "; y=" + YFolhaDeitada + "; angle=" + Angulo + "; size=" + Tamanho + "; color=&" + Cor, objDoc.Fonts[Fonte]);
                }
            }

            objDoc.Save(HttpContext.Current.Server.MapPath("/Arquivos/marcadAgua/" + nomeArquivo));
            objDoc.Close();

            Log log = new Log();

            log.NomeArquivo       = nomeArquivo;
            log.QuatindadePaginas = contadorDePaginas;
            log.TipoAlteracao     = 1;

            return(log);
        }
示例#2
0
        private Log GeraQrCode(HttpRequest httpRequest, string nomeArquivo)
        {
            NomeArquivo   = nomeArquivo;
            Link          = httpRequest.Params["link"];
            XFolhaEmPe    = int.Parse(httpRequest.Params["xfolhaEmPe"]);
            XFolhaDeitada = int.Parse(httpRequest.Params["xfolhaDeitada"]);
            YFolhaEmPe    = int.Parse(httpRequest.Params["yfolhaEmPe"]);
            YFolhaDeitada = int.Parse(httpRequest.Params["yfolhaDeitada"]);
            Tamanho       = int.Parse(httpRequest.Params["tamanho"]);

            int contadorDePaginas = 0;

            // Cria instancia de PDF manager.
            PdfManager objPDF = new PdfManager();

            // Chave licença
            objPDF.RegKey = ConfigurationManager.AppSettings["chavePdf"];

            //Abre PDF
            PdfDocument objDoc = objPDF.OpenDocument(HttpContext.Current.Server.MapPath("/Arquivos/" + nomeArquivo));

            foreach (PdfPage page in objDoc.Pages)
            {
                contadorDePaginas++;

                if (page.Rotate.Equals(0) || page.Rotate.Equals(180))
                {
                    page.Canvas.DrawBarcode2D(Link, "Type=3; X=" + XFolhaEmPe + "; Y=" + YFolhaEmPe + "; Version=" + Tamanho);
                }
                else
                {
                    page.Canvas.DrawBarcode2D(Link, "Type=3; X=" + XFolhaDeitada + "; Y=" + YFolhaDeitada + "; Version=" + Tamanho);
                }
            }

            objDoc.Save(HttpContext.Current.Server.MapPath("/Arquivos/qrCode/" + nomeArquivo));
            objDoc.Close();

            Log log = new Log();

            log.NomeArquivo       = nomeArquivo;
            log.QuatindadePaginas = contadorDePaginas;
            log.TipoAlteracao     = 2;

            return(log);
        }
示例#3
0
 private static void CreateImageFromPdf(string sourcePath, string destinationPath)
 {
     try
     {
         var pdfManagerObj = new PdfManager();
         var objPdfDoc     = pdfManagerObj.OpenDocument(sourcePath, Missing.Value);
         var objParam      = pdfManagerObj.CreateParam(Missing.Value);
         objParam["ResolutionX"].Value = 36;
         objParam["ResolutionY"].Value = 36;
         objParam["ScaleX"].Value      = 0.1f;
         objParam["ScaleY"].Value      = 0.1f;
         var objFrontPage    = objPdfDoc.Pages[1];
         var objFrontPreview = objFrontPage.ToImage(objParam);
         objFrontPreview.Save(String.Format(destinationPath, "front"), true);
         var objBackPage    = objPdfDoc.Pages[2];
         var objBackPreview = objBackPage.ToImage(objParam);
         objBackPreview.Save(String.Format(destinationPath, "back"), true);
         objPdfDoc.Close();
     }
     catch (Exception exception)
     {
     }
 }
示例#4
0
    protected void UploadButton_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            try
            {
                if (ddlSection.SelectedIndex != -1)
                {
                    DulyDBDataContext dc = new DulyDBDataContext();

                    //get the extension
                    string extension = System.IO.Path.GetExtension(FileUpload1.FileName);

                    //generate RandomName
                    string random      = randomName();
                    string newFileName = random + extension;

                    FileUpload1.SaveAs(HttpContext.Current.Server.MapPath("~") + "/Uploads/" +
                                       newFileName);


                    //THIS IS WHERE THE PREVIEW IMG IS CREATED
                    //open the document
                    PdfManager  objPdf = new PdfManager();
                    PdfDocument objDoc = objPdf.OpenDocument(HttpContext.Current.Server.MapPath("~") + "/Uploads/" + newFileName);

                    //get the first page
                    PdfPage firstPage = objDoc.Pages[1];

                    //convert to img
                    PdfPreview objPreview = firstPage.ToImage("ResolutionX=100; ResolutionY=100");

                    //save
                    objPreview.Save(HttpContext.Current.Server.MapPath("~") + "/Preview/" + random + ".png", true);
                    //END OF PREVIEW


                    //test link
                    hyperlink.NavigateUrl = "http://dulynoted-001-site1.smarterasp.net/Uploads/" + newFileName;
                    hyperlink.Visible     = true;

                    var newNote = new Note
                    {
                        sId                = int.Parse(ddlSection.SelectedValue),
                        userId             = int.Parse(Session["dulyNoted"].ToString()),
                        numberTimesFlagged = 0,
                        upVoteCounter      = 0,
                        downVoteCounter    = 0,
                        source             = "http://dulynoted-001-site1.smarterasp.net/Uploads/" + newFileName,
                        preview            = "http://dulynoted-001-site1.smarterasp.net/Preview/" + random + ".png",
                        title              = NoteTitle.Text,
                        description        = NoteDescription.Text,
                        noteDate           = Calendar_NoteDate.SelectedDate,
                        uploadDate         = DateTime.Now
                    };
                    dc.Notes.InsertOnSubmit(newNote);
                    dc.SubmitChanges();

                    //AFTER THE FILE IS UPLOADED HERE

                    NoteTitle.Text       = "";
                    NoteDescription.Text = "";
                }
                else
                {
                    UploadLabel1.Text = "You must select a section.";
                }
            }
            catch (Exception ex)
            {
                UploadLabel1.Text = "ERROR: " + ex.Message.ToString();
            }
        }
        else
        {
            UploadLabel1.Text = "You have not specified a file.";
        }
    }
示例#5
0
    public static string ExportInvoices(Invoices currentInvoice, string addressFillInInvoice,
        string exportDirectory)
    {
        IPdfManager manager = new PdfManager();
        IPdfDocument document = null;
        IPdfPage page = null;
        if (WebConfig.UsedPredefinedInvoicePaperToPrintInvoice.Trim() == "true")
        {

            document = manager.OpenDocument(WebConfig.AbsolutePathPredefinedInvoicePaper, Missing.Value);
            page = document.Pages[1];
        }
        else
        {
            document = manager.CreateDocument(Missing.Value);
            page = document.Pages.Add(Missing.Value, Missing.Value, Missing.Value);

            ////////////////Draw logo and template///////////////////////////////////
            IPdfImage verticalLine = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/neos-vertical-line.gif"), Missing.Value);
            IPdfParam verticalParam = manager.CreateParam(Missing.Value);
            verticalParam["x"].Value = 5;
            verticalParam["y"].Value = 0;
            verticalParam["ScaleX"].Value = 0.4f;
            //logoParam1["ScaleY"].Value = 0.8f;

            page.Canvas.DrawImage(verticalLine, verticalParam);

            IPdfImage logoImage = document.OpenImage(HttpContext.Current.Request.MapPath("~/images/logo_neos_new.gif"), Missing.Value);
            IPdfParam logoParam = manager.CreateParam(Missing.Value);
            logoParam["x"].Value = 20;
            logoParam["y"].Value = page.Height - 140;
            logoParam["ScaleX"].Value = 0.8f;
            logoParam["ScaleY"].Value = 0.8f;

            page.Canvas.DrawImage(logoImage, logoParam);

            string imageFooterPath = WebConfig.AbsolutePathImageFooterPath;
            if (!File.Exists(imageFooterPath))
            {
                imageFooterPath = HttpContext.Current.Request.MapPath("~/images/logo-neos-footer.gif");
            }
            IPdfImage footerImage = document.OpenImage(imageFooterPath, Missing.Value);
            IPdfParam footerParam = manager.CreateParam(Missing.Value);
            footerParam["x"].Value = 130;
            footerParam["y"].Value = 10;
            footerParam["ScaleX"].Value = 0.55f;
            footerParam["ScaleY"].Value = 0.55f;

            page.Canvas.DrawImage(footerImage, footerParam);
        }

        IPdfParam param = manager.CreateParam(Missing.Value);

        //Get invoice details and payments.
        IList<InvoiceDetails> detailList = new InvoiceDetailsRepository().GetInvoiceDetailsOfInvoice(
                                        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear, null);
        CompanyAddress comAddress = new CompanyAddressRepository().FindOne(
            new CompanyAddress(currentInvoice.RefCustomerNumber.Value));

        //-----Do not show payment----------------//
        //IList<InvoicePayments> paymentList =
        //    new InvoicePaymentsRepository().GetInvoicePaymentsOfInvoice(
        //        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear);
        //double paymentTotal = new InvoicePaymentsRepository().GetSumPaymentOfInvoice(
        //        currentInvoice.IdFactNumber, currentInvoice.IdTypeInvoice, currentInvoice.IdYear);

        //////////////// Draw Invoice title. ////////////////////////////////////
        //int height = 750;
        string title = currentInvoice.IdTypeInvoice == "I" ? ResourceManager.GetString("lblInvoiceInvoice") : ResourceManager.GetString("lblInvoiceCreditNote");
        title = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 12pt; font-weight: bold; color: black"">{0}</FONT>",
            title);
        page.Canvas.DrawText(title, "x=360, y=720, html=true", document.Fonts["Arial", Missing.Value]);

        ///////////////////////Draw Customers .///////////////////////////////////
        string companyName = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 12pt; font-weight: bold; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Name) ? "" : comAddress.Name));
        page.Canvas.DrawText(companyName, "x=320, y=650, html=true", document.Fonts["Arial", Missing.Value]);

        string coName = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Co) ? "" : comAddress.Co));
        page.Canvas.DrawText(coName, "x=320, y=635, html=true", document.Fonts["Arial", Missing.Value]);

        string companyAddr = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.Address) ? "" : comAddress.Address));
        page.Canvas.DrawText(companyAddr, "x=320, y=620, html=true", document.Fonts["Arial", Missing.Value]);

        string companyCity = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            (string.IsNullOrEmpty(comAddress.ZipCode) ? "" : comAddress.ZipCode) + " " +
            (string.IsNullOrEmpty(comAddress.City) ? "" : comAddress.City));
        page.Canvas.DrawText(companyCity, "x=320, y=605, html=true", document.Fonts["Arial", Missing.Value]);

        string vatNumber = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceVATNumber") + " : "
            + (string.IsNullOrEmpty(comAddress.VatNumber) ? "" : comAddress.VatNumber));
        page.Canvas.DrawText(vatNumber, "x=320, y=575, html=true", document.Fonts["Arial", Missing.Value]);

        string invoiceNumber = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceNumber") + " : " + currentInvoice.IdFactNumber.ToString());
        page.Canvas.DrawText(invoiceNumber, "x=70, y=560, html=true", document.Fonts["Arial", Missing.Value]);

        string invoiceDate = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
            ResourceManager.GetString("lblInvoiceDate") + " : "
            + (currentInvoice.Date.HasValue ? currentInvoice.Date.Value.ToString("dd/MM/yyyy") : string.Empty));
        page.Canvas.DrawText(invoiceDate, "x=320, y=560, html=true", document.Fonts["Arial", Missing.Value]);

        ///////////////////Draw details//////////////////////////////////////
        int heightDetail = 15;
        for (int i = 0; i < detailList.Count; i++)
        {
            heightDetail += CountLineOfString(detailList[i].Description, 33) * 13;
        }

        string rowsDetail = ((int)(detailList.Count + 1)).ToString();
        string detailParam = "width=500;height=" + heightDetail + "; Rows=" + rowsDetail
            + "; Cols=4; cellborder=0.1; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
        IPdfTable tableDetail = document.CreateTable(detailParam);
        tableDetail.Font = document.Fonts["Arial", Missing.Value];
        param.Set("alignment=left; size=10;");

        tableDetail.Rows[1].Cells[1].Width = 330;
        tableDetail.Rows[1].Cells[2].Width = 50;
        tableDetail.Rows[1].Cells[3].Width = 50;
        tableDetail.Rows[1].Cells[4].Width = 70;
        //tableDetail.Rows[1].Cells[5].Width = 50;
        //tableDetail.Rows[1].Cells[5].Width = 40;
        //tableDetail.Rows[1].Cells[6].Width = 50;
        //tableDetail.Rows[1].Cells[7].Width = 50;

        //New requirement (20-11-2009) : not show %VAT, VAT amuount and total
        tableDetail.Rows[1].Cells[1].AddText(ResourceManager.GetString("columnInvoiceDetailDescriptionHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[2].AddText(ResourceManager.GetString("columnInvoiceDetailQuantityHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[3].AddText(ResourceManager.GetString("columnInvoiceDetailUnitPriceHeader"), param, Missing.Value);
        tableDetail.Rows[1].Cells[4].AddText(ResourceManager.GetString("columnInvoiceDetailAmountHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[5].AddText(ResourceManager.GetString("columnInvoiceDetailCodeVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[5].AddText(ResourceManager.GetString("columnInvoiceDetailPercentVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[6].AddText(ResourceManager.GetString("columnInvoiceDetailAmountVATHeader"), param, Missing.Value);
        //tableDetail.Rows[1].Cells[7].AddText(ResourceManager.GetString("columnInvoiceDetailTotalAmountHeader"), param, Missing.Value);
        IPdfParam paramLeft = manager.CreateParam(Missing.Value);
        paramLeft.Set("alignment=right; size=10;");
        for (int i = 0; i < detailList.Count; i++)
        {
            InvoiceDetails detail = detailList[i];
            tableDetail.Rows[i + 2].Cells[1].Height = CountLineOfString(detail.Description, 33) * 13;
            tableDetail.Rows[i + 2].Cells[1].AddText(string.IsNullOrEmpty(detail.Description) ? "" : detail.Description, param, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[2].AddText(Get2DigitStringOfDouble(detail.Quantity), paramLeft, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[3].AddText(Get2DigitStringOfDouble(detail.UnitPriceEuro), paramLeft, document.Fonts["Arial", Missing.Value]);
            tableDetail.Rows[i + 2].Cells[4].AddText(Get2DigitStringOfDouble(detail.AmountEuro), paramLeft, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[5].AddText(detail.VatCode.HasValue ? detail.VatCode.Value.ToString() : "", param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[5].AddText(detail.VatRate.HasValue ? detail.VatRate.Value.ToString() : "", param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[6].AddText(Get2DigitStringOfDouble(detail.AmountVAT), param, document.Fonts["Arial", Missing.Value]);
            //tableDetail.Rows[i + 2].Cells[7].AddText(Get2DigitStringOfDouble(detail.TotalAmountVAT), param, document.Fonts["Arial", Missing.Value]);
        }
        page.Canvas.DrawTable(tableDetail, "x=70, y=530");

        //////////////////Draw total of details/////////////////////////////////////////////////
        //string totalHVTA = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-weight: normal; color: black"">{0}</FONT>",
        //    ResourceManager.GetString("lblInvoiceTotalHTVA") + " : "
        //    + (currentInvoice.TotalHtvaEuro.HasValue ? currentInvoice.TotalHtvaEuro.Value.ToString() : "0"));
        //page.Canvas.DrawText(invoiceNumber, "x=70, y=575, html=true", document.Fonts["Arial", Missing.Value]);

        IPdfTable tableTotal = document.CreateTable("width=165;height=50; Rows=3; Cols=2; cellborder=0;  cellspacing=0; cellpadding=0");
        tableTotal.Font = document.Fonts["Arial", Missing.Value];
        param.Set("alignment=left; size=10;");
        tableTotal.Rows[1].Cells[1].Width = 85;
        tableTotal.Rows[1].Cells[2].Width = 80;

        tableTotal.Rows[1].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotalHTVA"), param, Missing.Value);
        tableTotal.Rows[1].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.TotalHtvaEuro)), param, Missing.Value);

        tableTotal.Rows[2].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotalVAT"), param, Missing.Value);
        tableTotal.Rows[2].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.AmountVatEuro)), param, Missing.Value);

        tableTotal.Rows[3].Cells[1].AddText(ResourceManager.GetString("lblInvoiceTotal"), param, Missing.Value);
        tableTotal.Rows[3].Cells[2].AddText(": " + (Get2DigitStringOfDouble(currentInvoice.TotalAmountIncludeVatEuro)), param, Missing.Value);

        int totalY = 530 - heightDetail - 20;
        if (!string.IsNullOrEmpty(comAddress.FactoringCode))
        {
            page.Canvas.DrawTable(tableTotal, "x=400, y=200");
        }
        else
        {
            page.Canvas.DrawTable(tableTotal, "x=400, y=145");
        }

        ///////////////Draw factoring code////////////////////////////////////
        if (!string.IsNullOrEmpty(currentInvoice.Remark))
        {
            int remarkHeight = CountLineOfString(currentInvoice.Remark, 33) * 13;
            string remarkParam = "width=300;height=" + remarkHeight + "; Rows=1; Cols=1; cellborder=0.0; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
            IPdfTable tableRemark = document.CreateTable(remarkParam);
            tableRemark.Font = document.Fonts["Arial", Missing.Value];
            param.Set("alignment=left; size=10;");

            tableRemark.Rows[1].Cells[1].AddText(currentInvoice.Remark, param, Missing.Value);

            page.Canvas.DrawTable(tableRemark, "x=70, y=220");
        }

        ///////////////Draw factoring code////////////////////////////////////
        if (!string.IsNullOrEmpty(comAddress.FactoringCode))
        {
            //string factParam = "width=500;height=40; Rows=2; Cols=1; cellborder=0.0; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
            //IPdfTable tableFact = document.CreateTable(factParam);
            //tableFact.Font = document.Fonts["Arial", Missing.Value];
            //param.Set("alignment=left; size=10;");
            string factoringCode1 = ResourceManager.GetString("MessagePrintFactoringCode1");
            string factoringCode2 = ResourceManager.GetString("MessagePrintFactoringCode2");
            factoringCode1 = string.Format(factoringCode1, comAddress.FactoringCode,
                currentInvoice.IdFactNumber, currentInvoice.IdYear.ToString().Substring(2, 2));
            //string factoringCode = ResourceManager.GetString("lblFactoringCode") + " : " + comAddress.FactoringCode.HasValue.ToString()
            //    + currentInvoice.IdFactNumber.ToString();
            //if (currentInvoice.Date.HasValue)
            //{
            //    factoringCode += currentInvoice.Date.Value.Year.ToString().Substring(2);
            //}
            //tableFact.Rows[1].Cells[1].Width = 470;
            //tableFact.Rows[1].Cells[1].AddText(factoringCode1, param, Missing.Value);
            //tableFact.Rows[2].Cells[1].AddText(factoringCode2, param, Missing.Value);
            //totalY = totalY - 100;
            //page.Canvas.DrawTable(tableFact, "x=70, y=140");

            factoringCode1 = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-style: Italic; font-weight: Normal; color: black"">{0}</FONT>",
                                                factoringCode1);
            page.Canvas.DrawText(factoringCode1, "x=70, y=120, html=true", document.Fonts["Arial", Missing.Value]);
            factoringCode2 = string.Format(@"<FONT STYLE=""font-family: Arial; font-size: 10pt; font-style: Italic; font-weight: Normal; color: black"">{0}</FONT>",
                                                factoringCode2);
            page.Canvas.DrawText(factoringCode2, "x=70, y=105, html=true", document.Fonts["Arial", Missing.Value]);
        }

        /*
        ////////////////////////////////Draw payments /////////////////////////////////
        totalY = totalY - 25;
        page.Canvas.DrawText(ResourceManager.GetString("tabInvoicePayment"), "x=70, y=" + totalY.ToString() + ", size=15;", document.Fonts["Helvetica", Missing.Value]);

        string heightPayment = ((int)(paymentList.Count * 12 + 20)).ToString();
        string rowsPayment = ((int)(paymentList.Count + 1)).ToString();
        string paymentParam = "width=500;height=" + heightPayment + "; Rows=" + rowsPayment
            + "; Cols=3; cellborder=0.1; cellbordercolor = lightgray ; cellspacing=0; cellpadding=0";
        IPdfTable tablePayment = document.CreateTable(paymentParam);
        tablePayment.Font = document.Fonts["Helvetica", Missing.Value];
        param.Set("alignment=left; size=10;");

        tablePayment.Rows[1].Cells[1].Width = 300;
        tablePayment.Rows[1].Cells[2].Width = 110;
        tablePayment.Rows[1].Cells[3].Width = 60;

        tablePayment.Rows[1].Cells[1].AddText(ResourceManager.GetString("columnInvoicePaymentRemarkHeader"), param, Missing.Value);
        tablePayment.Rows[1].Cells[2].AddText(ResourceManager.GetString("columnInvoicePaymentDateHeader"), param, Missing.Value);
        tablePayment.Rows[1].Cells[3].AddText(ResourceManager.GetString("columnInvoicePaymentAmountHeader"), param, Missing.Value);

        for (int i = 0; i < paymentList.Count; i++)
        {
            InvoicePayments payment = paymentList[i];
            tablePayment.Rows[i + 2].Cells[1].AddText(string.IsNullOrEmpty(payment.Remark) ? "" : payment.Remark, param, document.Fonts["Arial", Missing.Value]);
            tablePayment.Rows[i + 2].Cells[2].AddText(
                payment.DatePayment.HasValue ? payment.DatePayment.Value.ToString("dd/MM/yyyy") : "",
                param, document.Fonts["Courier", Missing.Value]);
            tablePayment.Rows[i + 2].Cells[3].AddText(
                payment.Amount.HasValue ? payment.Amount.Value.ToString() : "0",
                param, document.Fonts["Courier", Missing.Value]);
        }
        totalY = totalY - 20;
        page.Canvas.DrawTable(tablePayment, "x=70, y=" + totalY.ToString());

        totalY = totalY - int.Parse(heightPayment) - 5;

        ////////////////////Draw total of payment///////////////////////////////////////////
        page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoicePaymentAmount"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        page.Canvas.DrawText(paymentTotal.ToString(), "x=480, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);

        totalY = totalY - 15;
        double remain = 0;
        if (currentInvoice.TotalAmountIncludeVatEuro.HasValue)
        {
            remain = currentInvoice.TotalAmountIncludeVatEuro.Value - paymentTotal;
        }
        else
        {
            remain = -paymentTotal;
        }
        page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoiceRemainAmount"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        page.Canvas.DrawText(remain.ToString(), "x=480, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);

        totalY = totalY - 15;
        if (currentInvoice.Payement.HasValue && currentInvoice.Payement.Value && currentInvoice.DateOfPayement.HasValue)
        {
            page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoicePaid"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
            page.Canvas.DrawText(currentInvoice.DateOfPayement.Value.ToString("dd/MM/yyyy"), "x=370, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        }
        else
        {
            page.Canvas.DrawText(ResourceManager.GetString("labelTotalInvoiceUnpaid"), "x=70, y=" + totalY.ToString() + ", size=10;", document.Fonts["Helvetica", Missing.Value]);
        }
        */

        /////// Save document, the Save method returns generated file name///////////////
        string fileName = exportDirectory + "\\";
        //string fileName = string.Empty;
        if (currentInvoice.IdTypeInvoice == "I")
            fileName += "Invoice";
        else
            fileName += "Credit Note";
        fileName += "-" + currentInvoice.IdFactNumber.ToString() + currentInvoice.IdTypeInvoice + currentInvoice.IdYear;
        fileName += "-" + DateTime.Today.Year;
        if (DateTime.Today.Month < 10)
        {
            fileName += "0";
        }
        fileName += DateTime.Today.Month;
        if (DateTime.Today.Day < 10)
        {
            fileName += "0";
        }
        fileName += DateTime.Today.Day + ".pdf";
        //fileName = "attachment;filename=" + fileName;
        string strFilename = document.Save(fileName, true);
        //document.SaveHttp(fileName, Missing.Value);
        return fileName;
    }