Exemple #1
0
 public PdfMerger(IWebHostEnvironment env, IStorage pdfStorage, PdfDataContext context, ILogger<PdfMerger> logger)
 {
     _env = env;
     _pdfStorage = pdfStorage;
     _context = context;
     _logger = logger;
 }
Exemple #2
0
 public PdfQueue(
     PdfDataContext context,
     IStorage storage,
     IMqMessages mqMessages,
     IOptions <CommonConfig> settings,
     ILogger <PdfQueue> logger)
 {
     _context      = context;
     _storage      = storage;
     _mqMessages   = mqMessages;
     _logger       = logger;
     _chromiumPath = settings.Value.PuppeteerChromiumPath ?? new BrowserFetcher().GetExecutablePath(BrowserFetcher.DefaultRevision);
 }
 public MergerController(
     IHangfireQueue backgroundJob,
     PdfDataContext context,
     IOptions <CommonConfig> settings,
     IMqMessages mqMessages,
     ILogger <MergerController> logger)
 {
     _backgroundJob = backgroundJob;
     _context       = context;
     _mqMessages    = mqMessages;
     _logger        = logger;
     _settings      = settings.Value;
 }
Exemple #4
0
 public PdfController(
     PdfDataContext context,
     IStorage pdfStorage,
     Uris uris,
     IHangfireQueue backgroundJob,
     TemplatingEngine templatingEngine,
     IErrorPages errorPages,
     IMqMessages mqMessages)
 {
     _context          = context;
     _pdfStorage       = pdfStorage;
     _uris             = uris;
     _backgroundJobs   = backgroundJob;
     _templatingEngine = templatingEngine;
     _errorPages       = errorPages;
     _mqMessages       = mqMessages;
 }
Exemple #5
0
        public override void ProcessObjectDataRequest(PdfDataContext context)
        {
            switch (context.Request.DataKey)
            {
            case "dynamic":
                //Create a dynamic image showing the date (200px by 50px)
                using (Bitmap bmp = new Bitmap(200, 50, PixelFormat.Format32bppArgb))
                {
                    //Create graphics object
                    using (Graphics gr = Graphics.FromImage(bmp))
                    {
                        //Set smoothing mode
                        gr.SmoothingMode = SmoothingMode.AntiAlias;

                        //Get the rect for the bitmap
                        RectangleF rect = gr.VisibleClipBounds;

                        //Create a new brush to draw background with
                        using (Brush br = new SolidBrush(Color.Yellow))
                        {
                            //Draw background
                            gr.FillRectangle(br, rect);
                        }

                        //Create a new brush to draw text with
                        using (Brush br = new SolidBrush(Color.Black))
                        {
                            //Create a new font to draw text with
                            using (Font ft = new Font("Arial", 20.0f, FontStyle.Regular, GraphicsUnit.Pixel))
                            {
                                //Create string format to draw text with
                                using (StringFormat sf = new StringFormat())
                                {
                                    //Set format properties
                                    sf.Alignment     = StringAlignment.Center;
                                    sf.LineAlignment = StringAlignment.Center;

                                    //Draw current date to bitmap
                                    gr.DrawString(DateTime.Now.ToString("yyyy-MM-dd\nhh:mm tt"), ft, br, rect, sf);
                                }
                            }
                        }
                    }

                    //Create output strea
                    using (MemoryStream ms = new MemoryStream())
                    {
                        //Save image to stream
                        bmp.Save(ms, ImageFormat.Gif);

                        //Write bytes to the response
                        context.Response.Write(ms.ToArray());
                    }
                }
                break;

            case "signature":
                //Write a file to the response
                //Alternatively, we could also use the .Write method to write data from almost any source (e.g. database, memory, etc.)
                context.Response.WriteFile(HttpContext.Current.Server.MapPath(@"images/signature.gif"));
                break;
            }
        }
    public override void ProcessObjectDataRequest(PdfDataContext context)
    {
        switch(context.Request.DataKey)
        {
            case "dynamic":
                //Create a dynamic image showing the date (200px by 50px)
                using(Bitmap bmp = new Bitmap(200, 50, PixelFormat.Format32bppArgb))
                {
                    //Create graphics object
                    using (Graphics gr = Graphics.FromImage(bmp))
                    {
                        //Set smoothing mode
                        gr.SmoothingMode = SmoothingMode.AntiAlias;

                        //Get the rect for the bitmap
                        RectangleF rect = gr.VisibleClipBounds;

                        //Create a new brush to draw background with
                        using (Brush br = new SolidBrush(Color.Yellow))
                        {
                            //Draw background
                            gr.FillRectangle(br, rect);
                        }

                        //Create a new brush to draw text with
                        using (Brush br = new SolidBrush(Color.Black))
                        {
                            //Create a new font to draw text with
                            using(Font ft = new Font("Arial", 20.0f, FontStyle.Regular, GraphicsUnit.Pixel))
                            {
                                //Create string format to draw text with
                                using (StringFormat sf = new StringFormat())
                                {
                                    //Set format properties
                                    sf.Alignment = StringAlignment.Center;
                                    sf.LineAlignment = StringAlignment.Center;

                                    //Draw current date to bitmap
                                    gr.DrawString(DateTime.Now.ToString("yyyy-MM-dd\nhh:mm tt"), ft, br, rect, sf);
                                }
                            }
                        }
                    }

                    //Create output strea
                    using (MemoryStream ms = new MemoryStream())
                    {
                        //Save image to stream
                        bmp.Save(ms, ImageFormat.Gif);

                        //Write bytes to the response
                        context.Response.Write(ms.ToArray());
                    }
                }
                break;

            case "signature":
                //Write a file to the response
                //Alternatively, we could also use the .Write method to write data from almost any source (e.g. database, memory, etc.)
                context.Response.WriteFile(HttpContext.Current.Server.MapPath(@"images/signature.gif"));
                break;
        }
    }
 public PdfUsageCountController(PdfDataContext context)
 {
     _context = context;
 }