예제 #1
0
        private void createButton1_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            List <Group> groups = new List <Group>();

            for (int i = 1; i < 4; i++)
            {
                groups.Add(props.AddGroup("Layer " + i.ToString(), null));
            }
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            for (int i = 0; i < 1; i++)
            {
                doc.Page = doc.AddPage();
                Page   page   = (Page)doc.ObjectSoup[doc.Page];
                Writer writer = new Writer(props, page);
                foreach (Group group in groups)
                {
                    OptionalContent.Layer layer = writer.AddGroup(group);
                    writer.StartLayer(layer);
                    doc.AddText(group.EntryName.Text + "\r\n");
                    writer.EndLayer();
                    doc.AddText("Always Visible\r\n");
                    writer.StartLayer(layer);
                    doc.AddText(group.EntryName.Text + "\r\n\r\n");
                    writer.EndLayer();
                }
                doc.Flatten();
            }
            LoadPDF(doc);
        }
예제 #2
0
        public override float Draw(float _curY)
        {
            float     curY = _curY, curX = 100;
            Rectangle rect = Doc.AddRectange(10, curY - 15, doc.PageSize.Width - 10, curY, PDFColor.BCGGreen);

            curY = Doc.AddText(rect, config.MainQuestion, BaseColor.WHITE) + 10;

            rect = new Rectangle(rect.Left, curY - 15, 300, curY);
            curY = doc.AddText(rect.OffSetRectByYAxis(15), config.SubQuestions, PDFColor.BCGBlack);

            if (config.OverAll != null)
            {
                rect = doc.AddRectange(rect.Left, curY - 25, 300, curY - 10, PDFColor.BCGGreen);
                Rectangle rRect = new Rectangle(125, rect.Top, 125 + 25, rect.Bottom);

                curY = doc.AddText(rect, "Overall", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX), "NA", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 35), "1", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "2", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "3", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "4", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "5", BaseColor.WHITE);

                doc.AddRadioGroup(config.OverAll, rRect, new List <String> {
                    "NA", "1", "2", "3", "4", "5"
                }, 25);
            }

            if (config.Comments != null)
            {
                doc.AddTextField(config.Comments,
                                 new Rectangle(300, _curY - 15, doc.PageSize.Width - 10, curY + 5));
            }
            return(curY);
        }
예제 #3
0
        private void annotateButton_Click(object sender, EventArgs e)
        {
            if (_doc == null)
            {
                return;
            }
            Properties props = Properties.FromDoc(_doc, false);

            foreach (Page page in _doc.ObjectSoup.Catalog.Pages.GetPageArrayAll())
            {
                Reader        oc = Reader.FromPage(props, page);
                TextOperation op = new TextOperation(_doc);
                op.PageContents.AddPages();
                string text = op.GetText();
                IList <TextFragment> fragments = op.Select(0, text.Length);
                _doc.FontSize = 12;
                _doc.Width    = 0.1;
                foreach (TextFragment fragment in fragments)
                {
                    _doc.Rect.String = fragment.Rect.String;
                    List <OptionalContent.Layer> states = oc.GetLayersFromStreamAndPosition(fragment.StreamID, fragment.StreamOffset);
                    string[] names = new string[states.Count];
                    for (int i = 0; i < names.Length; i++)
                    {
                        names[i] = states[i].Group != null ? states[i].Group.EntryName.Text : "Membership Dictionary";
                    }
                    if (names.Length > 0)
                    {
                        _doc.AddText(string.Join(" ", names));
                    }
                    _doc.FrameRect();
                }
            }
            UpdatePreview();
        }
예제 #4
0
        public override float Draw(float curY)
        {
            float start = curY;

            Rectangle rect = Doc.AddRectange(10, curY - 15, doc.PageSize.Width - 10, curY, PDFColor.BCGGreen);

            curY = Doc.AddText(rect, config.MainQuestion, BaseColor.WHITE) + 10;

            rect = new Rectangle(rect.Left, curY - 15, 300, curY);
            curY = doc.AddText(rect.OffSetRectByYAxis(15), config.SubQuestions, BaseColor.BLACK);

            rect = doc.AddRectange(rect.Left, curY - 25, 300, curY - 10, PDFColor.BCGGreen);
            doc.AddRectange(rect);
            curY = doc.AddText(rect, "Overall", BaseColor.WHITE);

            curY = doc.AddText(rect.OffSetRectByXAxis(100), "NA", BaseColor.WHITE);
            curY = doc.AddText(rect.OffSetRectByXAxis(125), "1", BaseColor.WHITE);
            curY = doc.AddText(rect.OffSetRectByXAxis(150), "2", BaseColor.WHITE);
            curY = doc.AddText(rect.OffSetRectByXAxis(175), "3", BaseColor.WHITE);
            curY = doc.AddText(rect.OffSetRectByXAxis(200), "4", BaseColor.WHITE);
            curY = doc.AddText(rect.OffSetRectByXAxis(225), "5", BaseColor.WHITE);

            Doc.Writer.Flush();
            return(curY);
        }
예제 #5
0
        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);
        }
        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();
        }
예제 #7
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));
 }
예제 #8
0
        private byte[] CreateDeliveryAssurancePdf(HttpRequestBase request, string id, int lineNumber, bool resync, ref Doc theDoc)
        {
            int retID = 0;

            theDoc = new Doc();

            if (resync)
            {
                theDoc.HtmlOptions.Engine           = EngineType.Gecko;
                theDoc.HtmlOptions.PageCacheEnabled = false;
                theDoc.HtmlOptions.UseNoCache       = true;
                theDoc.HtmlOptions.PageCacheClear();
                theDoc.HtmlOptions.PageCachePurge();
                theDoc.HtmlOptions.UseResync = true;
            }

            theDoc.Rect.Inset(20, 20);
            theDoc.ClearCachedDecompressedStreams();

            var generatePdfUrl = DeliveryAssuranceHelper.BuildQueryUrl($"{GenerateDeliveryPdfUrl}GeneratePdf",
                                                                       new Dictionary <string, string>()
            {
                { "a", id },
                { "l", lineNumber.ToString() }
            });

            var responseStream = GetWebResponseStream(request, generatePdfUrl);

            if (responseStream != null)
            {
                var outerHtml = FixRelativeLinksToAbsolute(responseStream, request.Url);
                Log.DebugFormat("HtmlResponse with relative links {0}", outerHtml);

                retID = theDoc.AddImageHtml(outerHtml);
            }
            else
            {
                Log.DebugFormat("PDFResponseStream was null");
            }

            //Add Barcode
            theDoc.Rect.String = "360 680 590 725";
            //theDoc.Rect.String = "360 695 590 740";
            var bdf   = BarcodeDrawFactory.Code39WithoutChecksum;
            var image = bdf.Draw(id, 45);

            theDoc.AddImageBitmap(new Bitmap(image), true);

            theDoc.Rect.String = "460 650 530 670";
            theDoc.AddText(id);

            //Add Footer
            theDoc = AddFooter(theDoc, id, lineNumber);

            var theData = theDoc.GetData();

            return(theData);
        }
예제 #9
0
        public async Task WaterMarkText(string WaterMarkText, bool IsRotate = false)
        {
            theDoc.TextStyle.HPos = 0;
            theDoc.TextStyle.VPos = 0;
            theDoc.Rect.SetRect(250, 265, 500, 80);
            if (IsRotate)
            {
                theDoc.Transform.Rotate(55, 250, 265);
            }
            theDoc.FontSize     = 80;
            theDoc.Color.String = "0 0 0 a70";
            Page[] pages = theDoc.ObjectSoup.Catalog.Pages.GetPageArray();
            foreach (Page p in pages)
            {
                theDoc.Page = p.ID;
                theDoc.AddText(WaterMarkText);
            }

            await Task.FromResult(0);
        }
예제 #10
0
        public int MergeDocuments(List <string> documentsToMergeList, List <string> documentsToCreateAndMergeList, string outputLocation, PdfPageSizeEnum pageSizeEnum)
        {
            try
            {
                using (Doc doc1 = new Doc())
                {
                    //set the page size of the entire document
                    doc1.MediaBox.String = pageSizeEnum.ToString();

                    //Merge existing documents
                    foreach (var documentToMerge in documentsToMergeList)
                    {
                        Doc doc2 = new Doc();

                        doc2.Read(documentToMerge);

                        //add each page of the plan to the doc2. It will add it as A4 size
                        for (int i = 1; i <= doc2.PageCount; i++)
                        {
                            doc1.Page = doc1.AddPage();
                            doc1.AddImageDoc(doc2, i, null);
                            doc1.FrameRect();
                        }

                        doc2.Dispose();
                    }

                    //Create New documents and Merge
                    foreach (var documentToCreateAndMerge in documentsToCreateAndMergeList)
                    {
                        using (Doc doc2 = new Doc())
                        {
                            doc2.FontSize = 40;
                            doc2.AddText(documentToCreateAndMerge);
                            doc1.Append(doc2);
                        }
                    }

                    doc1.Form.MakeFieldsUnique(Guid.NewGuid().ToString());
                    doc1.Encryption.CanEdit      = false;
                    doc1.Encryption.CanChange    = false;
                    doc1.Encryption.CanFillForms = false;
                    doc1.Save(outputLocation);
                    return(doc1.PageCount);
                }
            }
            catch (Exception e)
            {
                var documents = string.Join(", ", (from l in documentsToMergeList select l));
                //this.Log().Error(string.Format("Error converting the following documents {0} to ouput location {1}", documents, outputLocation), e);
                //Throw the stack trace with it.
                throw;
            }
        }
예제 #11
0
        private void createButton3_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            List <Group> groups = new List <Group>();

            for (int i = 1; i < 4; i++)
            {
                groups.Add(props.AddGroup("Layer " + i.ToString(), null));
            }
            // membership policies are simple to use but limited in scope
            MembershipGroup alloff = props.AddMembershipGroup();

            alloff.Policy       = MembershipGroup.PolicyEnum.AllOff;
            alloff.PolicyGroups = groups;
            // membership visibility expressions are more complex but more powerful
            MembershipGroup mgve = props.AddMembershipGroup();
            ArrayAtom       ve   = mgve.MakeVisibilityExpression(MembershipGroup.LogicEnum.Or, groups);

            mgve.EntryVE = mgve.MakeVisibilityExpression(MembershipGroup.LogicEnum.Not, new ArrayAtom[] { ve });
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            for (int i = 0; i < 3; i++)
            {
                doc.Page = doc.AddPage();
                Page   page   = (Page)doc.ObjectSoup[doc.Page];
                Writer writer = new Writer(props, page);
                OptionalContent.Layer layer1 = writer.AddGroup(alloff);
                doc.AddText("The next line uses a Policy so that it is only visible if all layers are turned off...\r\n");
                writer.StartLayer(layer1);
                doc.AddText("I am normally invisible\r\n\r\n");
                writer.EndLayer();
                OptionalContent.Layer layer2 = writer.AddGroup(mgve);
                doc.AddText("The next line uses a Visibility Expression so that it is only visible if all layers are turned off...\r\n");
                writer.StartLayer(layer2);
                doc.AddText("I am normally invisible\r\n");
                writer.EndLayer();
                doc.Flatten();
            }
            LoadPDF(doc);
        }
        public void Control()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["LicenseKey"].ConnectionString;
            XSettings.InstallLicense(connectionString);
            var theDoc = new Doc { FontSize = 96 };

            theDoc.AddText("Control");
            Response.ContentType = "application/pdf";
            theDoc.Save(Response.OutputStream);
            theDoc.Clear();
            theDoc.Dispose();
        }
예제 #13
0
        /// <summary>
        /// Add text to the current cell
        /// </summary>
        /// <param name="inText">Text of the cell</param>
        /// <returns>id of the created pdf object</returns>
        public int AddText(string inText)
        {
            while (inText.Length > 0 && Char.IsWhiteSpace(inText[inText.Length - 1]))
            {
                inText = inText.Remove(inText.Length - 1, 1);
            }

            string theRect = mDoc.Rect.String;

            mDoc.Rect.Inset(CellPadding, CellPadding);
            PageNumber = RowTop.PageNr;
            int id = mDoc.AddText(inText);

            int theDrawn = 0;

            if (id > 0)
            {
                theDrawn = mDoc.GetInfoInt(id, "Characters");
            }
            if (theDrawn < inText.Length)
            {
                if (id != 0)
                {
                    mDoc.Delete(id);
                }
                if (mRowPositions.Length >= 2)
                {
                    mRowPositions[mRowPositions.Length - 1].Bottom.PosY
                        = mRowPositions[mRowPositions.Length - 2].Bottom.PosY;
                }

                MoveRowToNextPage();
                mDoc.Rect.String = theRect;
                mDoc.Rect.Top    = RowTop.PosY;
                AddText(inText);
            }
            else
            {
                XRect drawnRect = new XRect();
                drawnRect.String = SaveRowObject(id, inText);

                PagePos thePos = new PagePos(this);
                thePos.PosY = (double)(mDoc.Pos.Y - mDoc.FontSize);
                if (thePos < RowBottom)
                {
                    RowBottom = thePos;
                }

                mDoc.Rect.String = theRect;
            }

            return(id);
        }
예제 #14
0
        private void createButton2_Click(object sender, EventArgs e)
        {
            Doc          doc    = new Doc();
            Properties   props  = Properties.FromDoc(doc, true);
            Group        parent = null;
            List <Group> groups = new List <Group>();

            // The Optional Content Group parent determines the nesting in the UI.
            // The presentation of the nesting is separate from the actual nesting
            // of visibility. In general you will want to ensure the two correspond
            // as in the code here.
            for (int i = 1; i <= 10; i++)
            {
                Group group = props.AddGroup("Layer " + i.ToString(), parent);
                groups.Add(group);
                parent = i == 5 ? null : group;
            }
            doc.Page     = doc.AddPage();
            doc.FontSize = 36;
            doc.Rect.Inset(20, 20);
            Page   page   = (Page)doc.ObjectSoup[doc.Page];
            Writer writer = new Writer(props, page);

            // This determines the nesting of actual visibility. Here we ensure that this
            // corresponds to the hierarchy specified in the UI so that it works in an
            // obvious way.
            for (int i = 0; i < groups.Count; i++)
            {
                Group group = groups[i];
                OptionalContent.Layer layer = writer.AddGroup(group);
                if (i == 5)
                {
                    while (writer.Depth > 0)
                    {
                        writer.EndLayer();
                    }
                }
                writer.StartLayer(layer);
                doc.AddText(group.EntryName.Text + "\r\n");
            }
            while (writer.Depth > 0)
            {
                writer.EndLayer();
            }
            doc.Flatten();
            LoadPDF(doc);
        }
예제 #15
0
        private static int AddtxtLineAndFont(ref Doc theDoc, string line, int font, int size, bool bold, bool italic, double indent = 0)
        {
            theDoc.FontSize         = size;
            theDoc.Font             = font;
            theDoc.TextStyle.Bold   = bold;
            theDoc.TextStyle.Italic = italic;
            if (indent > 0 && !line.StartsWith("-----"))
            {
                theDoc.TextStyle.Indent = indent;
            }
            else
            {
                theDoc.TextStyle.Indent = 0.0;
            }

            return(theDoc.AddText(line));
        }
예제 #16
0
        /// <summary>
        /// Merges PDF Documents and also creates new documents for the string provided and merges them
        /// </summary>
        /// <param name="documentsToMergeList">Existng documents that need to be merged</param>
        /// <param name="documentsToCreateAndMergeList">List of String Data which need to be added to a new document that is merged</param>
        /// <param name="outputLocation">output location where the nerge file gets saved</param>
        /// <returns></returns>
        public int MergeDocuments(List <string> documentsToMergeList, List <string> documentsToCreateAndMergeList, string outputLocation)
        {
            try
            {
                using (Doc doc1 = new Doc())
                {
                    //Merge existing documents
                    foreach (var documentToMerge in documentsToMergeList)
                    {
                        Doc doc2 = new Doc();

                        doc2.Read(documentToMerge);

                        doc1.Append(doc2);

                        doc2.Dispose();
                    }

                    //Create New documents and Merge
                    foreach (var documentToCreateAndMerge in documentsToCreateAndMergeList)
                    {
                        using (Doc doc2 = new Doc())
                        {
                            doc2.FontSize = 40;
                            doc2.AddText(documentToCreateAndMerge);
                            doc1.Append(doc2);
                        }
                    }

                    doc1.Form.MakeFieldsUnique(Guid.NewGuid().ToString());
                    doc1.Encryption.CanEdit      = false;
                    doc1.Encryption.CanChange    = false;
                    doc1.Encryption.CanFillForms = false;
                    doc1.Save(outputLocation);
                    return(doc1.PageCount);
                }
            }
            catch (Exception e)
            {
                var documents = string.Join(", ", (from l in documentsToMergeList select l));
                //this.Log().Error(string.Format("Error converting the following documents {0} to ouput location {1}", documents, outputLocation), e);
                //Throw the stack trace with it.
                throw;
            }
        }
예제 #17
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);
         }
     }
 }
예제 #18
0
        public override float Draw(float _curY)
        {
            float     curY = _curY, curX = 200;
            Rectangle rect = Doc.AddRectange(10, curY - 15, doc.PageSize.Width - 10, curY, PDFColor.BCGGreen);

            curY = Doc.AddText(rect, config.MainQuestion, BaseColor.WHITE) + 10;
            {
                curY = doc.AddText(rect.OffSetRectByXAxis(curX - rect.Left), "NA", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "1", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "2", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "3", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "4", BaseColor.WHITE);
                curY = doc.AddText(rect.OffSetRectByXAxis(curX += 25), "5", BaseColor.WHITE);
            }
            curX = 200;
            foreach (ItemRef item in getSubQuestions())
            {
                Rectangle rRect = new Rectangle(curX, curY, curX + 15, curY - 15);
                doc.AddRadioGroup(item, rRect, new List <String> {
                    "NA", "1", "2", "3", "4", "5"
                }, 25);
                rect = new Rectangle(10, curY - 15, 200, curY);
                curY = doc.AddText(rect, item.Question, PDFColor.BCGBlack);
            }
            if (config.OverAll != null)
            {
                rect = doc.AddRectange(rect.Left, curY - 25, 350, curY - 10, PDFColor.BCGGreen);
                curY = doc.AddText(rect, "Overall", BaseColor.WHITE);
                Rectangle rRect = new Rectangle(curX, rect.Top, curX + 25, rect.Bottom);
                doc.AddRadioGroup(config.OverAll, rRect, new List <String> {
                    "NA", "1", "2", "3", "4", "5"
                }, 25);
            }

            if (config.Comments != null)
            {
                doc.AddTextField(config.Comments,
                                 new Rectangle(350, _curY - 15, doc.PageSize.Width - 10, curY + 5));
            }
            return(curY);
        }
        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");
        }
예제 #20
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();
            }
        }
예제 #21
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);
            }
        }
예제 #22
0
        public ITextService()
        {
            using (var pdf = new Pdf(new FileStream($"../../../OutputFIles/generatePDF.pdf", FileMode.OpenOrCreate)))
            {
                pdf.AddPage(PageSize.A4);
                pdf.AddPage(PageSize.A4);
                pdf.AddPage(PageSize.A3);
                pdf.AddPage(PageSize.A4);

                using (var doc = new Doc(pdf, PageSize.A4, false))
                {
                    doc.SetMargins(100, 40, 100, 48);

                    IText_PDFGenerator.Models.Font font     = new IText_PDFGenerator.Models.Font();
                    IText_PDFGenerator.Models.Font font1251 = new IText_PDFGenerator.Models.Font("../../../Fonts/TIMES.ttf", "Cp1251", 36);

                    Barcode barcode = new Barcode("https://www.webopedia.com/TERM/Q/QR_Code.html");



                    doc.AddText("ti pidor");
                    doc.AddText("ti pidor1");
                    doc.AddText("ti pidor2");

                    doc.GoNextPage();

                    doc.AddText("ti pidor4");

                    doc.GoNextPage();
                    doc.AddText("ti pidor5");



                    for (int i = 1; i <= pdf.GetCountPages; i++)
                    {
                        float[] sizesPage;
                        pdf.GetSizesPage(out sizesPage, i);
                        var pW = sizesPage[0];
                        var pH = sizesPage[1];

                        pdf.SetBarcode(barcode, i, pH - 100);
                        doc.SetFootnotePage($"Специальное разрешение, {i}", font1251, i, pW - 50);

                        float bottomLeftX = pW / 2 - pW / 2;
                        float bottomLeftY = pH / 2 - pH / 2;
                        //Center the annotation
                        Watermark watermark = new Watermark(bottomLeftX, bottomLeftY, pW, pH, 0.6f, pdf.PdfDoc);

                        using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1)))
                        {
                            SizeF size = graphics.MeasureString("Единый реестр лицензий Руспублики Беларусь", new System.Drawing.Font("TIMES", 36, FontStyle.Regular, GraphicsUnit.Pixel));

                            var textW   = size.Width;
                            var textH   = size.Height;
                            var catetH  = (textW * (Math.Sqrt(3) / 2)) / 1;
                            var catetW  = (textW * 1 / 2) / 1;
                            var indentW = (pW - catetW) / 2;
                            var indentH = (pH - catetH) / 2;
                            watermark.TranslateAndRotate(indentW, indentH, Math.PI / 3);
                        }

                        watermark.SetFixed();
                        watermark.SetText(ColorConstants.GRAY, "Единый реестр лицензий Руспублики Беларусь", font1251);
                        watermark.SetAnnotation();

                        pdf.SetAnnotation(i, watermark);
                    }
                }
            }
        }
 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;
 }