private void AddTextInRect(string positions, string text, ref Doc theDoc)
 {
     theDoc.Rect.String = positions;
     theDoc.FontSize    = 8;
     theDoc.Font        = theDoc.AddFont("Arial");
     theDoc.AddHtml(text);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            // ---- Adds a font reference to the document ----
            Doc doc = new Doc();

            doc.FontSize = 48;
            string theFont = "Times-Roman ";

            doc.Font = doc.AddFont(theFont);
            doc.AddText(theFont);
            theFont  = "Helvetica-Bold";
            doc.Font = doc.AddFont(theFont);
            doc.AddText(theFont);
            doc.Save(Server.MapPath("~/Results/Output.pdf"));
            doc.Clear();
        }
        private Doc AddFooter(Doc theDoc, string id, int lineNumber)
        {
            var theCount = theDoc.PageCount;

            var deliveryAssurance = _deliveryNoteRepository.GetDeliveryAssurance(id, lineNumber);

            for (var i = 1; i <= theCount; i++)
            {
                theDoc.FontSize = 8;

                theDoc.Rect.String  = "45 30 575 110";
                theDoc.Color.String = "0 0 0";

                theDoc.Font = theDoc.AddFont("Arial");

                theDoc.AddText($"Leveransförsäkran skapad av {GetCustomerName(deliveryAssurance.SupplierNumber)}");

                theDoc.AddLine(45, 100, 575, 100);

                if (DeliveryAssurancePage != null)
                {
                    AddTextInRect("45 30 151 85", FixNewLine(DeliveryAssurancePage.Footer1), ref theDoc);
                    AddTextInRect("151 30 257 85", FixNewLine(DeliveryAssurancePage.Footer2), ref theDoc);
                    AddTextInRect("257 30 363 85", FixNewLine(DeliveryAssurancePage.Footer3), ref theDoc);
                    AddTextInRect("363 30 469 85", FixNewLine(DeliveryAssurancePage.Footer4), ref theDoc);
                    AddTextInRect("469 30 575 85", FixNewLine(DeliveryAssurancePage.Footer5), ref theDoc);
                }
            }
            return(theDoc);
        }
Beispiel #4
0
 private static int AddtxtLineAndFont(ref Doc theDoc, string line, string font, int size, bool bold, bool italic)
 {
     theDoc.FontSize         = size;
     theDoc.Font             = theDoc.AddFont(font);
     theDoc.TextStyle.Bold   = bold;
     theDoc.TextStyle.Italic = italic;
     return(theDoc.AddText(line));
 }
Beispiel #5
0
        /// <summary>
        /// 添加页眉和页脚
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="titleDic"></param>
        /// <param name="customName"></param>
        /// <param name="bookTaskUrl"></param>
        private static void AddHeader(ref Doc doc, Dictionary <int, string> titleDic, string customName, string bookTaskUrl)
        {
            for (int i = 1; i <= doc.PageCount; i++)
            {
                doc.PageNumber = i;

                doc.Rect.String  = "52 722 568 750"; //"left bottom right top". 直接通过这种方式指定表头输出区域
                doc.HPos         = 0;                //0.5代表居中, 0代表居左, 1代表居右
                doc.VPos         = 1;                //0.5代表居中, 0代表靠上, 1代表靠下
                doc.Color.String = "0 0 0";
                doc.Font         = doc.AddFont("宋体", "ChineseS");
                doc.AddHtml(bookTaskUrl);

                doc.Rect.String  = "52 722 568 750"; //"left bottom right top".
                doc.HPos         = 1;                //0.5代表居中, 0代表居左, 1代表居右
                doc.VPos         = 1;                //0.5代表居中, 0代表靠上, 1代表靠下
                doc.Color.String = "0 0 0";          //红色255 0 0
                doc.Font         = doc.AddFont("宋体", "ChineseS");
                doc.AddHtml(" <font color=\"#333333\">" + titleDic[i] + "</font>");

                doc.Color.String = "0 0 0";
                doc.AddLine(52, 720, 568, 720); //画一条页眉分隔线

                doc.Rect.String      = "52 12 568 53";
                doc.HPos             = 0;
                doc.VPos             = 0;
                doc.TextStyle.Italic = true;
                doc.AddHtml(" <font color=\"#666666\">" + customName + "</font>");
                doc.TextStyle.Italic = false;

                doc.Rect.String  = "52 12 568 53";
                doc.HPos         = 1.0;
                doc.VPos         = 0;
                doc.Color.String = "0 0 0"; //黑色
                doc.AddHtml("page " + i.ToString() + "/" + doc.PageCount.ToString());
                doc.Color.String = "0 0 0";
                doc.AddLine(52, 55, 568, 55);//画一条页脚分隔线
                doc.Color.String = "0 0 0";
            }
        }
Beispiel #6
0
 /// <summary>
 /// Stamps a PDF document with a line of text in a small font size at the lower left hand side of
 /// the first page of the document
 /// </summary>
 /// <param name="documentPath">The full PDF document file path and name</param>
 /// <param name="text">The line of text to stamp onto the document</param>
 public void AddFooterText(string path, string text)
 {
     using (var doc = new Doc())
     {
         doc.Read(path);
         using (var doc2 = new Doc())
         {
             doc2.Read(doc.GetStream());
             doc.Clear();
             doc2.FontSize = 8;
             var theF1 = doc2.AddFont("Arial");
             doc2.Font  = theF1;
             doc2.Pos.X = 37;
             doc2.Pos.Y = 32;
             doc2.AddText(text);
             doc2.Save(path);
         }
     }
 }
Beispiel #7
0
        public void FormatPDFHtmlOptions()
        {
            theDoc.HtmlOptions.Engine    = EngineType.Gecko;
            theDoc.HtmlOptions.UseScript = true;
            //theDoc.HtmlOptions.OnLoadScript = "(function(){ window.ABCpdf_go = false; setTimeout(function(){ window.ABCpdf_go = true; }, 1000); })();";
            theDoc.HtmlOptions.ImageQuality = 33;
            theDoc.HtmlOptions.Timeout      = 300000;
            theDoc.HtmlOptions.BrowserWidth = 1500;
            theDoc.HtmlOptions.AddLinks     = true;
            // theDoc.HtmlOptions.BreakMethod = HtmlBreakMethodType.NoOptimization;
            //  theDoc.HtmlOptions.BreakZoneSize = 400;

            // header footer custom font

            theDoc.HtmlOptions.FontEmbed      = true;
            theDoc.HtmlOptions.FontSubstitute = true;
            theDoc.HtmlOptions.FontProtection = false;
            theDoc.HtmlOptions.FontSubset     = false;
            theDoc.Font = theDoc.AddFont("Arial");
        }
Beispiel #8
0
        /// <summary>
        /// 将html页面生成pdf文档,同步方式
        /// </summary>
        /// <param name="url"></param>
        /// <param name="savePath"></param>
        /// <returns></returns>
        public static bool Html2PDFSynch(string url, string savePath, string customName)
        {
            Doc doc = new Doc();

            try
            {
                //url = "http://localhost:8018/PDF?returnUrl=http://localhost:8018/Material/MatList/exporttopdf?matListId=167";
                doc.HtmlOptions.UseNoCache       = true;
                doc.HtmlOptions.PageCacheEnabled = false;
                doc.HtmlOptions.PageCacheClear();
                doc.HtmlOptions.Timeout    = 30 * 1000;
                doc.HtmlOptions.UseScript  = true;
                doc.HtmlOptions.UseActiveX = true;
                doc.Rect.Inset(36.0, 72.0);
                doc.Page = doc.AddPage();
                int num = doc.AddImageUrl(url);
                while (true)
                {
                    //doc.FrameRect();//添加黑色边框
                    if (!doc.Chainable(num))
                    {
                        break;
                    }
                    doc.Page = doc.AddPage();
                    num      = doc.AddImageToChain(num);
                }
                for (int i = 1; i <= doc.PageCount; i++)
                {
                    doc.PageNumber = i;

                    doc.Color.String = "0 0 0";     //黑色
                    doc.AddLine(24, 750, 588, 750); //画一条分隔线

                    doc.Rect.String      = "24 12 588 40";
                    doc.HPos             = 0;
                    doc.VPos             = 0.5;
                    doc.Font             = doc.AddFont("宋体", "ChineseS");
                    doc.TextStyle.Italic = true;
                    doc.AddHtml(" <font color=\"#cccccc\">" + customName + "</font>");
                    doc.TextStyle.Italic = false;

                    doc.Rect.String  = "24 12 588 40";
                    doc.HPos         = 1.0;
                    doc.VPos         = 0.5;
                    doc.Color.String = "0 0 0"; //黑色
                    doc.AddHtml("page " + i.ToString() + "/" + doc.PageCount.ToString());
                    doc.AddLine(24, 40, 588, 40);

                    doc.Flatten();
                }
                if (!savePath.ToLower().EndsWith(".pdf"))
                {
                    savePath += ".pdf";
                }
                doc.Save(savePath);
                doc.Clear();
                return(true);
            }
            catch (Exception ex)
            {
                LogError.ReportErrors(ex.Message);

                return(false);
            }
            finally
            {
                doc.Clear();
            }

            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// Create an estimate body in html format, related to an Estimate.
        /// </summary>
        /// <param name="HTML">The HTML.</param>
        /// <param name="estimateid">estimate id.</param>
        /// <param name="theDoc">The doc.</param>
        /// <param name="printCustomerDetails">if set to <c>true</c> [print customer details].</param>
        /// <param name="promotiontypeid">The promotiontypeid.</param>
        /// <returns>Pdf document</returns>
        public Doc PrintEstimateBody(string pdftemplate, int estimateid, Doc theDoc)
        {
            StringBuilder sb       = new StringBuilder();
            StringBuilder tempdesc = new StringBuilder();
            string        tempStr  = string.Empty;

            // Add the Disclaimer/Acknowledgements body text.
            Doc theDoc3 = new Doc();

            theDoc3.MediaBox.SetRect(0, 0, 595, 600);
            theDoc3.Rect.String = "0 0 565 600";

            theDoc3.Color.Color    = System.Drawing.Color.Black;
            theDoc3.Font           = theDoc3.AddFont(Common.PRINTPDF_DEFAULT_FONT);
            theDoc3.TextStyle.Size = Common.PRINTPDF_DISCLAIMER_FONTSIZE;
            theDoc3.TextStyle.Bold = false;
            theDoc3.Rect.Pin       = 0;
            theDoc3.Rect.Position(20, 0);
            theDoc3.Rect.Width           = 400;
            theDoc3.Rect.Height          = 600;
            theDoc3.TextStyle.LeftMargin = 25;

            string disclaimer = Common.getDisclaimer(estimateRevisionId.ToString(), Session["OriginalLogOnState"].ToString(), estimateRevision_internalVersion, estimateRevision_disclaimer_version).Replace("$Token$", tempStr);

            disclaimer = disclaimer.Replace("$printdatetoken$", DateTime.Now.ToString("dd/MMM/yyyy"));
            disclaimer = disclaimer.Replace("$logoimagetoken$", Server.MapPath("~/images/metlog.jpg"));

            if (variationnumber == "--")
            {
                disclaimer = disclaimer.Replace("$DaysExtension$", "&nbsp;");
            }
            else
            {
                disclaimer = disclaimer.Replace("$DaysExtension$", string.Format("EXTENSION OF TIME {0} DAYS (Due to the above variation)", extentiondays));
            }

            // If QLD, then use a real deposit amount in the Agreement
            if (Session["OriginalLogOnStateID"] != null)
            {
                if (Session["OriginalLogOnStateID"].ToString() == "3")
                {
                    DBConnection DBCon = new DBConnection();
                    SqlCommand   Cmd   = DBCon.ExecuteStoredProcedure("spw_checkIfContractDeposited");
                    Cmd.Parameters["@contractNo"].Value = BCContractnumber;
                    DataSet ds     = DBCon.SelectSqlStoredProcedure(Cmd);
                    double  amount = 0;
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        amount = double.Parse(ds.Tables[0].Rows[0]["DepositAmount"].ToString());
                    }
                    if (amount > 0.00)
                    {
                        disclaimer = disclaimer.Replace("$DepositAmount$", "payment of " + String.Format("{0:C}", amount));
                    }
                    else
                    {
                        disclaimer = disclaimer.Replace("$DepositAmount$", "payment as receipted");
                    }
                }
            }

            if (disclaimer.Trim() != "")
            {
                int docid = theDoc3.AddImageHtml(disclaimer);
                while (true)
                {
                    if (!theDoc3.Chainable(docid))
                    {
                        break;
                    }

                    theDoc3.Page = theDoc3.AddPage();
                    docid        = theDoc3.AddImageToChain(docid);
                }
            }

            theDoc.Append(theDoc3);

            return(theDoc);
        }
 private Doc AddHeaderFooter(Doc theDoc)
 {
     int theCount = theDoc.PageCount;
     int i = 0;
     //This block add Header
     BindPDFInfoData();
     string theFont = "Helvetica-Bold";
     theDoc.Font = theDoc.AddFont(theFont);
     theDoc.FontSize = 10;
     string imgPath = Server.MapPath(CredentialLogoURL);
     for (i = 1; i <= theCount; i++)
     {
         theDoc.PageNumber = i;
         theDoc.Rect.String = "10 750 490 777";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.4;
         theDoc.AddText(CredentialHeaderText);
         if (i == 1)
         {
             theDoc.Rect.String = "500 730 600 775";
             if (File.Exists(imgPath))
             {
                 theDoc.AddImage(imgPath);
             }
             else
             {
                 imgPath = Server.MapPath("~/Images" + "/CredentialLogo.jpg");
                 if (File.Exists(imgPath))
                     theDoc.AddImage(imgPath);
             }
             //SetImageWidthAndHeight(theDoc);//Do not remove 
         }
         theDoc.Rect.String = "5 10 605 783";
         theDoc.FrameRect();
     }
     //This block add Footer
     for (i = 1; i <= theCount; i++)
     {
         theDoc.PageNumber = i;
         theDoc.Rect.String = "10 10 500 60";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.5;
         theDoc.FontSize = 10;
         theDoc.AddText(CredentialFooterText);
         theDoc.Rect.String = "500 10 590 60";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.5;
         theDoc.FontSize = 8;
         theDoc.AddText("Page " + i + " of " + theCount); //Setting page number  
     }
     return theDoc;
 }
Beispiel #11
0
        public static string OutputToPdf(string reference, string ReturnString, string FilePrefix, Image imageID, string FIUserID = "", string FIName = "")
        {
            /* 612  792
             * Paper        Width	Height in Points
             *  A3		842		1190
             *  A4		595		842
             *  A5		420		595
             *  Letter	612		792
             */
            double borderLeft = 50, borderTop = 70;
            Doc    theDoc = new Doc();

            theDoc.Width                   = 1; //line thickness
            theDoc.MediaBox.String         = "A4";
            theDoc.Rect.String             = theDoc.MediaBox.String;
            theDoc.TextStyle.Justification = 1;
            theDoc.Rect.Inset(borderLeft, borderTop);   //Set the paper border
            //save page size
            RectPos rect = new RectPos();

            rect.left   = theDoc.Rect.Left;
            rect.top    = theDoc.Rect.Top;
            rect.width  = theDoc.Rect.Width;
            rect.height = theDoc.Rect.Height;
            rect.bottom = theDoc.Rect.Bottom;

            /*
             * A4 working area
             * Width  495 = 595 - (50*2)
             * Height  555 = 842 - (70*2)
             */
            //counters
            int cnt  = 0;
            int page = 0;
            //setup the fonts
            int iFont_BMWTypeRegular = theDoc.AddFont("BMWTypeRegular");
            int iFont_Arial          = theDoc.AddFont("Arial");
            int iFont_Consolas       = theDoc.AddFont("Consolas");
            int iFont_Courier        = theDoc.AddFont("Courier New");
            int iFontCurrent         = 0;

            //headers
            string HeaderMain = "BMW Financial Services (Pty) Ltd South Africa" + Environment.NewLine;
            string HeaderSub  = "Identification Document or Smart Card Barcode Decoding" + Environment.NewLine;
            string FIString   = "Triggered by : " + FIName + " (" + FIUserID + ") " + Environment.NewLine;
            string DateString = "Date : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + Environment.NewLine;
            string Purpose    = "The result of the Identification document or smart card ID barcode decoding is shown below: \r\n\r\n"
                                + "As a risk aversion measure and in line with Know Your customer requirements, "
                                + "kindly establish that the information corresponds with the physical document provided by the applicant." + Environment.NewLine;

            try
            {
                string[] arStr = Regex.Split(ReturnString, "\r\n");
                //set the main headers/title
                iFontCurrent = (iFont_BMWTypeRegular > 0) ? iFont_BMWTypeRegular : iFont_Arial; //change font to Arial if bmw font does not exist

                theDoc.Color.String = "180 180 180";                                            //some grayish text color
                AddtxtLineAndFont(ref theDoc, HeaderMain, iFontCurrent, 20, true, false);

                theDoc.Color.String = "100 100 100";    //some grayish text color
                AddtxtLineAndFont(ref theDoc, HeaderSub, iFontCurrent, 12, true, false);

                AddtxtLineAndFont(ref theDoc, Environment.NewLine + Environment.NewLine + Environment.NewLine, iFontCurrent, 12, true, false);

                theDoc.AddLine(borderLeft, A4_HEIGHT - 105, 550, A4_HEIGHT - 105); //left , top , with , top
                theDoc.AddLine(borderLeft, 50, 550, 50);                           //left , top , with , top

                //set the other headers
                AddtxtLineAndFont(ref theDoc, FIString, iFontCurrent, 10, false, true);
                AddtxtLineAndFont(ref theDoc, DateString, iFontCurrent, 10, false, true);
                AddtxtLineAndFont(ref theDoc, Environment.NewLine + Environment.NewLine + Environment.NewLine, iFontCurrent, 12, true, false);

                theDoc.Color.String = "100 100 100";    //some grayish text color
                AddtxtLineAndFont(ref theDoc, Purpose, iFontCurrent, 10, false, true);
                AddtxtLineAndFont(ref theDoc, Environment.NewLine + Environment.NewLine + Environment.NewLine, iFontCurrent, 12, true, false);


                foreach (string line in arStr)
                {
                    if (line.StartsWith("*"))   //an indicator for bold text
                    {
                        AddtxtLineAndFont(ref theDoc, line.Replace("*", "") + "\r\n", iFontCurrent, 10, true, false);
                    }
                    else
                    {
                        AddtxtLineAndFont(ref theDoc, line + "\r\n", iFontCurrent, 10, false, false, 8);
                    }
                }

                //set images first - on first page
                SetImagePhoto(ref theDoc, imageID, rect, iFontCurrent);
                SetImageLogo(ref theDoc, null, rect);


                //save
                string dt  = DateTime.Now.ToString("MMddHHmmss");
                string REF = "";
                if (reference.Length > 8)
                {
                    REF = reference.Substring(5, 8);
                }
                else
                {
                    REF = reference;
                }

                string TempPath = Path.GetTempPath();
                if (!TempPath.EndsWith(@"\"))
                {
                    TempPath += @"\";
                }
                string Filename = TempPath + FilePrefix + REF + "_" + dt + ".pdf";
                theDoc.Save((Filename));
                theDoc.Clear();


                return(Filename);
            }
            catch (Exception e)
            {
                BarcodeDetection.AddLog_KYC("Error", "QIWS.ABCpdfHandler.OutputToPdf", e.Message, "Output TXT", reference);
                return("");
            }
        }
Beispiel #12
0
 private static void SetFont(ref Doc theDoc, string font, int size)
 {
     theDoc.FontSize = size;
     theDoc.Font     = theDoc.AddFont(font);
 }
Beispiel #13
0
        public void CreateFormattedEmailPdf(string from, string sent, string to, string subject, string htmlbody, string pdfFileName)
        {
            /*
             *          Creates a single paged PDF that is formatted in the MS Outlook email print style:
             *
             *               InfoTrack
             *              --------------------------------------------
             *               From:              << from >>
             *               Sent:              << sent >>
             *               To:                << to >>
             *               Subject:           << subject >>
             *
             *
             *               << body >>
             */

            // Constant coordinates (in pixels):
            const double yCoordHeaderLine1               = 780 - 10 - 4;
            const double yCoordHeaderLine2               = 780 - 20 - 5;
            const double yCoordHeaderLine3               = 780 - 30 - 6.2;
            const double yCoordHeaderLine4               = 780 - 40 - 7.1;
            const double xCoordLineLeftMargin            = 35;
            const double xCoordTextLeftMargin            = 37;
            const double xCoordEmailHeaderInfoLeftMargin = 157;
            const double headerLineThickness             = 2.8;
            const double yCoordHeaderLine             = 780;
            const double ySpacingBetweenHeaderAndBody = 35;
            const double bottomMargin      = 50;
            const double yCoordMailboxName = 793;

            // Transform the plain text to HTML
            // var htmlbody = body;

            using (var theDoc = new Doc())
            {
                // Set page size
                theDoc.MediaBox.String = "A4";
                theDoc.Rect.String     = theDoc.MediaBox.String;
                theDoc.Page            = theDoc.AddPage();

                var pageWidth  = theDoc.Rect.Width;
                var pageHeight = theDoc.Rect.Height;

                // Add the mailbox/account name
                var accountNameFont = theDoc.AddFont("Segoe UI-Bold");
                theDoc.FontSize = 12;
                theDoc.Font     = accountNameFont;
                theDoc.Pos.X    = xCoordTextLeftMargin;
                theDoc.Pos.Y    = yCoordMailboxName;
                theDoc.AddText("InfoTrack");

                // Add horizontal header line
                theDoc.Width = headerLineThickness;
                theDoc.AddLine(xCoordLineLeftMargin, yCoordHeaderLine - headerLineThickness / 2,
                               pageWidth - xCoordLineLeftMargin, yCoordHeaderLine - headerLineThickness / 2);

                // Add the email header headings
                theDoc.FontSize = 10;
                theDoc.Pos.X    = xCoordTextLeftMargin;
                theDoc.Pos.Y    = yCoordHeaderLine1;
                theDoc.AddText("From:");

                theDoc.Pos.X = xCoordTextLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine2;
                theDoc.AddText("Sent:");

                theDoc.Pos.X = xCoordTextLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine3;
                theDoc.AddText("To:");

                theDoc.Pos.X = xCoordTextLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine4;
                theDoc.AddText("Subject:");

                // Add the email header values
                var headerInfoFont = theDoc.AddFont("Segoe UI");
                theDoc.Font  = headerInfoFont;
                theDoc.Pos.X = xCoordEmailHeaderInfoLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine1;
                theDoc.AddText(from);

                theDoc.Pos.X = xCoordEmailHeaderInfoLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine2;
                theDoc.AddText(sent);

                theDoc.Pos.X = xCoordEmailHeaderInfoLeftMargin;
                theDoc.Pos.Y = yCoordHeaderLine3;
                theDoc.AddText(to);

                theDoc.Rect.Position(xCoordEmailHeaderInfoLeftMargin, yCoordHeaderLine4, XRect.Corner.TopLeft);
                theDoc.Rect.Width = pageWidth - xCoordTextLeftMargin - xCoordEmailHeaderInfoLeftMargin;
                var textObjectId      = theDoc.AddText(subject);
                var endY              = Double.Parse(theDoc.GetInfo(textObjectId, "EndPos").Split(new[] { ' ' })[1]);
                var subjectTextHeight = yCoordHeaderLine4 - endY;

                // Add the email body
                var bodyFont = theDoc.AddFont("Consolas");
                theDoc.Font     = bodyFont;
                theDoc.FontSize = 10;

                theDoc.Rect.Width = pageWidth - (2 * xCoordTextLeftMargin);

                var headerSize = pageHeight - yCoordHeaderLine4 + ySpacingBetweenHeaderAndBody + subjectTextHeight;
                theDoc.Rect.Height = pageHeight - headerSize - bottomMargin;
                theDoc.Rect.Position(xCoordTextLeftMargin, yCoordHeaderLine4 - subjectTextHeight - ySpacingBetweenHeaderAndBody, XRect.Corner.TopLeft);
                theDoc.TextStyle.LineSpacing = 2;

                var chainId   = theDoc.AddImageHtml(htmlbody);
                var topMargin = pageHeight - yCoordMailboxName;

                // Add 1st page number
                theDoc.Rect.Height = 40;
                theDoc.Rect.Position(xCoordTextLeftMargin, 40, XRect.Corner.TopLeft);
                theDoc.HPos = 0.5;
                theDoc.AddText(theDoc.PageNumber.ToString());

                // Add more pages
                var currentPage = 2;
                while (theDoc.Chainable(chainId))
                {
                    theDoc.Rect.Height = pageHeight - topMargin - bottomMargin;
                    theDoc.Rect.Position(xCoordTextLeftMargin, yCoordMailboxName, XRect.Corner.TopLeft);
                    theDoc.Page = theDoc.AddPage();
                    chainId     = theDoc.AddImageToChain(chainId);

                    // Page number
                    theDoc.PageNumber  = currentPage++;
                    theDoc.Rect.Height = 40;
                    theDoc.Rect.Position(xCoordTextLeftMargin, 40, XRect.Corner.TopLeft);
                    theDoc.HPos = 0.5;
                    theDoc.AddText(theDoc.PageNumber.ToString());
                }

                // Save the PDF
                theDoc.Save(pdfFileName);
            }
        }
Beispiel #14
0
        public void GeneratePdf(string pageurl, string fileSavePath, bool showFooterText = false, string footerText = "", string coverSheetPages = "", string customizedLetter = "", string contentpages = "", string kynFile = "", string bloodLetter = "",
                                string doctorLetter   = "", string corporateFluffLetter = "", bool isPpCustomer        = false, string awvTestResult = "", bool isPcpReport = false, bool generatePcpLetter = false, string scannedDocumentsPdf = "", string eawvPdfReport = "",
                                string focAttestation = "", string attestationForm      = "", bool hasSectionToDisplay = true, string mammogram      = "", string ifobt     = "", string urineMicroalbumin  = "", string participantLetter      = "", string chlamydia = "",
                                string awvBoneMass    = "", string osteoporosis         = "", string quantaFloAbi      = "", string hkyn = "", string mybioCheckAssessment  = "", string memberLetter = "", string greenFormAttestation = "", string dpn               = "")
        {
            var finalReport = new Doc();

            int prePrintedCount = 0;

            var beforFinalReportDoc = new Doc();

            try
            {
                if (coverSheetPages != "")
                {
                    var participantLetterDoc = new Doc();
                    var doctorLetterDoc      = new Doc();
                    var customizedLetterDoc  = new Doc();
                    var contentpagesDoc      = new Doc();
                    var eawvPdfDoc           = new Doc();

                    var memberLetterDoc         = new Doc();
                    var greenFormAttestationDoc = new Doc();
                    try
                    {
                        //Cover Sheet
                        beforFinalReportDoc.Read(coverSheetPages);

                        if (!string.IsNullOrWhiteSpace(greenFormAttestation))
                        {
                            greenFormAttestationDoc.Read(greenFormAttestation);
                            beforFinalReportDoc.Append(greenFormAttestationDoc);
                        }

                        //Member Letter
                        if (!string.IsNullOrEmpty(memberLetter))
                        {
                            memberLetterDoc.Read(memberLetter);
                            beforFinalReportDoc.Append(memberLetterDoc);
                        }

                        if (!string.IsNullOrEmpty(participantLetter))
                        {
                            participantLetterDoc.Read(participantLetter);
                            beforFinalReportDoc.Append(participantLetterDoc);
                        }

                        //Doctor letter
                        if (!string.IsNullOrEmpty(doctorLetter))
                        {
                            doctorLetterDoc.Read(doctorLetter);
                            beforFinalReportDoc.Append(doctorLetterDoc);
                        }
                        //Customized Letter Hospital Partner no default letter
                        if (!string.IsNullOrEmpty(customizedLetter))
                        {
                            customizedLetterDoc.Read(customizedLetter);
                            beforFinalReportDoc.Append(customizedLetterDoc);
                        }

                        if (!string.IsNullOrEmpty(contentpages))
                        {
                            contentpagesDoc.Read(contentpages);
                            beforFinalReportDoc.Append(contentpagesDoc);
                        }

                        if (!string.IsNullOrEmpty(eawvPdfReport))
                        {
                            eawvPdfDoc.Read(eawvPdfReport);
                            beforFinalReportDoc.Append(eawvPdfDoc);
                        }

                        prePrintedCount = beforFinalReportDoc.PageCount;
                    }
                    catch (Exception exception)
                    {
                        throw exception;
                    }
                    finally
                    {
                        participantLetterDoc.Clear();
                        participantLetterDoc.Dispose();

                        doctorLetterDoc.Clear();
                        doctorLetterDoc.Dispose();

                        customizedLetterDoc.Clear();
                        customizedLetterDoc.Dispose();

                        contentpagesDoc.Clear();
                        contentpagesDoc.Dispose();

                        eawvPdfDoc.Clear();
                        eawvPdfDoc.Dispose();

                        memberLetterDoc.Clear();
                        memberLetterDoc.Dispose();

                        greenFormAttestationDoc.Clear();
                        greenFormAttestationDoc.Dispose();
                    }
                }

                if (hasSectionToDisplay)
                {
                    finalReport.Rect.Inset(40, 70);
                    //pdfDoc.Rect.
                    finalReport.MediaBox.String = PaperSize;
                    finalReport.Rect.String     = finalReport.MediaBox.String;
                    finalReport.Page            = finalReport.AddPage();
                    finalReport.HtmlOptions.PageCachePurge();
                    finalReport.HtmlOptions.Timeout = 90000;


                    if (AllowLoadingJavascriptbeforePdfGenerate)
                    {
                        finalReport.HtmlOptions.UseScript = true;
                    }

                    int imageToChain = finalReport.AddImageUrl(pageurl, true, 950, true);

                    while (true)
                    {
                        if (!finalReport.Chainable(imageToChain))
                        {
                            break;
                        }
                        finalReport.Page = finalReport.AddPage();
                        imageToChain     = finalReport.AddImageToChain(imageToChain);
                    }

                    footerText = string.IsNullOrEmpty(footerText) ? string.Empty : footerText + " | ";
                    int pageCount = finalReport.PageCount + prePrintedCount;
                    for (int pageNumber = 1; pageNumber <= finalReport.PageCount; pageNumber++)
                    {
                        finalReport.PageNumber = pageNumber;
                        if (showFooterText)
                        {
                            int pNum = pageNumber + prePrintedCount;

                            string txt = footerText + "Page: " + pNum + " of " + pageCount;

                            finalReport.Color.String = "0 0 0"; //Dark grey text

                            finalReport.TextStyle.VPos = 0.98;
                            finalReport.TextStyle.HPos = (pageNumber % 2) == 0 ? 0.10 : 0.80;

                            finalReport.AddFont("Arial");
                            //Add the page number
                            finalReport.AddText(txt);


                            //Add a line above page number
                            finalReport.AddLine(21, 40, 590, 40);
                        }

                        //Flatten page
                        finalReport.Flatten();
                    }
                }



                if (!string.IsNullOrEmpty(kynFile))
                {
                    var inputPdfDoc = new Doc();
                    try
                    {
                        inputPdfDoc.Read(kynFile);
                        finalReport.Append(inputPdfDoc);
                    }
                    finally
                    {
                        inputPdfDoc.Clear();
                        inputPdfDoc.Dispose();
                    }
                }

                AppendPdf(finalReport, hkyn);

                if (!string.IsNullOrEmpty(bloodLetter))
                {
                    var inputPdfDoc = new Doc();
                    try
                    {
                        inputPdfDoc.Read(bloodLetter);
                        finalReport.Append(inputPdfDoc);
                    }
                    finally
                    {
                        inputPdfDoc.Clear();
                        inputPdfDoc.Dispose();
                    }
                }

                if (!string.IsNullOrEmpty(corporateFluffLetter))
                {
                    var inputPdfDoc = new Doc();
                    try
                    {
                        inputPdfDoc.Read(corporateFluffLetter);
                        finalReport.Append(inputPdfDoc);
                    }
                    finally
                    {
                        inputPdfDoc.Clear();
                        inputPdfDoc.Dispose();
                    }
                }

                if (!string.IsNullOrEmpty(awvTestResult))
                {
                    var inputPdfDoc = new Doc();
                    try
                    {
                        inputPdfDoc.Read(awvTestResult);
                        finalReport.Append(inputPdfDoc);
                    }
                    finally
                    {
                        inputPdfDoc.Clear();
                        inputPdfDoc.Dispose();
                    }
                }

                if (!string.IsNullOrEmpty(scannedDocumentsPdf))
                {
                    var inputScannedPdfDoc = new Doc();
                    try
                    {
                        inputScannedPdfDoc.Read(scannedDocumentsPdf);
                        finalReport.Append(inputScannedPdfDoc);
                    }
                    finally
                    {
                        inputScannedPdfDoc.Clear();
                        inputScannedPdfDoc.Dispose();
                    }
                }

                AppendPdf(finalReport, focAttestation);
                AppendPdf(finalReport, attestationForm);
                AppendPdf(finalReport, mammogram);
                AppendPdf(finalReport, ifobt);
                AppendPdf(finalReport, urineMicroalbumin);
                AppendPdf(finalReport, chlamydia);
                AppendPdf(finalReport, awvBoneMass);
                AppendPdf(finalReport, osteoporosis);
                AppendPdf(finalReport, quantaFloAbi);
                AppendPdf(finalReport, mybioCheckAssessment);
                AppendPdf(finalReport, dpn);

                if (coverSheetPages != "")
                {
                    try
                    {
                        beforFinalReportDoc.Append(finalReport);
                        beforFinalReportDoc.Save(fileSavePath);
                    }
                    catch (Exception exception)
                    {
                        throw exception;
                    }
                }
                else
                {
                    finalReport.Save(fileSavePath);
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                finalReport.Clear();
                finalReport.Dispose();

                beforFinalReportDoc.Clear();
                beforFinalReportDoc.Dispose();
            }
        }
        public Archivo GenerarPDF(int Numero_Prestamo, TipoPDF tipoPDF, int Anno, int Porcentaje, string Fila, bool Forzar = false)
        {
            bool BanProc  = false;
            bool NoAplica = false;
            ConstanciasPDFData DatosPDF;
            Archivo            ArchivoConstancia;

            DatosPDF.sNumeroId        = "";
            DatosPDF.sCurp            = "";
            DatosPDF.sNombreCom       = "";
            DatosPDF.sNombres         = "";
            DatosPDF.sPrimerAp        = "";
            DatosPDF.sSegundoAp       = "";
            DatosPDF.sNOMENCLATURA    = "";
            DatosPDF.sCodigoBar       = "";
            DatosPDF.sCodigoMun       = "";
            DatosPDF.sCodigoSec       = "";
            DatosPDF.sCodigodep       = "";
            DatosPDF.sCP              = "";
            DatosPDF.sUbicacionFisGa  = "";
            DatosPDF.scodigobarrioga  = "";
            DatosPDF.scodigomuniga    = "";
            DatosPDF.scodigosectorga  = "";
            DatosPDF.scodigodepga     = "";
            DatosPDF.scpga            = "";
            DatosPDF.sNombreComCoa    = "";
            DatosPDF.sNombresCoa      = "";
            DatosPDF.sPrimerApCoa     = "";
            DatosPDF.sSegundoApCoa    = "";
            DatosPDF.sNumeroIdCoa     = "";
            DatosPDF.sCurpCoa         = "";
            DatosPDF.sNOMENCLATURACoa = "";
            DatosPDF.sCodigoBarCoa    = "";
            DatosPDF.sCodigoMunCoa    = "";
            DatosPDF.sCodigoSecCoa    = "";
            DatosPDF.sCodigoDepCoa    = "";
            DatosPDF.sCpCoa           = "";
            DatosPDF.sINTNOMDEV       = "";
            DatosPDF.sINTNOMPAG       = "";
            DatosPDF.sINTREAL         = "";
            DatosPDF.sMONTOCRED       = "";
            DatosPDF.sMONTOCRED_C2    = "";
            DatosPDF.sINTNOMDEV_C2    = "";
            DatosPDF.sINTNOMPAG_C2    = "";
            DatosPDF.sINTREAL_C2      = "";
            DatosPDF.sMES_INI         = "";
            DatosPDF.sMES_FIN         = "";
            DatosPDF.sCVE_MONEDA      = "";
            DatosPDF.sEjercicio       = "";
            DatosPDF.sjudicial        = "";
            DatosPDF.sBaseJit         = "";
            DatosPDF.sIntNomPag       = "";
            DatosPDF.sEstado          = "";
            DatosPDF.RFC_Emp          = "";
            DatosPDF.RazonSoc_Emp     = "";
            DatosPDF.Calle_Emp        = "";
            DatosPDF.NoExt_Emp        = "";
            DatosPDF.NoInt_Emp        = "";
            DatosPDF.Col_Emp          = "";
            DatosPDF.CD_Emp           = "";
            DatosPDF.CP_Emp           = "";
            DatosPDF.Edo_Emp          = "";
            DatosPDF.NomRep_Emp       = "";
            DatosPDF.RFCRep_Emp       = "";
            DatosPDF.CURPRep_Emp      = "";

            if (Anno < 2008 || Anno > 2012)
            {
                ArchivoConstancia.Datos    = null;
                ArchivoConstancia.MsjError = "Año fuera de los parámetros: " + Anno.ToString();

                return(ArchivoConstancia);
            }

            //OperacionesBD.HerramientasOracle tool = new OperacionesBD.HerramientasOracle(ConfigurationManager.AppSettings["Usuario"],
            //                                           ConfigurationManager.AppSettings["Pass"],
            //                                           ConfigurationManager.AppSettings["Host"],
            //                                           ConfigurationManager.AppSettings["Service"],
            //                                           ConfigurationManager.AppSettings["Port"],
            //                                           ConfigurationManager.AppSettings["Protocol"]);
            clsDatos  tool      = new clsDatos();
            Doc       theDoc    = new Doc();
            DataTable Registros = new DataTable();

            BanProc = false;
            string sHTML = string.Empty;
            string sSQL  = string.Empty;

            ArchivoConstancia.MsjError = "";
            //ArchivoConstancia.ProcesoCorrecto = false;
            ArchivoConstancia.Datos = null;
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);
            Registros = tool.EjecutaLectura(Scripts.Constancias_DatosDeClienteXPrestamo);

            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sNumeroId  = Registros.Rows[0]["NUMERO_IDENTIFICACION"].ToString();
                    DatosPDF.sCurp      = Registros.Rows[0]["CURP"].ToString();
                    DatosPDF.sNombreCom = Registros.Rows[0]["NOMBRE_COMPLETO"].ToString();
                    DatosPDF.sNombres   = Registros.Rows[0]["NOMBRES"].ToString();
                    DatosPDF.sPrimerAp  = Registros.Rows[0]["PRIMER_APELLIDO"].ToString();
                    DatosPDF.sSegundoAp = Registros.Rows[0]["SEGUNDO_APELLIDO"].ToString();
                    BanProc             = true;
                }
                else
                {
                    RegistraError("Constancias_DatosDeClienteXPrestamo", "Error en consulta Constancias_DatosDeClienteXPrestamo", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }
            else
            {
                RegistraError("Constancias_DatosDeClienteXPrestamo", "Error en consulta Constancias_DatosDeClienteXPrestamo", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
            }

            if (!BanProc)
            {
                RegistraError("GenerarPDF", "Proceso interrumpido", "Se detiene proceso para el préstamo " + Numero_Prestamo.ToString() + " por no cumplir todas las validaciones correspondientes. Punto de revisión: Constancias_DatosDeClienteXPrestamo", Fila, Numero_Prestamo.ToString());
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }

            Registros = new DataTable();
            tool.LimpiaParametros();
            BanProc = false;
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);
            Registros = tool.EjecutaLectura(Scripts.Constancias_DatosDeGarantiaXPrestamo);

            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sNOMENCLATURA = Registros.Rows[0]["NOMENCLATURA"].ToString();
                    DatosPDF.sCodigoBar    = Registros.Rows[0]["CODIGO_BARRIO"].ToString();
                    DatosPDF.sCodigoMun    = Registros.Rows[0]["NOMBRE_MUN"].ToString();
                    DatosPDF.sCodigoSec    = Registros.Rows[0]["DESCRIPCION"].ToString();
                    DatosPDF.sCodigodep    = Registros.Rows[0]["NOMBRE_DEP"].ToString();
                    DatosPDF.sCP           = Registros.Rows[0]["CODIGO_POSTAL"].ToString();
                    BanProc = true;
                }
                else
                {
                    RegistraError("Constancias_DatosDeGarantiaXPrestamo", "Error en consulta Constancias_DatosDeGarantiaXPrestamo", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }
            else
            {
                RegistraError("Constancias_DatosDeGarantiaXPrestamo", "Error en consulta Constancias_DatosDeGarantiaXPrestamo", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
            }

            if (!BanProc)
            {
                RegistraError("GenerarPDF", "Proceso interrumpido", "Se detiene proceso para el préstamo " + Numero_Prestamo.ToString() + " por no cumplir todas las validaciones correspondientes. Punto de revisión: Constancias_DatosDeGarantiaXPrestamo", Fila, Numero_Prestamo.ToString());
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }

            Registros = new DataTable();
            tool.LimpiaParametros();
            BanProc = false;
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);
            Registros = tool.EjecutaLectura(Scripts.Constancias_DireccionGarantiaXPrestamo);

            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sUbicacionFisGa = Registros.Rows[0]["UBICACION_FISICA"].ToString();
                    DatosPDF.scodigobarrioga = Registros.Rows[0]["COLONIA"].ToString();
                    DatosPDF.scodigomuniga   = Registros.Rows[0]["MUNICIPIO"].ToString();
                    DatosPDF.scodigosectorga = Registros.Rows[0]["NOMBRE_SECTOR"].ToString();
                    DatosPDF.scodigodepga    = Registros.Rows[0]["ESTADO"].ToString();
                    DatosPDF.scpga           = Registros.Rows[0]["CODIGO_POSTAL"].ToString();
                    DatosPDF.sEstado         = Registros.Rows[0]["ESTADO_PRESTAMO"].ToString();
                    BanProc = true;
                }
                else
                {
                    RegistraError("Constancias_DireccionGarantiaXPrestamo", "Error en consulta Constancias_DireccionGarantiaXPrestamo", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }
            else
            {
                RegistraError("Constancias_DireccionGarantiaXPrestamo", "Error en consulta Constancias_DireccionGarantiaXPrestamo", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
            }

            if (!BanProc)
            {
                RegistraError("GenerarPDF", "Proceso interrumpido", "Se detiene proceso para el préstamo " + Numero_Prestamo.ToString() + " por no cumplir todas las validaciones correspondientes. Punto de revisión: Constancias_DireccionGarantiaXPrestamo", Fila, Numero_Prestamo.ToString());
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }

            Registros = new DataTable();
            tool.LimpiaParametros();
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);
            Registros = tool.EjecutaLectura(Scripts.Constancias_DatosDeCoacreditadoXPrestamo);

            //No es un requerimiento obligatorio obtener estos datos
            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sNombreComCoa = Registros.Rows[0]["NOMBRE_COMPLETO"].ToString();
                    DatosPDF.sNombresCoa   = Registros.Rows[0]["NOMBRES"].ToString();
                    DatosPDF.sPrimerApCoa  = Registros.Rows[0]["PRIMER_APELLIDO"].ToString();
                    DatosPDF.sSegundoApCoa = Registros.Rows[0]["SEGUNDO_APELLIDO"].ToString();
                    DatosPDF.sNumeroIdCoa  = Registros.Rows[0]["NUMERO_IDENTIFICACION"].ToString();
                    DatosPDF.sCurpCoa      = Registros.Rows[0]["CURP"].ToString();
                }
                else
                {
                    RegistraError("Constancias_DatosDeCoacreditadoXPrestamo", "Error en consulta Constancias_DatosDeCoacreditadoXPrestamo", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }

            Registros = new DataTable();
            tool.LimpiaParametros();
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);
            Registros = tool.EjecutaLectura(Scripts.Constancias_DatosDeGarantiaXPrestamoXCoacreditado);

            //No es un requerimiento obligatorio obtener estos datos
            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sNOMENCLATURACoa = Registros.Rows[0]["NOMENCLATURA"].ToString();
                    DatosPDF.sCodigoBarCoa    = Registros.Rows[0]["CODIGO_BARRIO"].ToString();
                    DatosPDF.sCodigoMunCoa    = Registros.Rows[0]["NOMBRE_MUN"].ToString();
                    DatosPDF.sCodigoSecCoa    = Registros.Rows[0]["DESCRIPCION"].ToString();
                    DatosPDF.sCodigoDepCoa    = Registros.Rows[0]["NOMBRE_DEP"].ToString();
                    DatosPDF.sCpCoa           = Registros.Rows[0]["CODIGO_POSTAL"].ToString();
                }
                else
                {
                    RegistraError("Constancias_DatosDeGarantiaXPrestamoXCoacreditado", "Error en consulta Constancias_DatosDeGarantiaXPrestamoXCoacreditado", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }

            string direccionGar = "";

            string[] valoresGar = null;
            Registros = new DataTable();
            tool.LimpiaParametros();
            BanProc = false;
            tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);

            if (Forzar)
            {
                Registros = tool.EjecutaLectura(Scripts.Constancias_HSCConstancias.Replace("@@Anno", Anno.ToString()).Replace("AND Imprimir = 'S'", ""));
            }
            else
            {
                if (Anno > 2008)
                {
                    Registros = tool.EjecutaLectura(Scripts.Constancias_HSCConstancias.Replace("@@Anno", Anno.ToString()));
                }
                else if (Anno == 2008)
                {
                    Registros = tool.EjecutaLectura(Scripts.Constancias_HSCConstancias.Replace("@@Anno", Anno.ToString()).Replace("AND Imprimir = 'S'", ""));
                }
            }

            if (Registros != null && Registros.Rows.Count > 0)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.sIntNomPag    = (Convert.ToDecimal(Registros.Rows[0]["INTNOMPAG"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sINTNOMDEV    = (Convert.ToDecimal(Registros.Rows[0]["INTNOMDEV"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sINTNOMPAG    = Registros.Rows[0]["INTNOMPAG"].ToString();
                    DatosPDF.sMONTOCRED    = (Convert.ToDecimal(Registros.Rows[0]["MONTOCRED"].ToString())).ToString("###,###,##0.00");
                    DatosPDF.sINTREAL      = (Convert.ToDecimal(Registros.Rows[0]["INTREAL"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sMONTOCRED_C2 = (Convert.ToDecimal(Registros.Rows[0]["MONTOCRED"].ToString())).ToString("###,###,##0.00");
                    DatosPDF.sINTNOMDEV_C2 = (Convert.ToDecimal(Registros.Rows[0]["INTNOMDEV"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sINTNOMPAG_C2 = (Convert.ToDecimal(Registros.Rows[0]["INTNOMPAG"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sINTREAL_C2   = (Convert.ToDecimal(Registros.Rows[0]["INTREAL"].ToString()) * Porcentaje / 100).ToString("###,###,##0.00");
                    DatosPDF.sMES_INI      = Registros.Rows[0]["MES_INI"].ToString();
                    DatosPDF.sMES_FIN      = Registros.Rows[0]["MES_FIN"].ToString();
                    DatosPDF.sCVE_MONEDA   = Registros.Rows[0]["CVE_MONEDA"].ToString();
                    DatosPDF.sEjercicio    = Registros.Rows[0]["EJERCICIO"].ToString();
                    DatosPDF.sjudicial     = Registros.Rows[0]["JUDICIAL"].ToString();
                    DatosPDF.sBaseJit      = Registros.Rows[0]["BASEJIT"].ToString();

                    direccionGar = Registros.Rows[0]["DIRECCION_GAR"].ToString().Trim();
                    valoresGar   = direccionGar.Split('?');

                    if (valoresGar.Length == 6 && (DatosPDF.sEstado != "1" && DatosPDF.sEstado != "6" && DatosPDF.sEstado != "9"))
                    {
                        DatosPDF.sUbicacionFisGa = valoresGar[0];
                        DatosPDF.scodigobarrioga = valoresGar[1];
                        DatosPDF.scodigomuniga   = valoresGar[2];
                        DatosPDF.scodigosectorga = valoresGar[3];
                        DatosPDF.scodigodepga    = valoresGar[4];
                        DatosPDF.scpga           = valoresGar[5];
                    }

                    BanProc = true;
                }
                else
                {
                    RegistraError("Constancias_HSCConstancias", "Error en consulta Constancias_HSCConstancias", "Préstamo:" + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }
            }
            else
            {
                Registros = new DataTable();
                tool.LimpiaParametros();
                BanProc = false;
                tool.CreaParametro("@Numero_Prestamo", Numero_Prestamo, SqlDbType.Int);

                if (Anno > 2008)
                {
                    Registros = tool.EjecutaLectura(Scripts.Constancias_HSCConstancias_Error.Replace("@@Anno", Anno.ToString()));
                }
                else if (Anno == 2008)
                {
                    Registros = tool.EjecutaLectura(Scripts.Constancias_HSCConstancias2_Error.Replace("@@Anno", Anno.ToString()));
                }

                if (Registros != null && Registros.Rows.Count > 0)
                {
                    if (Registros.TableName != "Error")
                    {
                        if (Registros.Rows[0][0].ToString().Trim() != "")
                        {
                            RegistraError("Constancias_HSCConstancias_Error", "Error en consulta Constancias_HSCConstancias_Error", Registros.Rows[0][0].ToString().Trim() + ". Préstamo: " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
                            ArchivoConstancia.MsjError = Errores;
                            return(ArchivoConstancia);
                        }
                        else
                        {
                            RegistraError("Constancias_HSCConstancias_Error", "Error en consulta Constancias_HSCConstancias_Error", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
                        }
                    }
                    else
                    {
                        RegistraError("Constancias_HSCConstancias_Error", "Error en consulta Constancias_HSCConstancias_Error", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
                    }
                }
                else
                {
                    RegistraError("Constancias_HSCConstancias_Error", "Error en consulta Constancias_HSCConstancias_Error", "No se obtuvieron los datos para el préstamo " + Numero_Prestamo.ToString(), Fila, Numero_Prestamo.ToString());
                }

                NoAplica = false; //Cambiar a true si se desea que en caso de no tener datos se genere con la leyenda: ESTE CRÉDITO NO TIENE CONSTANCIA DE DEDUCIBILIDAD PARA ESTE EJERCICIO
            }

            if (!BanProc && !NoAplica)
            {
                RegistraError("GenerarPDF", "Proceso interrumpido", "Se detiene proceso para el préstamo " + Numero_Prestamo.ToString() + " por no cumplir todas las validaciones correspondientes. Punto de revisión: Constancias_HSCConstancias", Fila, Numero_Prestamo.ToString());
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }

            theDoc.TopDown = true;
            theDoc.Units   = "mm";
            theDoc.Font    = theDoc.AddFont("Arial");
            theDoc.TextStyle.LineSpacing = 1.1;
            theDoc.TextStyle.CharSpacing = -.1;

            //********************************************************TITULO
            theDoc.Rect.String = "55 11 200 25";
            sHTML += "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += "CONSTANCIA ANUAL DE INTERESES DEVENGADOS Y PAGADOS DE CREDITOS<br>";
            sHTML += "HIPOTECARIOS DESTINADOS A CASA HABITACIÓN";
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            XImage theImg2 = new XImage();

            theImg2.SetFile(Server.MapPath("Images") + "/logo azul small.jpg"); //ODES
            theDoc.Rect.Bottom = 30;
            theDoc.Rect.Left   = 10;
            theDoc.Rect.Width  = 33.7;
            theDoc.Rect.Height = 20.3;
            theDoc.AddImageObject(theImg2, false);

            theDoc.Rect.String = "55 21 200 35";
            sHTML  = "<p align='center'><font size='1' face='Arial'>";
            sHTML += "La presente Constancia se emite de conformidad con lo establecido en los articulos 176 fracción IV y 227 de la Ley del<br>";
            sHTML += "Impuesto Sobre la Renta y del reglamento de la Ley del Impuesto Sobre la Renta, respectivamente.";
            sHTML += "</font></p>";
            theDoc.AddHtml(sHTML);

            //PERIODO Y CREDITO
            theDoc.Rect.String = "134 30 200 60";
            sHTML  = "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += "Periodo que ampara la Constancia<br>";
            sHTML += "<b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String = "134 35 200 40";
            theDoc.FrameRect(2, 2);
            sHTML  = "<p align='center'><font size='2' face='Arial'>";
            sHTML += "Mes Inicial &nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp; Mes Final  &nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp; Ejercicio <br>";
            sHTML += "</font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String = "140 41 155 48";
            sHTML  = "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += DatosPDF.sMES_INI;
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String = "195 41 140 48";
            sHTML  = "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += DatosPDF.sMES_FIN;
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String = "205 41 170 48";
            sHTML  = "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += DatosPDF.sEjercicio;
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String  = "100 55 200 60";
            theDoc.Color.String = "255 255 255";
            theDoc.Color.String = "0 0 0";
            sHTML  = "<p align='center'><font size='2' face='Arial'><b>";
            sHTML += "No. de Prestamo";
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String = "134 60 200 65";
            theDoc.FrameRect(2, 2);
            theDoc.Color.String = "0 0 0";
            sHTML  = "<p align='center'><font size='3' face='Arial'><b>";
            sHTML += Numero_Prestamo.ToString();
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            //DATOS DEL DEUDOR
            theDoc.Rect.String    = "10 39 205 162";
            theDoc.TextStyle.Size = 2.5;
            string sNomenc1 = "";
            string sNomenc2 = "";
            int    iLen     = 0;

            if ((int)tipoPDF == 1)
            {
                sHTML    = DatosPDF.sNombres + ' ' + DatosPDF.sPrimerAp + ' ' + DatosPDF.sSegundoAp;
                sNomenc1 = DatosPDF.sNOMENCLATURA;
            }
            else
            {
                sNomenc1 = DatosPDF.sNOMENCLATURACoa;
                sHTML    = DatosPDF.sNombreComCoa;
            }

            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "10 43 205 162";
            theDoc.TextStyle.Size = 2.5;
            theDoc.TextStyle.Bold = false;

            if (sNomenc1.Length > 75)
            {
                iLen = sNomenc1.IndexOf(" ", 60);

                if (iLen >= 0)
                {
                    sNomenc2 = sNomenc1.Substring(iLen, sNomenc1.Length - iLen).Trim();
                    sNomenc1 = sNomenc1.Substring(0, iLen);
                }
            }

            sHTML = sNomenc1 + "<br>";

            if (sNomenc2 != "")
            {
                sHTML += sNomenc2 + "<br>";
            }

            if ((int)tipoPDF == 1)
            {
                sHTML += DatosPDF.sCodigoBar + "<br>";
                sHTML += DatosPDF.sCodigoMun + ", " + DatosPDF.sCodigoSec + "<br>";
                sHTML += DatosPDF.sCodigodep + " " + ". C.P. " + DatosPDF.sCP + "<br>";
            }
            else
            {
                sHTML += DatosPDF.sCodigoBarCoa + "<br>";
                sHTML += DatosPDF.sCodigoMunCoa + ", " + DatosPDF.sCodigoSecCoa + "<br>";
                sHTML += DatosPDF.sCodigoDepCoa + " " + ". C.P. " + DatosPDF.sCpCoa + "<br>";
            }

            theDoc.AddHtml(sHTML);

            theDoc.Rect.String    = "138 65 200 70 ";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = true;
            sHTML = "R.F.C.";
            theDoc.AddText(sHTML);

            theDoc.Rect.String = "134 70 200 75";
            theDoc.FrameRect(2, 2);
            theDoc.TextStyle.Bold = true;
            theDoc.Color.String   = "0 0 0";
            sHTML = "<p align='center'><font size='2' face='Arial'><b>";

            if ((int)tipoPDF == 1)
            {
                sHTML += DatosPDF.sNumeroId;
            }
            else
            {
                sHTML += DatosPDF.sNumeroIdCoa;
            }

            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            //DATOS DEL CREDITO
            theDoc.Rect.String  = "28 78 190 116";
            theDoc.Color.String = "255 255 255";
            theDoc.FillRect();
            theDoc.FrameRect();
            theDoc.Color.String = "0 0 0";
            sHTML  = "<p align='center'><font size='3' face='Arial'><b>";
            sHTML += "DATOS DEL CRÉDITO";
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Color.String = "0 0 0";
            theDoc.Rect.String  = "10 116 205 163";
            theDoc.AddLine(15, 83, 200, 83);

            theDoc.Rect.String    = "15 86 205 162";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = false;
            sHTML = "Domicilio de la Garantía:";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "15 92 205 162";
            theDoc.TextStyle.Size = 2.5;
            theDoc.TextStyle.Bold = false;

            if (DatosPDF.sUbicacionFisGa.Length > 78)
            {
                string   sAux        = string.Empty;
                string[] arrPalabras = DatosPDF.sUbicacionFisGa.Split(' ');
                DatosPDF.sUbicacionFisGa = arrPalabras[0];
                int i = 1;

                while (DatosPDF.sUbicacionFisGa.Length < 70)
                {
                    DatosPDF.sUbicacionFisGa = DatosPDF.sUbicacionFisGa + " " + arrPalabras[i];
                    i++;
                }

                if (arrPalabras.Length < i)
                {
                    sAux = arrPalabras[i];
                    while (sAux.Length < 70 && i < arrPalabras.Length)
                    {
                        sAux = sAux + " " + arrPalabras[i];
                        i++;
                    }
                }

                sHTML  = DatosPDF.sUbicacionFisGa + "<br>";
                sHTML += sAux + "<br>";
            }
            else
            {
                sHTML = DatosPDF.sUbicacionFisGa + "<br>";
            }

            sHTML += DatosPDF.scodigobarrioga + "<br>";
            sHTML += DatosPDF.scodigomuniga + ", " + DatosPDF.scodigosectorga + "<br>";
            sHTML += DatosPDF.scodigodepga + " " + ". C.P. " + DatosPDF.scpga + "<br>";
            theDoc.AddHtml(sHTML);

            theDoc.Rect.String    = "135 86 205 162";
            theDoc.TextStyle.Size = 3;
            sHTML = "Denominación:";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "165 86 205 162";
            theDoc.TextStyle.Size = 3.5;
            theDoc.TextStyle.Bold = true;

            switch (DatosPDF.sCVE_MONEDA)
            {
            case "1":
                sHTML = "PESOS";
                break;

            case "2":
                sHTML = "DOLARES";
                break;

            case "3":
                sHTML = "UDIS";
                break;

            case "4":
                sHTML = "SALARIOS MINIMOS";
                break;
            }

            theDoc.AddText(sHTML);
            theDoc.Rect.String    = "135 95 205 180";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = false;
            sHTML  = "Saldo Insoluto al <br>";
            sHTML += "31 de diciembre de " + Anno.ToString();
            theDoc.AddHtml(sHTML);
            theDoc.Rect.String    = "175 99 205 162";
            theDoc.TextStyle.Size = 3.5;
            theDoc.TextStyle.Bold = true;

            if ((int)tipoPDF == 1)
            {
                sHTML = DatosPDF.sMONTOCRED;
            }
            else
            {
                sHTML = DatosPDF.sMONTOCRED_C2;
            }

            if (DatosPDF.sCVE_MONEDA == "UDI")
            {
                sHTML += " UDIS";
            }

            theDoc.AddText(sHTML);

            //INFORMATIVO DE INTERESES
            theDoc.Rect.String  = "10 112 210 162";
            theDoc.Color.String = "255 255 255";
            theDoc.FillRect();
            theDoc.FrameRect();
            theDoc.Color.String = "0 0 0";
            sHTML  = "<p align='center'><font size='3' face='Arial'><b>";
            sHTML += "INFORMATIVO DE INTERESES EN EL EJERCICIO";
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Color.String = "0 0 0";
            theDoc.Rect.String  = "10 150 205 163";
            theDoc.AddLine(15, 117, 205, 117);

            theDoc.Rect.String    = "15 120 205 262";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = false;
            sHTML = "Intereses Nominales Devengados";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "60 120 115 262";
            theDoc.TextStyle.Size = 3.5;
            theDoc.TextStyle.Bold = true;

            if ((int)tipoPDF == 1)
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sINTNOMDEV;
            }
            else
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sINTNOMDEV_C2;
            }

            theDoc.AddHtml(sHTML);

            theDoc.Rect.String    = "15 127 205 262";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = false;
            sHTML = "Intereses Nominales Pagados en el Ejercicio";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "60 127 115 262";
            theDoc.TextStyle.Size = 3.5;
            theDoc.TextStyle.Bold = true;

            if ((int)tipoPDF == 1)
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sIntNomPag;
            }
            else
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sINTNOMPAG_C2;
            }

            theDoc.AddHtml(sHTML);

            theDoc.Rect.String    = "15 134 205 262";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = false;
            sHTML = "Intereses Reales Pagados en el Ejercicio";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "60 134 115 262";
            theDoc.TextStyle.Size = 3.5;
            theDoc.TextStyle.Bold = true;

            if ((int)tipoPDF == 1)
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sINTREAL;
            }
            else
            {
                sHTML = "<p align='right'><font size='3' face='Arial'>" + DatosPDF.sINTREAL_C2;
            }

            theDoc.AddHtml(sHTML);

            //DATOS DEL ACREEDOR
            theDoc.Rect.String  = "20 142  99 200";
            theDoc.Color.String = "255 255 255";
            theDoc.FillRect();
            theDoc.FrameRect();
            theDoc.Color.String = "0 0 0";
            sHTML  = "<p align='center'><font size='3' face='Arial'><b>";
            sHTML += "DATOS DEL ACREEDOR HIPOTECARIO";
            sHTML += "</b></font></p>";
            theDoc.AddHtml(sHTML);

            theDoc.Color.String = "0 0 0";
            theDoc.Rect.String  = "15 148 104 200";
            theDoc.FrameRect(2, 2);

            theDoc.Rect.String    = "17 188 205 262";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = true;
            sHTML = "RFC:";
            theDoc.AddText(sHTML);

            theDoc.Rect.String    = "28 188 205 262";
            theDoc.TextStyle.Size = 3;
            theDoc.TextStyle.Bold = true;

            //OBTENEMOS LOS DATOS DE LAS HIPOTECARIAS
            Registros = new DataTable();
            tool.LimpiaParametros();
            BanProc = false;
            tool.CreaParametro("@sBaseJit", DatosPDF.sBaseJit, SqlDbType.VarChar, 4000);
            Registros = tool.EjecutaLectura(Scripts.Constancias_EmpresasSiglasEmp);

            if (Registros != null && Registros.Rows.Count > 0 && !NoAplica)
            {
                if (Registros.TableName != "Error")
                {
                    DatosPDF.RFC_Emp      = Registros.Rows[0]["RFC"].ToString();
                    DatosPDF.RazonSoc_Emp = Registros.Rows[0]["RAZON_SOC2"].ToString();
                    DatosPDF.Calle_Emp    = Registros.Rows[0]["CALLE"].ToString();
                    DatosPDF.NoExt_Emp    = Registros.Rows[0]["NOEXT"].ToString();
                    DatosPDF.NoInt_Emp    = Registros.Rows[0]["NOINT"].ToString();
                    DatosPDF.Col_Emp      = Registros.Rows[0]["COLONIA"].ToString();
                    DatosPDF.CD_Emp       = Registros.Rows[0]["CIUDAD"].ToString();
                    DatosPDF.CP_Emp       = Registros.Rows[0]["CODPOS"].ToString();
                    DatosPDF.Edo_Emp      = Registros.Rows[0]["ESTADO"].ToString();
                    DatosPDF.NomRep_Emp   = Registros.Rows[0]["NOM_REPRESENTANTE"].ToString();
                    DatosPDF.RFCRep_Emp   = Registros.Rows[0]["RFC_REPRESENTANTE"].ToString();
                    DatosPDF.CURPRep_Emp  = Registros.Rows[0]["CURP_REPRESENTANTE"].ToString();
                    BanProc = true;
                }
                else
                {
                    RegistraError("Constancias_EmpresasSiglasEmp", "Error en consulta Constancias_EmpresasSiglasEmp", "Préstamo: " + Numero_Prestamo.ToString() + ". Error: " + Registros.Rows[0][0].ToString(), Fila, Numero_Prestamo.ToString());
                }

                if (!BanProc)
                {
                    theDoc.TopDown = true;
                    theDoc.Units   = "mm";
                    theDoc.Font    = theDoc.AddFont("Arial");
                    theDoc.TextStyle.LineSpacing = 1.1;
                    theDoc.TextStyle.CharSpacing = -.1;

                    //TITULO
                    theDoc.Rect.String = "16 180 200 25";
                    sHTML += "<br><br><br><br><br><br><br><br><br><p align='center'><font size='38' face='Arial'><b>";
                    sHTML += "ESTE CRÉDITO NO TIENE CONSTANCIA <br>";
                    sHTML += "DE DEDUCIBILIDAD PARA ESTE EJERCICIO";
                    sHTML += "</b></font></p>";
                    theDoc.AddHtml(sHTML);

                    //byte[] theData = theDoc.GetData();
                    //theDoc.Save(fbd01.SelectedPath + "\\" + Numero_Prestamo.ToString() + "_" + Anno.ToString() + ".pdf");
                    ArchivoConstancia.Datos    = theDoc.GetData();
                    ArchivoConstancia.MsjError = Errores;
                    return(ArchivoConstancia);
                }

                sHTML = DatosPDF.RFC_Emp + " ";
                theDoc.AddText(sHTML);

                theDoc.Rect.String    = "17 155 205 300";
                theDoc.TextStyle.Size = 3;
                theDoc.TextStyle.Bold = true;

                string sNomenc3 = "";
                string sNomenc4 = "";
                int    iLen1    = 0;

                sNomenc3 = DatosPDF.RazonSoc_Emp;

                if (sNomenc3.Length > 75)
                {
                    iLen1    = sNomenc3.IndexOf(" ", 65);
                    sNomenc4 = sNomenc3.Substring(iLen1, sNomenc3.Length - iLen1).Trim();
                    sNomenc3 = sNomenc3.Substring(0, iLen1);
                }

                sHTML = sNomenc3 + "<br>";

                if (sNomenc4 != "")
                {
                    sHTML += sNomenc4 + "<br>";
                }

                theDoc.AddHtml(sHTML);

                theDoc.TextStyle.LineSpacing = 1.1;
                theDoc.TextStyle.WordSpacing = 0;

                theDoc.Rect.String    = "17 168 205 262";
                theDoc.TextStyle.Size = 3;
                sHTML  = DatosPDF.Calle_Emp + " No." + DatosPDF.NoExt_Emp + ", " + DatosPDF.NoInt_Emp + "<br>";
                sHTML += "Col. " + DatosPDF.Col_Emp + "<br>";
                sHTML += DatosPDF.CD_Emp + ", " + DatosPDF.Edo_Emp + ", C.P." + DatosPDF.CP_Emp + "<br>";

                theDoc.AddHtml(sHTML);

                //DATOS DEL REPRESENTANTE
                theDoc.Rect.String  = "220 142 105 190";
                theDoc.Color.String = "255 255 255";
                theDoc.FillRect();
                theDoc.FrameRect();
                theDoc.Color.String = "0 0 0";
                sHTML  = "<p align='center'><font size='3' face='Arial'><b>";
                sHTML += "DATOS DEL REPRESENTANTE LEGAL";
                sHTML += "</b></font></p>";
                theDoc.AddHtml(sHTML);

                theDoc.Color.String = "0 0 0";
                theDoc.Rect.String  = "205 148 119 200";
                theDoc.FrameRect(2, 2);

                theDoc.Rect.String    = "123 165 205 262";
                theDoc.TextStyle.Size = 3;
                theDoc.TextStyle.Bold = false;
                sHTML = "RFC:";
                theDoc.AddText(sHTML);

                theDoc.Rect.String    = "140 165 205 262";
                theDoc.TextStyle.Size = 3;
                sHTML = DatosPDF.RFCRep_Emp;

                theDoc.AddText(sHTML);

                theDoc.Rect.String    = "123 173 205 262";
                theDoc.TextStyle.Size = 3;
                sHTML = "CURP:";
                theDoc.AddText(sHTML);

                theDoc.Rect.String    = "140 173 205 262";
                theDoc.TextStyle.Size = 3;
                sHTML = DatosPDF.CURPRep_Emp;

                theDoc.AddText(sHTML);

                theDoc.Rect.String    = "123 155 195 170";
                theDoc.TextStyle.Size = 3;
                //theDoc.TextStyle.Bold = true;
                sHTML = DatosPDF.NomRep_Emp;

                theDoc.AddHtml(sHTML);

                //PIE DE PAGINA
                theDoc.Rect.String             = "48 234 205 275";
                theDoc.Color.String            = "0 0 0";
                theDoc.TextStyle.LineSpacing   = 1;
                theDoc.TextStyle.ParaSpacing   = -1;
                theDoc.TextStyle.Justification = 1;
                sHTML  = "<font size='2' face='Arial'><p>";
                sHTML += "L0S DATOS CONTENIDOS EN ESTA CONSTANCIA SERÁN COTEJADOS CON LA INFORMACIÓN QUE OBRA ";
                sHTML += "EN PODER DE LA AUTORIDAD FISCAL, CUANDO SE UTILICE COMO DEDUCCIÓN PERSONAL EN LA ";
                sHTML += "DECLARACIÓN ANUAL DE LAS PERSONAS FISICAS.</p>";
                sHTML += "<p>PARA CUALQUIER ACLARACIÓN O INFORMACIÓN REFERENTE A ESTA CONSTANCIA, FAVOR DE ";
                sHTML += "COMUNICARSE AL 01 800 712 1212";
                sHTML += "</p></font>";
                theDoc.AddHtml(sHTML);

                //IMAGEN DEL RFC
                XImage theImg = new XImage();

                switch (DatosPDF.sBaseJit.Trim())
                {
                case "HSC":
                    theImg.SetFile(Server.MapPath("Images") + "/RFC_HSC_2008.jpg");     //ODES
                    theDoc.Rect.Bottom = 259;
                    theDoc.Rect.Left   = 15;
                    theDoc.Rect.Width  = 27.7;   //theImg.Width / 7;
                    theDoc.Rect.Height = 51.4;   //theImg.Height / 7;
                    break;

                case "SHF":
                    theImg.SetFile(Server.MapPath("Images") + "/RFC_SHF.jpg");     //ODES
                    theDoc.Rect.Bottom = 259;
                    theDoc.Rect.Left   = 15;
                    theDoc.Rect.Width  = 28.4;   //theImg.Width / 6.8;
                    theDoc.Rect.Height = 52.2;   //theImg.Height / 6.8;
                    break;

                case "GMAC":
                    theImg.SetFile(Server.MapPath("Images") + "/RFC_GMAC_2008.jpg");     //ODES
                    theDoc.Rect.Bottom = 259;
                    theDoc.Rect.Left   = 15;
                    theDoc.Rect.Width  = 28.2;   //theImg.Width / 11.3;
                    theDoc.Rect.Height = 52.2;   //theImg.Height / 11.3;
                    break;
                }

                theDoc.AddImageObject(theImg, false);

                //theDoc.Save(fbd01.SelectedPath + "\\" + Numero_Prestamo.ToString() + "_" + Anno.ToString() + ".pdf");
                ArchivoConstancia.Datos    = theDoc.GetData();
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }
            else
            {
                theDoc.TopDown = true;
                theDoc.Units   = "mm";
                theDoc.Font    = theDoc.AddFont("Arial");
                theDoc.TextStyle.LineSpacing = 1.1;
                theDoc.TextStyle.CharSpacing = -.1;

                //********************************************************TITULO
                theDoc.Rect.String = "16 180 200 25";
                sHTML += "<br><br><br><br><br><br><br><br><br><p align='center'><font size='38' face='Arial'><b>";
                sHTML += "ESTE CRÉDITO NO TIENE CONSTANCIA <br>";
                sHTML += "DE DEDUCIBILIDAD PARA ESTE EJERCICIO";
                sHTML += "</b></font></p>";
                theDoc.AddHtml(sHTML);

                //theDoc.Save(fbd01.SelectedPath + "\\" + Numero_Prestamo.ToString() + "_" + Anno.ToString() + ".pdf");
                ArchivoConstancia.Datos    = theDoc.GetData();
                ArchivoConstancia.MsjError = Errores;
                return(ArchivoConstancia);
            }

            //MessageBox.Show("Ya");
        }