Example #1
0
        //private ConnectionMultiplexer _redis;
        //private ConnectionMultiplexer ConnectionMultiplexer
        //{
        //    get
        //    {
        //        if (_redis == null || !_redis.IsConnected)
        //        {
        //            var settings = new Settings();
        //            var config = ConfigurationOptions.Parse(settings.RedisServerHost);
        //            config.KeepAlive = WaitForSeconds;
        //            config.ConnectTimeout = 5000;
        //            _redis = ConnectionMultiplexer.Connect(config);
        //        }
        //        return _redis;
        //    }
        //}

        public PdfGenerator(WkHtmltoPdfSwitches defaultSwitches)
        {
            Switches = defaultSwitches;
            AllowLoadingJavascriptbeforePdfGenerate = false;
            PaperSize = "Letter";
            _settings = new Settings();
        }
Example #2
0
        public ActionResult GenerateCalendarPdf(EventStaffAssignmentListModelFilter filter = null)
        {
            var    mediaLocation = IoC.Resolve <IMediaRepository>().GetTempMediaFileLocation();
            var    url           = Request.Url.OriginalString.Replace(Request.Url.Query, "");
            string newpdfpath    = url.Replace(Request.Url.AbsolutePath, "/Operations/Schedule/Print" + Request.Url.Query);

            var pdfConverterPath = Server.MapPath(@"~\bin");

            var wkHtmltoPdfSwitches =
                new WkHtmltoPdfSwitches()
            {
                MarginBottom  = 0.5m,
                MarginRight   = 0.5m,
                MarginLeft    = 1.5m,
                MarginTop     = 1m,
                RedirectDelay = 5000,
                Orientation   = "Landscape"
            };

            var pdfGenerator = IoC.Resolve <IPdfGenerator>();

            pdfGenerator.SetDefaultSwitch(wkHtmltoPdfSwitches);

            string pdfname = pdfGenerator.Generate(newpdfpath, mediaLocation.PhysicalPath, pdfConverterPath);

            Response.RedirectUser(mediaLocation.Url + pdfname);
            return(null);
        }
Example #3
0
        public ContentResult GeneratePdf(long eventId = 0, int shippingStatus = 1)
        {
            if (eventId < 0)
            {
                return(null);
            }
            var model = _operationsReportingService.GetCustomerLabels(eventId, shippingStatus);

            var pdfConverterPath = Server.MapPath(@"~\bin");

            string view = RenderView(@"~\Config\Content\Views\Shared\CustomerLabelListModel.cshtml", model);

            var mediaLocation       = _mediaRepository.GetTempMediaFileLocation();
            var wkHtmltoPdfSwitches =
                new WkHtmltoPdfSwitches()
            {
                MarginBottom  = 0.5m,
                MarginRight   = 0.5m,
                MarginLeft    = 1.5m,
                MarginTop     = 0.25m,
                PageSize      = "Letter",
                RedirectDelay = 100
            };

            var pdfGenerator = IoC.Resolve <IPdfGenerator>();

            pdfGenerator.SetDefaultSwitch(wkHtmltoPdfSwitches);

            var pdfname = pdfGenerator.Generate(new StringBuilder(view), mediaLocation.PhysicalPath, pdfConverterPath);

            var pdfUrl = mediaLocation.Url + "/" + pdfname;

            return(Content(pdfUrl));
        }
Example #4
0
        public ContentResult GenerateBatchLabelPdf(long eventId)
        {
            if (eventId < 0)
            {
                return(null);
            }
            var model = _operationsReportingService.GetBatchLabelsForEvent(eventId);

            var pdfConverterPath = Server.MapPath(@"~\bin");

            string view = RenderView(@"~\Areas\Operations\Views\Reports\BatchLabels.cshtml", model);

            var mediaLocation       = _mediaRepository.GetTempMediaFileLocation();
            var wkHtmltoPdfSwitches = new WkHtmltoPdfSwitches
            {
                MarginBottom  = 0,
                MarginRight   = 0,
                MarginLeft    = 0,
                MarginTop     = 0,
                PageSize      = "",
                PageWidth     = 70,
                PageHeight    = 25,
                RedirectDelay = 100
            };

            var pdfGenerator = IoC.Resolve <IPdfGenerator>();

            pdfGenerator.SetDefaultSwitch(wkHtmltoPdfSwitches);

            var pdfname = pdfGenerator.Generate(new StringBuilder(view), mediaLocation.PhysicalPath, pdfConverterPath);

            var pdfUrl = mediaLocation.Url + "/" + pdfname;

            return(Content(pdfUrl));
        }
Example #5
0
 public void SetDefaultSwitch(WkHtmltoPdfSwitches defaultSwitches)
 {
     Switches = defaultSwitches;
 }
Example #6
0
 public PdfGenerator()
 {
     Switches  = new WkHtmltoPdfSwitches();
     PaperSize = "Letter";
     _settings = new Settings();
 }