public ImageCarouselCanvas(Arguments args)
        {
            this.CloseOnClick = true;

            this.Container = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight
            };

            //var r = new Rectangle
            //{
            //    Fill = Brushes.Red,
            //    Opacity = 0.05
            //};

            //r.SizeTo(DefaultWidth, DefaultHeight);
            //r.AttachTo(this);

            //this.Container.Background = Brushes.Transparent;
            //this.Container.Background = Brushes.Red;

            var y = 0;

            var s = new Stopwatch();

            s.Start();

            var images = new List<XImage>();

            #region AddImages
            Func<Image, XImage> Add =
                i =>
                {
                    y += 32;

                    var n = new XImage
                    {
                        Image = i,
                        Opacity = 0,
                        Radius = 72
                    };


                    RenderOptions.SetBitmapScalingMode(i, BitmapScalingMode.Fant);
                    images.Add(n);
                    i.Opacity = 0;
                    i.AttachTo(this);

                    return n;
                };

            args.AddImages(Add);
            #endregion



            var size = 64;



            Action<DispatcherTimer> AtAnimation = delegate { };

            // .net is fast, but js will be slow :)

            var randomphase = Math.PI * 2 * new Random().NextDouble();

            #region AtIntervalWithTimer
            var AnimationTimer = (1000 / 50).AtIntervalWithTimer(
                t =>
                {
                    var ms = s.ElapsedMilliseconds;


                    var i = 0;

                    AtAnimation(t);

                    // using for each must be the last thing in a method 
                    // because .leave operator currently cannot be understood by jsc

                    foreach (var item_ in images)
                    {
                        var item = item_.Image;
                        var phase = Math.PI * 2 * i / images.Count + randomphase;


                        var cos = Math.Cos(step * ms + phase);
                        var sin = Math.Sin(step * ms + phase);

                        var z1margin = 0.7;
                        var z1 = (cos + (1 + z1margin)) / (2 + z1margin);

                        var z2margin = 1.0;
                        var z2 = (cos + (1 + z2margin)) / (2 + z2margin);


                        item.Opacity = z1 * item_.Opacity;
                        item.SizeTo(size * z2, size * z2);
                        item.MoveTo(
                            -sin * item_.Radius

                            + (DefaultWidth + args.ImageDefaultWidth * 0.3) / 2
                            //+ jsc.ImageDefaultWidth 

                            + cos * item_.Radius
                            - size * z2 * 0.5

                            ,
                            sin * item_.Radius

                            + (DefaultHeight + args.ImageDefaultHeight * 0.3) / 2
                            //+ jsc.ImageDefaultHeight

                            - size * z2 * 0.5

                        );

                        Canvas.SetZIndex(item, Convert.ToInt32(z1 * 1000));
                        i++;
                    }

                }
            );
            #endregion

            var logo = args.CreateCenterImage();


            #region WaitAndAppear
            Action<int, double, Action<double>> WaitAndAppear =
                (delay, step__, set_Opacity) =>
                {
                    var a = 0.0;

                    set_Opacity(a);

                    delay.AtDelay(
                        delegate
                        {


                            (1000 / 30).AtIntervalWithTimer(
                                t =>
                                {
                                    a += step__;

                                    if (a > 1)
                                    {
                                        set_Opacity(1);

                                        t.Stop();
                                        return;
                                    }
                                    set_Opacity(a);
                                }
                            );
                        }
                    );
                };
            #endregion


            WaitAndAppear(200, 0.07, n => logo.Opacity = n);
            SattelitesHidden = false;

            ShowSattelites(images, WaitAndAppear);

            ShowSattelitesAgain =
                delegate
                {
                    if (!SattelitesHidden)
                        return;

                    SattelitesHidden = false;

                    if (AtSattelitesShownAgain != null)
                        AtSattelitesShownAgain();

                    foreach (var item__ in images.ToArray())
                    {
                        var item = item__;

                        WaitAndAppear(0, StepSpeedToToggleSattelites, n => item.Opacity = n);
                    }

                };

            Canvas.SetZIndex(logo, 500);

            logo.AttachTo(this).MoveTo(
                (DefaultWidth - args.ImageDefaultWidth) / 2,
                (DefaultHeight - args.ImageDefaultHeight) / 2
            );

            var logo_hit = new Rectangle
            {
                Fill = Brushes.Red,
                Opacity = 0
            };

            Canvas.SetZIndex(logo_hit, 501);

            logo_hit.Cursor = Cursors.Hand;
            logo_hit.AttachTo(this).MoveTo(
                (DefaultWidth - args.ImageDefaultWidth) / 2,
                (DefaultHeight - args.ImageDefaultHeight) / 2
            );
            logo_hit.SizeTo(args.ImageDefaultWidth, args.ImageDefaultHeight);

            #region MouseLeftButtonUp
            logo_hit.MouseLeftButtonUp +=
                delegate
                {
                    if (AtLogoClick != null)
                        AtLogoClick();
                    //new Uri("http://www.jsc-solutions.net").NavigateTo(this.Container);

                    if (CloseOnClick)
                    {
                        Close();
                        logo_hit.Orphanize();
                    }
                };
            #endregion

            #region HideSattelites
            this.HideSattelites =
                delegate
                {
                    SattelitesHidden = true;

                    Action TriggerClose = () => AtAnimation =
                        t =>
                        {
                            if (images.Any(k => k.Opacity > 0))
                                return;

                            t.Stop();

                            if (AtClose != null)
                                AtClose();
                        };


                    AtAnimation =
                        t =>
                        {
                            if (images.Any(k => k.Opacity < 1))
                                return;

                            foreach (var item__ in images.ToArray())
                            {
                                var item = item__;

                                var NextDelay = 1;

                                if (!DisableTimerShutdown)
                                    NextDelay = 1 + 1000.Random();

                                WaitAndAppear(NextDelay, StepSpeedToToggleSattelites, n => item.Opacity = 1 - n);
                            }

                            if (DisableTimerShutdown)
                            {
                                AtAnimation = delegate { };
                            }
                            else
                                TriggerClose();
                        };


                };
            #endregion


            this.Close =
                delegate
                {
                    WaitAndAppear(1, 0.12, n => logo.Opacity = 1 - n);

                    HideSattelites();
                };
        }
Пример #2
0
        /// <summary>
        /// Makes the specified image to the current graphics object.
        /// </summary>
        string Realize(XImage image)
        {
            BeginPage();
            BeginGraphicMode();
            RealizeTransform();

            // The transparency set for a brush also applies to images. Set opacity to 100% so image will be drawn without transparency.
            _gfxState.RealizeNonStrokeTransparency(1, _colorMode);

            XForm form = image as XForm;
            return form != null ? GetFormName(form) : GetImageName(image);
        }
Пример #3
0
 /// <summary>
 /// Implements the interface because the primary function is internal.
 /// </summary>
 string IContentStream.GetImageName(XImage image)
 {
     return(GetImageName(image));
 }
Пример #4
0
        /// <summary>
        /// Creates a report of a single picture.
        /// </summary>
        /// <param name="picture"></param>
        public void CreateReport(IPictureViewModel picture)
        {
            var report   = new PdfDocument();
            var page     = report.AddPage();
            var filename = picture.FileName + $"_Report{DateTime.Now.Ticks}.pdf";

            var gfx = XGraphics.FromPdfPage(page);

            if (!File.Exists(picture.FilePath))
            {
                throw new FileNotFoundException();
            }

            var image = XImage.FromFile(picture.FilePath);

            // Print Headline
            var   font = new XFont("Times New Roman", 20, XFontStyle.Regular);
            XRect rect = new XRect(20, 20, page.Width - 20, 220);

            gfx.DrawRectangle(XBrushes.White, rect);
            gfx.DrawString(picture.FileName, font, XBrushes.Black, rect, XStringFormats.TopCenter);

            // Print Image
            gfx.DrawImage(image, page.Width / 6, 50, page.Width / 1.5, page.Height / 3);

            // Print EXIF
            double infoYCoord  = (rect.Y + page.Width / 1.8);
            double infoHeight  = (page.Height - (rect.Height + page.Height / 3)) / 2; // Get Height that has already been used and only take half of it
            string exifContent = string.Format("{0}\n" +
                                               "{1}: {2}\n" +
                                               "{3}: {4}\n" +
                                               "{5}: {6}\n" +
                                               "{7}: {8}\n" +
                                               "{9}: {10}\n" +
                                               "{11}: {12}\n" +
                                               "{13}: {14}\n" +
                                               "{15}: {16}",
                                               "EXIF",
                                               "Make", picture.EXIF.Make,
                                               "FNumber", picture.EXIF.FNumber,
                                               "ExposureTime", picture.EXIF.ExposureTime,
                                               "ISOValue", picture.EXIF.ISOValue,
                                               "ISORating", picture.EXIF.ISORating,
                                               "Flash", picture.EXIF.Flash,
                                               "ExposureProgram", picture.EXIF.ExposureProgram,
                                               "Exp.Pro.Resource", picture.EXIF.ExposureProgramResource
                                               );

            font = new XFont("Times New Roman", 14, XFontStyle.Regular);
            rect = new XRect(60, infoYCoord, page.Width / 2 - 20, infoHeight);
            XTextFormatter tf = new XTextFormatter(gfx);

            tf.DrawString(exifContent, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            // Print IPTC
            string iptcContent = string.Format("{0}\n" +
                                               "{1}: {2}\n" +
                                               "{3}: {4}\n" +
                                               "{5}: {6}\n" +
                                               "{7}: {8}\n" +
                                               "{9}: {10}\n",
                                               "IPTC",
                                               "Keywords", picture.IPTC.Keywords,
                                               "ByLine", picture.IPTC.ByLine,
                                               "CopyrightNotice", picture.IPTC.CopyrightNotice,
                                               "Headline", picture.IPTC.Headline,
                                               "Caption", picture.IPTC.Caption);

            rect = new XRect(page.Width / 2 + 50, infoYCoord, page.Width / 2 - 20, infoHeight);
            tf.DrawString(iptcContent, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            // Print Photographer
            string photographerContent = string.Format("{0}\n" +
                                                       "{1}: {2}\n" +
                                                       "{3}: {4}\n" +
                                                       "{5}: {6}\n",
                                                       "Photographer",
                                                       "Full name", picture.Photographer.FirstName + " " + picture.Photographer.LastName,
                                                       "Birthday", picture.Photographer.BirthDay.ToString(),
                                                       "Notes", picture.Photographer.Notes);

            rect = new XRect(60, infoYCoord + 10 * 14, page.Width - 100, infoHeight);
            tf.DrawString(photographerContent, font, XBrushes.Black, rect, XStringFormats.TopLeft);

            report.Save(GlobalInformation.ReportPath + "\\" + filename);
        }
Пример #5
0
    // ----- DrawImage ----------------------------------------------------------------------------

    //public void DrawImage(Image image, Point point);
    //public void DrawImage(Image image, PointF point);
    //public void DrawImage(Image image, Point[] destPoints);
    //public void DrawImage(Image image, PointF[] destPoints);
    //public void DrawImage(Image image, Rectangle rect);
    //public void DrawImage(Image image, RectangleF rect);
    //public void DrawImage(Image image, int x, int y);
    //public void DrawImage(Image image, float x, float y);
    //public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr);
    //public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr);
    //public void DrawImage(Image image, int x, int y, int width, int height);
    //public void DrawImage(Image image, float x, float y, float width, float height);
    //public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback);
    //public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback);
    //public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit);
    //public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData);
    //public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData);
    //public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr);
    //public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs);
    //public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback);
    //public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback);
    //public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData);
    //public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes

    public void DrawImage(XImage image, double x, double y, double width, double height)
    {
      string name = Realize(image);
      if (!(image is XForm))
      {
        if (this.gfx.PageDirection == XPageDirection.Downwards)
        {
          AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm {5} Do Q\n",
            x, y, width, height, y + height, name);
        }
        else
        {
          AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n",
            x, y, width, height, name);
        }
      }
      else
      {
        BeginPage();

        XForm form = (XForm)image;
        form.Finish();

        PdfFormXObject pdfForm = Owner.FormTable.GetForm(form);

        double cx = width / image.PointWidth;
        double cy = height / image.PointHeight;

        if (cx != 0 && cy != 0)
        {
          if (this.gfx.PageDirection == XPageDirection.Downwards)
          {
            AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm 100 Tz {5} Do Q\n",
              x, y, cx, cy, y + height, name);
          }
          else
          {
            AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n",
              x, y, cx, cy, name);
          }
        }
      }
    }
        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");
        }
Пример #7
0
 public static extern int XInitImage(ref XImage image);
Пример #8
0
    /// <summary>
    /// Makes the specified image to the current graphics object.
    /// </summary>
    string Realize(XImage image)
    {
      BeginPage();
      BeginGraphic();
      RealizeTransform();

      string imageName;
      if (image is XForm)
        imageName = GetFormName(image as XForm);
      else
        imageName = GetImageName(image);
      return imageName;
    }
Пример #9
0
        private void CreateOnePage(int plateNumber, ref int nextPartToPrintIndex, PdfPage pdfPage)
        {
            ImageBuffer plateInventoryImage           = new ImageBuffer((int)(300 * 8.5), 300 * 11, 32, new BlenderBGRA());
            Graphics2D  plateGraphics                 = plateInventoryImage.NewGraphics2D();
            double      currentlyPrintingHeightPixels = PrintTopOfPage(plateInventoryImage, plateGraphics);

            Vector2          offset        = new Vector2(PageMarginPixels.Left, currentlyPrintingHeightPixels);
            double           tallestHeight = 0;
            List <PartImage> partsOnLine   = new List <PartImage>();

            while (nextPartToPrintIndex < partImagesToPrint.Count)
            {
                ImageBuffer image = partImagesToPrint[nextPartToPrintIndex].image;
                tallestHeight = Math.Max(tallestHeight, image.Height);

                if (partsOnLine.Count > 0 && offset.x + image.Width > plateInventoryImage.Width - PageMarginPixels.Right)
                {
                    if (partsOnLine.Count == 1)
                    {
                        plateGraphics.Render(partsOnLine[0].image, plateInventoryImage.Width / 2 - partsOnLine[0].image.Width / 2, offset.y - tallestHeight);
                    }
                    else
                    {
                        foreach (PartImage partToDraw in partsOnLine)
                        {
                            plateGraphics.Render(partToDraw.image, partToDraw.xOffset, offset.y - tallestHeight);
                        }
                    }

                    offset.x      = PageMarginPixels.Left;
                    offset.y     -= (tallestHeight + PartPaddingPixels * 2);
                    tallestHeight = 0;
                    partsOnLine.Clear();
                    if (offset.y - image.Height < PageMarginPixels.Bottom)
                    {
                        break;
                    }
                }
                else
                {
                    partImagesToPrint[nextPartToPrintIndex].xOffset = offset.x;
                    partsOnLine.Add(partImagesToPrint[nextPartToPrintIndex]);
                    //plateGraphics.Render(image, offset.x, offset.y - image.Height);
                    offset.x += image.Width + PartPaddingPixels * 2;
                    nextPartToPrintIndex++;
                }
            }

            // print the last line of parts
            foreach (PartImage partToDraw in partsOnLine)
            {
                plateGraphics.Render(partToDraw.image, partToDraw.xOffset, offset.y - tallestHeight);
            }

            TypeFacePrinter printer = new TypeFacePrinter(string.Format("{0}", Path.GetFileNameWithoutExtension(pathAndFileToSaveTo)), 32, justification: Justification.Center);

            printer.Origin = new Vector2(plateGraphics.DestImage.Width / 2, 110);
            plateGraphics.Render(printer, RGBA_Bytes.Black);

            printer        = new TypeFacePrinter(string.Format("Page {0}", plateNumber), 28, justification: Justification.Center);
            printer.Origin = new Vector2(plateGraphics.DestImage.Width / 2, 60);
            plateGraphics.Render(printer, RGBA_Bytes.Black);

            string applicationUserDataPath = ApplicationDataStorage.ApplicationUserDataPath;
            string folderToSavePrintsTo    = Path.Combine(applicationUserDataPath, "data", "temp", "plateImages");
            string jpegFileName            = Path.Combine(folderToSavePrintsTo, plateNumber.ToString() + ".jpeg");

            if (!Directory.Exists(folderToSavePrintsTo))
            {
                Directory.CreateDirectory(folderToSavePrintsTo);
            }
            ImageIO.SaveImageData(jpegFileName, plateInventoryImage);

            XGraphics gfx       = XGraphics.FromPdfPage(pdfPage);
            XImage    jpegImage = XImage.FromFile(jpegFileName);

            //double width = jpegImage.PixelWidth * 72 / jpegImage.HorizontalResolution;
            //double height = jpegImage.PixelHeight * 72 / jpegImage. .HorizontalResolution;

            gfx.DrawImage(jpegImage, 0, 0, pdfPage.Width, pdfPage.Height);
        }
Пример #10
0
        static void Main(string[] args)
        {
            DateTime now      = DateTime.Now;
            string   fileName = "ticket.pdf";

            fileName = Guid.NewGuid().ToString("D").ToUpper() + ".pdf";
            PdfDocument document = new PdfDocument();

            document.Info.Title    = "FACTURA DE VENTA";
            document.Info.Author   = "";
            document.Info.Subject  = "";
            document.Info.Keywords = "Other Words";

            double marginLeft  = 42.52;
            double marginRight = 42.52;
            double marginTop   = 42.52;
            double cuadrito    = 14.173228346457;

            LayoutHelper helper   = new LayoutHelper(document, marginTop, XUnit.FromCentimeter(29.7 - 2.5));
            string       logoPath = @"C:\Users\gusvo\Desktop\logo.jpg";

            logoPath = @"C:\Users\Alejandro Sierra\Desktop\logo.png";

            XImage image = XImage.FromFile(logoPath);

            marginTop = helper.GetLinePosition(XUnit.FromCentimeter(29.7 - 2.5));
            //Debug control
            Debug.WriteLine("marginTop= " + marginTop.ToString());

            helper.Gfx.DrawImage(image, marginLeft, marginTop, 200, 100);
            XPen pen = new XPen(XColors.Plum, 4.7);

            string[] company = { "Supermercado el dorado", "Direccion: Cra 90 bis #76-51", "Telefono: 3212261759", "ID: 1016072267", "Correo: [email protected]" };
            string[] head    = { "FACTURA DE VENTA", DateTime.UtcNow.ToShortDateString(), "#FACT-11111" };
            string[] client  = { "Cliente: Gustavo Alejandro Sierra", "Correo: [email protected]", "Telefono: 3212261759", "ID: 1016072267", "Direccion: Cra 90 bis #76-51" };
            // Create a font
            XFont fontCompany = new XFont("Arial", 8, XFontStyle.Regular);
            XFont fontClient  = new XFont("Arial", 8, XFontStyle.Regular);
            XFont fontHead    = new XFont("Arial", 11, XFontStyle.Regular);
            XFont fontFooter  = new XFont("Arial", 11, XFontStyle.Regular);
            //fact head
            double headHeight = marginTop;

            // Draw the HEADtext
            for (int i = 0; i < head.Length; i++)
            {
                helper.Gfx.DrawString(head[i], fontHead, head.Length == i + 1 ? XBrushes.Gray : XBrushes.Black,
                                      new XRect(helper.Page.Width - helper.Page.Width / 3, marginTop, helper.Page.Width / 3 - marginLeft, headHeight), XStringFormats.CenterRight);
                headHeight += 30;
            }

            int clientNameHeight = 110;

            // Draw the CLIENTtext
            for (int i = 0; i < client.Length; i++)
            {
                clientNameHeight += 8;
                helper.Gfx.DrawString(client[i], fontClient, XBrushes.Black,
                                      new XRect(marginLeft, clientNameHeight, 306, clientNameHeight), XStringFormats.CenterLeft);
            }

            int companyMarginHeight = 110;

            // Draw the COMPANYtext
            for (int i = 0; i < company.Length; i++)
            {
                companyMarginHeight += 8;
                helper.Gfx.DrawString(company[i], fontCompany, XBrushes.Black,
                                      new XRect(helper.Page.Width - helper.Page.Width / 3, companyMarginHeight, 306, companyMarginHeight), XStringFormats.CenterLeft);
            }

            XFont fontSubTitle = new XFont("Arial", 11, XFontStyle.Bold);

            //Draw the GridDetails
            string[] gridTitles          = { "Referencia", "Producto", "Tasa de impuesto", "Precio unitario", "Cant.", "Total" };
            string[] gridMovementsTitles = { "Referencia", "Producto", "Tasa de impuesto", "Precio unitario", "Cant.", "Total" };
            string[] list1 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list2 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list3 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list4 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list5 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list6 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list7 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list8 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list9 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };
            string[] list10 = new string[3] {
                "$20.000", "Pago parcial", "26/10/2020"
            };

            List <string[]> movementDetails = new List <string[]>()
            {
                list1, list2, list3, list4, list5, list6, list7, list8
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
                , list9, list10, list1, list10, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3, list3
            };

            XFont fontGrid = new XFont("Arial", 9, XFontStyle.Bold);
            XPen  penRect  = new XPen(XColors.DarkGray, 0.25);

            helper.Gfx.DrawRectangle(penRect, XBrushes.WhiteSmoke, marginLeft, helper.Page.Height / 3, helper.Page.Width - (marginLeft * 2), 2 * cuadrito);
            helper.Gfx.DrawString("Valor Movimiento", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft, helper.Page.Height / 3, 10 * cuadrito, 2 * cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Descripcion", fontGrid, XBrushes.Black,
                                  new XRect((helper.Page.Width - (2 * marginLeft)) / 3, helper.Page.Height / 3, 20 * cuadrito, 2 * cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Fecha Movimiento", fontGrid, XBrushes.Black,
                                  new XRect(helper.Page.Width - (helper.Page.Width - (2 * marginLeft)) / 3, helper.Page.Height / 3, 10 * cuadrito, 2 * cuadrito), XStringFormats.Center);

            XFont fontMovement = new XFont("Arial", 9, XFontStyle.Regular);

            double[] movementMarginLeft = { marginLeft, (helper.Page.Width - (2 * marginLeft)) / 3, helper.Page.Width - (helper.Page.Width - (2 * marginLeft)) / 3 };
            double[] movementSpacing    = { 10 * cuadrito, 20 * cuadrito, 10 * cuadrito };
            double   spacingMovement    = 2 * cuadrito + (helper.Page.Height / 3);

            foreach (var item in movementDetails)
            {
                for (int j = 0; j < item.Length; j++)
                {
                    if (spacingMovement + cuadrito > helper.Page.Height - marginTop)
                    {
                        XUnit top = helper.GetLinePosition(XUnit.FromCentimeter(29.7 - 2.5));
                        Debug.WriteLine("TOP " + j + " " + top.ToString() + ", spacingMovement: " + spacingMovement);

                        spacingMovement = top;
                    }
                    helper.Gfx.DrawString(item[j], fontMovement, XBrushes.Black,
                                          new XRect(movementMarginLeft[j], spacingMovement, movementSpacing[j], cuadrito), XStringFormats.Center);
                    helper.Gfx.DrawLine(penRect, movementMarginLeft[j], spacingMovement, movementMarginLeft[j], spacingMovement + cuadrito);
                    helper.Gfx.DrawLine(penRect, helper.Page.Width - marginRight, spacingMovement, helper.Page.Width - marginRight, spacingMovement + cuadrito);
                    helper.Gfx.DrawLine(penRect, marginLeft, spacingMovement, helper.Page.Width - marginRight, spacingMovement);
                }
                spacingMovement += cuadrito;
                helper.Gfx.DrawLine(penRect, marginLeft, spacingMovement, helper.Page.Width - marginRight, spacingMovement);
            }

            spacingMovement += cuadrito;


            helper.Gfx.DrawRectangle(penRect, XBrushes.WhiteSmoke, marginLeft, spacingMovement, helper.Page.Width - (marginLeft * 2), 2 * cuadrito);
            helper.Gfx.DrawString("Ref", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft, spacingMovement, 50, 2 * cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Producto", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft + 50, spacingMovement, 300, 2 * cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Precio", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft + 50 + 250 + 50, spacingMovement, 70, cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Unitario", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft + 50 + 250 + 50, spacingMovement + cuadrito, 70, cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("Cant.", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft + 50 + 250 + 50 + 70, spacingMovement, 50, 2 * cuadrito), XStringFormats.Center);
            helper.Gfx.DrawString("SubTotal", fontGrid, XBrushes.Black,
                                  new XRect(marginLeft + 50 + 250 + 50 + 70 + 50, spacingMovement, 55, 2 * cuadrito), XStringFormats.Center);

            XFont fontDetails = new XFont("Arial", 9, XFontStyle.Regular);

            string[]        product1       = { "0001", "COCA COLA ZERO", "2680", "1", "50.000" };
            string[]        product2       = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product3       = { "0001", "COCA COLA ZERO", "2680", "1", "1.000.000" };
            string[]        product4       = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product5       = { "0001", "COCA COLA ZERO", "2680", "1", "26.850" };
            string[]        product6       = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product7       = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product8       = { "0001", "COCA COLA ZERO", "2680", "1", "122.680" };
            string[]        product9       = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product10      = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product11      = { "0001", "COCA COLA ZERO", "2680", "1", "2680" };
            string[]        product12      = { "0001", "COCA COLA ZERO", "2680", "1", "2.680.899" };
            double[]        gridmarginLeft = { marginLeft, marginLeft + 50, marginLeft + 50 + 250 + 50, marginLeft + 50 + 250 + 50 + 70, marginLeft + 50 + 250 + 50 + 70 + 50 };
            double[]        gridSpacing    = { 50, 300, 70, 50, 55 };
            string[]        totals         = { "$580.000", "Envio gratis", "$0", "$0", "$680", "$1.200.000" };
            List <string[]> products       = new List <string[]>()
            {
                product1, product2, product3, product3, product3, product3, product3, product3, product3, product4, product5,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12,
                product6, product7, product8, product9, product10, product11, product12
            };

            double spacingProducts = 2 * cuadrito + spacingMovement;

            foreach (var item in products)
            {
                for (int i = 0; i < item.Length; i++)
                {
                    if (spacingProducts + cuadrito > helper.Page.Height - marginTop)
                    {
                        XUnit top = helper.GetLinePosition(XUnit.FromCentimeter(29.7 - 2.5));
                        spacingProducts = top;
                    }
                    else
                    {
                        helper.Gfx.DrawLine(penRect, marginLeft, spacingProducts, helper.Page.Width - marginRight, spacingProducts);
                    }
                    helper.Gfx.DrawString(item[i], fontDetails, XBrushes.Black,
                                          new XRect(gridmarginLeft[i], spacingProducts, gridSpacing[i], cuadrito), XStringFormats.Center);
                    helper.Gfx.DrawLine(penRect, gridmarginLeft[i], spacingProducts, gridmarginLeft[i], spacingProducts + cuadrito);
                    helper.Gfx.DrawLine(penRect, helper.Page.Width - marginRight, spacingProducts, helper.Page.Width - marginRight, spacingProducts + cuadrito);
                }
                spacingProducts += cuadrito;
                helper.Gfx.DrawLine(penRect, marginRight, spacingProducts, helper.Page.Width - marginRight, spacingProducts);
            }

            XTextFormatter tf = new XTextFormatter(helper.Gfx);

            string[] footerFields        = { "Pago Transacción", "Pago Efectivo", "Detalles" };
            string[] footerDetails       = { "$1.000", "$1.000", "Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo Cliente Nuevo " };
            double[] footerFieldsSpacing = { 8 * cuadrito, marginLeft + 12 * cuadrito };
            double   totalSpacing        = spacingProducts;

            string[] totalFields        = { "Subtotal", "Gastos de envío", "Impuesto1", "Impuesto2", "Descuento", "TOTAL" };
            double[] totalFieldsSpacing = { marginLeft + 50 + 250 + 50 };

            if (spacingProducts + 7 * cuadrito > helper.Page.Height - marginTop)
            {
                XUnit top = helper.GetLinePosition(XUnit.FromCentimeter(29.7 - 2.5));
                spacingProducts = totalSpacing = top;
            }
            else
            {
                totalSpacing = spacingProducts += cuadrito;
            }
            helper.Gfx.DrawRectangle(penRect, XBrushes.White, marginLeft, totalSpacing, 24 * cuadrito, 8 * cuadrito);
            helper.Gfx.DrawRectangle(penRect, XBrushes.WhiteSmoke, marginLeft + 50 + 250 + 50, totalSpacing, 9 * cuadrito, 8 * cuadrito);
            helper.Gfx.DrawRectangle(penRect, XBrushes.White, marginLeft + 50 + 250 + 50 + 70 + 50, totalSpacing, 4 * cuadrito, 8 * cuadrito);
            for (int i = 0; i < footerFields.Length; i++)
            {
                helper.Gfx.DrawString(footerFields[i], fontGrid, XBrushes.Black,
                                      new XRect(marginLeft + cuadrito, spacingProducts, marginLeft + footerFieldsSpacing[0], cuadrito), XStringFormats.CenterLeft);

                helper.Gfx.DrawLine(penRect, marginLeft, spacingProducts, marginLeft + 24 * cuadrito, spacingProducts);

                if (footerDetails.Length - 1 == i)
                {
                    tf.DrawString(footerDetails[i], fontDetails, XBrushes.Black,
                                  new XRect(marginLeft + cuadrito, spacingProducts + cuadrito, 22 * cuadrito, 5 * cuadrito), XStringFormats.TopLeft);
                }
                else
                {
                    helper.Gfx.DrawString(footerDetails[i], fontDetails, XBrushes.Black,
                                          new XRect(footerFieldsSpacing[1], spacingProducts, marginLeft + footerFieldsSpacing[0], cuadrito), XStringFormats.CenterRight);
                }

                helper.Gfx.DrawLine(penRect, marginLeft, spacingProducts, marginLeft + 24 * cuadrito, spacingProducts);

                spacingProducts += cuadrito;
            }
            for (int i = 0; i < totalFields.Length; i++)
            {
                helper.Gfx.DrawString(totalFields[i], fontGrid, XBrushes.Black,
                                      new XRect(totalFieldsSpacing[0], totals.Length == i + 1 ? totalSpacing + cuadrito : totalSpacing, 9 * cuadrito, cuadrito), XStringFormats.Center);
                helper.Gfx.DrawString(totals[i], totals.Length == i + 1 ? fontGrid : fontDetails, XBrushes.Black,
                                      new XRect(marginLeft + 50 + 250 + 50 + 70 + 50, totals.Length == i + 1 ? totalSpacing + cuadrito : totalSpacing, 4 * cuadrito, cuadrito), XStringFormats.Center);
                totalSpacing += cuadrito;
            }


            //612pt*792pt letter paper is the same to A4
            Debug.WriteLine("seconds= " + (DateTime.Now - now).TotalSeconds.ToString());
            //Saving
            document.Save(fileName);
            //start view
            Process.Start(fileName);
        }
Пример #11
0
        /// <summary>
        /// Append PDF and bitmap image to result PDF file.
        /// </summary>
        public void AppendToResultPdf()
        {
            string      resultFileName    = Path.Combine(OutputDirectory, "~TestResult.pdf");
            PdfDocument pdfResultDocument = null;

            if (File.Exists(resultFileName))
            {
                pdfResultDocument = PdfReader.Open(resultFileName, PdfDocumentOpenMode.Modify);
            }
            else
            {
                pdfResultDocument            = new PdfDocument();
                pdfResultDocument.PageLayout = PdfPageLayout.SinglePage;

#if GDI
                pdfResultDocument.Info.Title = "PDFsharp Unit Tests based on GDI+";
#endif
#if WPF
                pdfResultDocument.Info.Title = "PDFsharp Unit Tests based on WPF";
#endif
                pdfResultDocument.Info.Author = "Stefan Lange";
            }

            PdfPage page = pdfResultDocument.AddPage();
            page.Orientation = PageOrientation.Landscape;
            XGraphics gfx = XGraphics.FromPdfPage(page);
            gfx.DrawRectangle(XBrushes.GhostWhite, new XRect(0, 0, 1000, 1000));

            double x1 = XUnit.FromMillimeter((297 - 2 * WidthInMillimeter) / 3);
            double x2 = XUnit.FromMillimeter((297 - 2 * WidthInMillimeter) / 3 * 2 + WidthInMillimeter);
            double y  = XUnit.FromMillimeter((210 - HeightInMillimeter) / 2);
            double yt = XUnit.FromMillimeter(HeightInMillimeter) + y + 20;
            gfx.DrawString(String.Format("PDFsharp Unit Test '{0}'", this.Name), new XFont("Arial", 9, XFontStyle.Bold),
                           XBrushes.DarkRed, new XPoint(x1, 30));

            // Draw the PDF result
#if GDI
            //gfx.DrawString("What you see: A PDF form created with PDFsharp based on GDI+", new XFont("Verdana", 9), XBrushes.DarkBlue, new XPoint(x1, yt));
            string subtitle = "This is a PDF form created with PDFsharp based on GDI+";
#endif
#if WPF
            //gfx.DrawString("What you see: A PDF form created with PDFsharp based on WPF", new XFont("Verdana", 9), XBrushes.DarkBlue, new XPoint(x1, yt));
            string subtitle = "This is a PDF form created with PDFsharp based on WPF";
#endif
            gfx.DrawString(subtitle, new XFont("Arial", 8), XBrushes.DarkBlue, new XRect(x1, yt, WidthInPoint, 0), XStringFormats.Default);
            XPdfForm form = XPdfForm.FromFile(Path.Combine(OutputDirectory, Name + ".pdf"));
            gfx.DrawImage(form, new XPoint(x1, y));

            // Draw the result bitmap
#if GDI
            //gfx.DrawString("What you see: A bitmap image created with PDFsharp based on GDI+", new XFont("Verdana", 9), XBrushes.DarkBlue, new XPoint(x2, yt));
            subtitle = "As a reference, this is a bitmap image created with PDFsharp based on GDI+";
#endif
#if WPF
            //gfx.DrawString("What you see: A bitmap image created with PDFsharp based on WPF", new XFont("Verdana", 9), XBrushes.DarkBlue, new XPoint(x2, yt));
            subtitle = "As a reference, this is a bitmap image created with PDFsharp based on WPF";
#endif
            gfx.DrawString(subtitle, new XFont("Arial", 8), XBrushes.DarkBlue, new XRect(x2, yt, WidthInPoint, 0), XStringFormats.Default);
            XImage image = XImage.FromFile(Path.Combine(OutputDirectory, Name + ".png"));
            image.Interpolate = false;
            gfx.DrawImage(image, new XPoint(x2, y));
            pdfResultDocument.Save(resultFileName);
        }
Пример #12
0
        private void CalculateImageDimensions()
        {
            ImageFormatInfo formatInfo = (ImageFormatInfo)_renderInfo.FormatInfo;

            if (formatInfo.Failure == ImageFailure.None)
            {
                XImage xImage = null;
                try
                {
                    //xImage = XImage.FromFile(_imageFilePath);
                    xImage = CreateXImage(_imageFilePath);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine(Messages2.InvalidImageType(ex.Message));
                    formatInfo.Failure = ImageFailure.InvalidType;
                }

                if (formatInfo.Failure == ImageFailure.None)
                {
                    try
                    {
                        XUnit usrWidth     = _image.Width.Point;
                        XUnit usrHeight    = _image.Height.Point;
                        bool  usrWidthSet  = !_image._width.IsNull;
                        bool  usrHeightSet = !_image._height.IsNull;

                        XUnit resultWidth  = usrWidth;
                        XUnit resultHeight = usrHeight;

                        Debug.Assert(xImage != null);
                        double xPixels          = xImage.PixelWidth;
                        bool   usrResolutionSet = !_image._resolution.IsNull;

                        double horzRes = usrResolutionSet ? _image.Resolution : xImage.HorizontalResolution;
                        double vertRes = usrResolutionSet ? _image.Resolution : xImage.VerticalResolution;

// ReSharper disable CompareOfFloatsByEqualityOperator
                        if (horzRes == 0 && vertRes == 0)
                        {
                            horzRes = 72;
                            vertRes = 72;
                        }
                        else if (horzRes == 0)
                        {
                            Debug.Assert(false, "How can this be?");
                            horzRes = 72;
                        }
                        else if (vertRes == 0)
                        {
                            Debug.Assert(false, "How can this be?");
                            vertRes = 72;
                        }
                        // ReSharper restore CompareOfFloatsByEqualityOperator

                        XUnit  inherentWidth  = XUnit.FromInch(xPixels / horzRes);
                        double yPixels        = xImage.PixelHeight;
                        XUnit  inherentHeight = XUnit.FromInch(yPixels / vertRes);

                        //bool lockRatio = _image.IsNull("LockAspectRatio") ? true : _image.LockAspectRatio;
                        bool lockRatio = _image._lockAspectRatio.IsNull || _image.LockAspectRatio;

                        double scaleHeight = _image.ScaleHeight;
                        double scaleWidth  = _image.ScaleWidth;
                        //bool scaleHeightSet = !_image.IsNull("ScaleHeight");
                        //bool scaleWidthSet = !_image.IsNull("ScaleWidth");
                        bool scaleHeightSet = !_image._scaleHeight.IsNull;
                        bool scaleWidthSet  = !_image._scaleWidth.IsNull;

                        if (lockRatio && !(scaleHeightSet && scaleWidthSet))
                        {
                            if (usrWidthSet && !usrHeightSet)
                            {
                                resultHeight = inherentHeight / inherentWidth * usrWidth;
                            }
                            else if (usrHeightSet && !usrWidthSet)
                            {
                                resultWidth = inherentWidth / inherentHeight * usrHeight;
                            }
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
                            else if (!usrHeightSet && !usrWidthSet)
                            {
                                resultHeight = inherentHeight;
                                resultWidth  = inherentWidth;
                            }

                            if (scaleHeightSet)
                            {
                                resultHeight = resultHeight * scaleHeight;
                                resultWidth  = resultWidth * scaleHeight;
                            }
                            if (scaleWidthSet)
                            {
                                resultHeight = resultHeight * scaleWidth;
                                resultWidth  = resultWidth * scaleWidth;
                            }
                        }
                        else
                        {
                            if (!usrHeightSet)
                            {
                                resultHeight = inherentHeight;
                            }

                            if (!usrWidthSet)
                            {
                                resultWidth = inherentWidth;
                            }

                            if (scaleHeightSet)
                            {
                                resultHeight = resultHeight * scaleHeight;
                            }
                            if (scaleWidthSet)
                            {
                                resultWidth = resultWidth * scaleWidth;
                            }
                        }

                        formatInfo.CropWidth  = (int)xPixels;
                        formatInfo.CropHeight = (int)yPixels;
                        if (_image._pictureFormat != null && !_image._pictureFormat.IsNull())
                        {
                            PictureFormat picFormat = _image.PictureFormat;
                            //Cropping in pixels.
                            XUnit cropLeft   = picFormat.CropLeft.Point;
                            XUnit cropRight  = picFormat.CropRight.Point;
                            XUnit cropTop    = picFormat.CropTop.Point;
                            XUnit cropBottom = picFormat.CropBottom.Point;
                            formatInfo.CropX       = (int)(horzRes * cropLeft.Inch);
                            formatInfo.CropY       = (int)(vertRes * cropTop.Inch);
                            formatInfo.CropWidth  -= (int)(horzRes * ((XUnit)(cropLeft + cropRight)).Inch);
                            formatInfo.CropHeight -= (int)(vertRes * ((XUnit)(cropTop + cropBottom)).Inch);

                            //Scaled cropping of the height and width.
                            double xScale = resultWidth / inherentWidth;
                            double yScale = resultHeight / inherentHeight;

                            cropLeft   = xScale * cropLeft;
                            cropRight  = xScale * cropRight;
                            cropTop    = yScale * cropTop;
                            cropBottom = yScale * cropBottom;

                            resultHeight = resultHeight - cropTop - cropBottom;
                            resultWidth  = resultWidth - cropLeft - cropRight;
                        }
                        if (resultHeight <= 0 || resultWidth <= 0)
                        {
                            formatInfo.Width  = XUnit.FromCentimeter(2.5);
                            formatInfo.Height = XUnit.FromCentimeter(2.5);
                            Debug.WriteLine(Messages2.EmptyImageSize);
                            _failure = ImageFailure.EmptySize;
                        }
                        else
                        {
                            formatInfo.Width  = resultWidth;
                            formatInfo.Height = resultHeight;
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(Messages2.ImageNotReadable(_image.Name, ex.Message));
                        formatInfo.Failure = ImageFailure.NotRead;
                    }
                    finally
                    {
                        if (xImage != null)
                        {
                            xImage.Dispose();
                        }
                    }
                }
            }
            if (formatInfo.Failure != ImageFailure.None)
            {
                if (!_image._width.IsNull)
                {
                    formatInfo.Width = _image.Width.Point;
                }
                else
                {
                    formatInfo.Width = XUnit.FromCentimeter(2.5);
                }

                if (!_image._height.IsNull)
                {
                    formatInfo.Height = _image.Height.Point;
                }
                else
                {
                    formatInfo.Height = XUnit.FromCentimeter(2.5);
                }
            }
        }
Пример #13
0
        public void ExportThread()
        {
            var zWait = WaitDialog.Instance;

#if !MONO_BUILD
            Bitmap zBuffer = null;
#endif

            zWait.ProgressReset(0, 0, ExportLayoutEndIndex - ExportLayoutStartIndex, 0);
            for (var nIdx = ExportLayoutStartIndex; nIdx < ExportLayoutEndIndex; nIdx++)
            {
                ChangeExportLayoutIndex(nIdx);
                zWait.ProgressReset(1, 0, CurrentDeck.CardCount, 0);

                ConfigurePointSizes(CurrentDeck.CardLayout);

                // necessary tracking for which index of the layout is to be exported (this is NOT necessarily the index of the card due to the page back functionality)
                var nNextExportIndex = 0;

                if (0 < nIdx)
                {
                    if (CardMakerSettings.PrintLayoutsOnNewPage)
                    {
                        AddPage();
                    }

                    if (CardMakerSettings.PrintAutoHorizontalCenter ||
                        (m_dDrawX + m_dLayoutPointWidth > m_dPageMarginEndX)) // this is the case where a layout won't fit in the remaining space of the row
                    {
                        MoveToNextRow(nNextExportIndex);
                    }
                }

                // should be adjusted after the above move to next row
                m_dNextRowYAdjust = Math.Max(m_dNextRowYAdjust, m_dLayoutPointHeight + m_dBufferY);

                if (CardMakerSettings.PrintAutoHorizontalCenter)
                {
                    CenterLayoutPositionOnNewRow(nNextExportIndex);
                }

#if !MONO_BUILD
                zBuffer?.Dispose();
                zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);

                float fOriginalXDpi = zBuffer.HorizontalResolution;
                float fOriginalYDpi = zBuffer.VerticalResolution;
#endif

                foreach (var nCardIdx in GetExportIndices())
                {
                    CurrentDeck.ResetDeckCache();

                    CurrentDeck.CardPrintIndex = nCardIdx;

#if MONO_BUILD
                    // mono build won't support the optimization so re-create the buffer
                    Bitmap zBuffer = new Bitmap(CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height);
#endif

#if !MONO_BUILD
                    // minor optimization, reuse the same bitmap (for drawing sake the DPI has to be reset)
                    zBuffer.SetResolution(fOriginalXDpi, fOriginalYDpi);
#endif
                    if (nCardIdx == -1)
                    {
                        Graphics.FromImage(zBuffer).FillRectangle(Brushes.White, 0, 0, zBuffer.Width, zBuffer.Height);
                        // note: some oddities were observed where the buffer was not flood filling
                    }
                    else
                    {
                        CardRenderer.DrawPrintLineToGraphics(Graphics.FromImage(zBuffer));
                    }

                    // apply any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, false);

                    // before rendering to the PDF bump the DPI to the desired value
                    zBuffer.SetResolution(CurrentDeck.CardLayout.dpi, CurrentDeck.CardLayout.dpi);

                    var xImage = XImage.FromGdiPlusImage(zBuffer);

                    EvaluatePagePosition(nNextExportIndex);

                    m_zPageGfx.DrawImage(xImage, m_dDrawX, m_dDrawY);

                    MoveToNextColumnPosition();

                    // undo any export rotation
                    ProcessRotateExport(zBuffer, CurrentDeck.CardLayout, true);

                    nNextExportIndex++;

                    zWait.ProgressStep(1);
                }
                zWait.ProgressStep(0);
            }

#if !MONO_BUILD
            zBuffer?.Dispose();
#endif

            try
            {
                m_zDocument.Save(m_sExportFile);
                zWait.ThreadSuccess = true;
            }
            catch (Exception ex)
            {
                Logger.AddLogLine("Error saving PDF (is it open?) " + ex.Message);
                zWait.ThreadSuccess = false;
            }

            zWait.CloseWaitDialog();
        }
Пример #14
0
 /// <summary>
 /// Gets the resource name of the specified image within this page or form.
 /// </summary>
 internal string GetImageName(XImage image)
 {
     if (_page != null)
         return _page.GetImageName(image);
     return _form.GetImageName(image);
 }
Пример #15
0
 public static extern int XDestroyImage(ref XImage image);
Пример #16
0
        // TODO: incomplete - srcRect not used
        public void DrawImage(XImage image, XRect destRect, XRect srcRect, XGraphicsUnit srcUnit)
        {
            const string format = Config.SignificantFigures4;

            double x = destRect.X;
            double y = destRect.Y;
            double width = destRect.Width;
            double height = destRect.Height;

            string name = Realize(image);
            if (!(image is XForm))
            {
                if (_gfx.PageDirection == XPageDirection.Downwards)
                {
                    AppendFormatImage("q {2:" + format + "} 0 0 {3:" + format + "} {0:" + format + "} {1:" + format + "} cm {4} Do\nQ\n",
                        x, y + height, width, height, name);
                }
                else
                {
                    AppendFormatImage("q {2:" + format + "} 0 0 {3:" + format + "} {0:" + format + "} {1:" + format + "} cm {4} Do Q\n",
                        x, y, width, height, name);
                }
            }
            else
            {
                BeginPage();

                XForm form = (XForm)image;
                form.Finish();

                PdfFormXObject pdfForm = Owner.FormTable.GetForm(form);

                double cx = width / image.PointWidth;
                double cy = height / image.PointHeight;

                if (cx != 0 && cy != 0)
                {
                    XPdfForm xForm = image as XPdfForm;
                    if (_gfx.PageDirection == XPageDirection.Downwards)
                    {
                        double xDraw = x;
                        double yDraw = y;
                        if (xForm != null)
                        {
                            // Yes, it is an XPdfForm - adjust the position where the page will be drawn.
                            xDraw -= xForm.Page.MediaBox.X1;
                            yDraw += xForm.Page.MediaBox.Y1;
                        }
                        AppendFormatImage("q {2:" + format + "} 0 0 {3:" + format + "} {0:" + format + "} {1:" + format + "} cm {4} Do Q\n",
                            xDraw, yDraw + height, cx, cy, name);
                    }
                    else
                    {
                        // TODO Translation for MediaBox.
                        AppendFormatImage("q {2:" + format + "} 0 0 {3:" + format + "} {0:" + format + "} {1:" + format + "} cm {4} Do Q\n",
                            x, y, cx, cy, name);
                    }
                }
            }
        }
Пример #17
0
 public static extern int XPutImage(IntPtr display, IntPtr drawable, IntPtr gc, ref XImage image,
                                    int srcx, int srcy, int destx, int desty, uint width, uint height);
Пример #18
0
 /// <summary>
 /// Gets the resource name of the specified image within this page or form.
 /// </summary>
 internal string GetImageName(XImage image)
 {
   if (this.page != null)
     return this.page.GetImageName(image);
   else
     return this.form.GetImageName(image);
 }
Пример #19
0
        private void CalculateImageDimensions()
        {
            ImageFormatInfo formatInfo = (ImageFormatInfo)this.renderInfo.FormatInfo;

            if (formatInfo.Failure == ImageFailure.None)
            {
                XImage xImage = null;
                try
                {
                    xImage = XImage.FromImageSource(formatInfo.ImageSource);
                }
                catch (InvalidOperationException ex)
                {
                    Debug.WriteLine(string.Format(AppResources.InvalidImageType, ex.Message));
                    formatInfo.Failure = ImageFailure.InvalidType;
                }

                try
                {
                    XUnit usrWidth     = image.Width.Point;
                    XUnit usrHeight    = image.Height.Point;
                    bool  usrWidthSet  = !this.image.IsNull("Width");
                    bool  usrHeightSet = !this.image.IsNull("Height");

                    XUnit resultWidth  = usrWidth;
                    XUnit resultHeight = usrHeight;

                    double xPixels          = xImage.PixelWidth;
                    bool   usrResolutionSet = !image.IsNull("Resolution");

                    double horzRes        = usrResolutionSet ? (double)image.Resolution : xImage.HorizontalResolution;
                    XUnit  inherentWidth  = XUnit.FromInch(xPixels / horzRes);
                    double yPixels        = xImage.PixelHeight;
                    double vertRes        = usrResolutionSet ? (double)image.Resolution : xImage.VerticalResolution;
                    XUnit  inherentHeight = XUnit.FromInch(yPixels / vertRes);

                    bool lockRatio = this.image.IsNull("LockAspectRatio") ? true : image.LockAspectRatio;

                    double scaleHeight    = this.image.ScaleHeight;
                    double scaleWidth     = this.image.ScaleWidth;
                    bool   scaleHeightSet = !this.image.IsNull("ScaleHeight");
                    bool   scaleWidthSet  = !this.image.IsNull("ScaleWidth");

                    if (lockRatio)
                    {
                        if (usrWidthSet && usrHeightSet)
                        {
                            if (inherentHeight / usrHeight > inherentWidth / usrWidth)
                            {
                                usrWidthSet = false;
                            }
                            else
                            {
                                usrHeightSet = false;
                            }
                        }
                        if (usrWidthSet && !usrHeightSet)
                        {
                            resultHeight = inherentHeight / inherentWidth * usrWidth;
                        }
                        else if (usrHeightSet && !usrWidthSet)
                        {
                            resultWidth = inherentWidth / inherentHeight * usrHeight;
                        }
                        else if (!usrHeightSet && !usrWidthSet)
                        {
                            resultHeight = inherentHeight;
                            resultWidth  = inherentWidth;
                        }

                        if (scaleHeightSet || scaleHeightSet && scaleWidthSet && scaleHeight < scaleWidth)
                        {
                            resultHeight = resultHeight * scaleHeight;
                            resultWidth  = resultWidth * scaleHeight;
                        }
                        else if (scaleWidthSet || scaleHeightSet && scaleWidthSet && scaleHeight > scaleWidth)
                        {
                            resultHeight = resultHeight * scaleWidth;
                            resultWidth  = resultWidth * scaleWidth;
                        }
                    }
                    else
                    {
                        if (!usrHeightSet)
                        {
                            resultHeight = inherentHeight;
                        }

                        if (!usrWidthSet)
                        {
                            resultWidth = inherentWidth;
                        }

                        if (scaleHeightSet)
                        {
                            resultHeight = resultHeight * scaleHeight;
                        }
                        if (scaleWidthSet)
                        {
                            resultWidth = resultWidth * scaleWidth;
                        }
                    }

                    formatInfo.CropWidth  = (int)xPixels;
                    formatInfo.CropHeight = (int)yPixels;
                    if (!this.image.IsNull("PictureFormat"))
                    {
                        PictureFormat picFormat = this.image.PictureFormat;
                        //Cropping in pixels.
                        XUnit cropLeft   = picFormat.CropLeft.Point;
                        XUnit cropRight  = picFormat.CropRight.Point;
                        XUnit cropTop    = picFormat.CropTop.Point;
                        XUnit cropBottom = picFormat.CropBottom.Point;
                        formatInfo.CropX       = (int)(horzRes * cropLeft.Inch);
                        formatInfo.CropY       = (int)(vertRes * cropTop.Inch);
                        formatInfo.CropWidth  -= (int)(horzRes * ((XUnit)(cropLeft + cropRight)).Inch);
                        formatInfo.CropHeight -= (int)(vertRes * ((XUnit)(cropTop + cropBottom)).Inch);

                        //Scaled cropping of the height and width.
                        double xScale = resultWidth / inherentWidth;
                        double yScale = resultHeight / inherentHeight;

                        cropLeft   = xScale * cropLeft;
                        cropRight  = xScale * cropRight;
                        cropTop    = yScale * cropTop;
                        cropBottom = yScale * cropBottom;

                        resultHeight = resultHeight - cropTop - cropBottom;
                        resultWidth  = resultWidth - cropLeft - cropRight;
                    }
                    if (resultHeight <= 0 || resultWidth <= 0)
                    {
                        formatInfo.Width  = XUnit.FromCentimeter(2.5);
                        formatInfo.Height = XUnit.FromCentimeter(2.5);
                        Debug.WriteLine(AppResources.EmptyImageSize);
                        this.failure = ImageFailure.EmptySize;
                    }
                    else
                    {
                        formatInfo.Width  = resultWidth;
                        formatInfo.Height = resultHeight;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(string.Format(AppResources.ImageNotReadable, image.Source.ToString(), ex.Message));
                    formatInfo.Failure = ImageFailure.NotRead;
                }
                finally
                {
                    if (xImage != null)
                    {
                        xImage.Dispose();
                    }
                }
            }
            if (formatInfo.Failure != ImageFailure.None)
            {
                if (!this.image.IsNull("Width"))
                {
                    formatInfo.Width = this.image.Width.Point;
                }
                else
                {
                    formatInfo.Width = XUnit.FromCentimeter(2.5);
                }

                if (!this.image.IsNull("Height"))
                {
                    formatInfo.Height = this.image.Height.Point;
                }
                else
                {
                    formatInfo.Height = XUnit.FromCentimeter(2.5);
                }
                return;
            }
        }
Пример #20
0
    // TODO: incomplete - srcRect not used
    public void DrawImage(XImage image, XRect destRect, XRect srcRect, XGraphicsUnit srcUnit)
    {
      double x = destRect.X;
      double y = destRect.Y;
      double width = destRect.Width;
      double height = destRect.Height;

      string name = Realize(image);
      if (!(image is XForm))
      {
        if (this.gfx.PageDirection == XPageDirection.Downwards)
        {
          AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm {5} Do\nQ\n",
            x, y, width, height, y + height, name);
        }
        else
        {
          AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n",
            x, y, width, height, name);
        }
      }
      else
      {
        BeginPage();

        XForm xForm = (XForm)image;
        xForm.Finish();

        PdfFormXObject pdfForm = Owner.FormTable.GetForm(xForm);

        double cx = width / image.PointWidth;
        double cy = height / image.PointHeight;

        if (cx != 0 && cy != 0)
        {
          if (this.gfx.PageDirection == XPageDirection.Downwards)
          {
            AppendFormat("q {2:0.####} 0 0 -{3:0.####} {0:0.####} {4:0.####} cm 100 Tz {5} Do Q\n",
              x, y, cx, cy, y + height, name);
          }
          else
          {
            AppendFormat("q {2:0.####} 0 0 {3:0.####} {0:0.####} {1:0.####} cm {4} Do Q\n",
              x, y, cx, cy, name);
          }
        }
      }
    }
Пример #21
0
 /// <inheritdoc/>
 public override void Draw(object dc, XImage image, double dx, double dy, ImmutableArray <XProperty> db, XRecord r)
 {
     // TODO: Implement Draw image.
 }