public void CreateDarPdfForSendMail(DiscountRequestModel model)
        {
            long quoteId   = model.QuoteId.Value;
            long projectId = model.ProjectId.Value;

            var urlAuth    = Utilities.DocumentServerURL();
            var controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

            bool showCostPricing = true;

            var urlDiscountRequestFormBody = string.Format("{0}/{1}?discountRequestId={2}&projectId={3}&quoteId={4}&showCostPricing={5}",
                                                           controller, "DiscountRequestPrint",
                                                           model.DiscountRequestId, projectId, quoteId, showCostPricing);

            var urlDiscountRequestFormHeader = string.Format("{0}/{1}",
                                                             controller, "DiscountRequestPrintHeader", projectId, quoteId);

            var urlDiscountRequestFormFooter = string.Format("{0}/{1}", controller, "DiscountRequestPrintFooter");

            var pdf = new PdfConvertor();

            var web = new WebClientLocal(System.Web.HttpContext.Current);

            pdf.Options.NoLink             = false;
            pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlDiscountRequestFormHeader);
            pdf.Options.FooterHtmlFormat   = web.DownloadString(urlDiscountRequestFormFooter);
            pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

            pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);
            pdf.AppendHtml(web.DownloadString(urlDiscountRequestFormBody));

            string root        = System.Web.HttpContext.Current.Server.MapPath("~");
            string parent      = System.IO.Path.GetDirectoryName(root);
            string grandParent = System.IO.Path.GetDirectoryName(parent);

            string _last5DigitsOfProjectId = model.ProjectId.ToString()
                                             .Substring(model.ProjectId.ToString().Length - 5);

            string nameFile = "Daikin City Discount Request " +
                              DateTime.Now.ToString("MM-dd-yyyy") +
                              "-" +
                              _last5DigitsOfProjectId + ".pdf";

            string subPath = grandParent + "/CustomerDataFiles/DiscountRequestFiles/" + model.QuoteId;

            bool exists = System.IO.Directory.Exists(subPath);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(subPath);
            }

            string filePath = grandParent + "/CustomerDataFiles/DiscountRequestFiles/" + model.QuoteId + "/" + nameFile;

            pdf.Document.Save(filePath);
        }
コード例 #2
0
        public FileResult GetPdf(string tableHtml, int id)
        {
            Pricing pricing = db.Pricings.Find(id);

            tableHtml = tableHtml.Replace("<span class=\"glyphicon glyphicon-ok\"></span>", "+");
            tableHtml = tableHtml.Replace("<span class=\"glyphicon glyphicon-remove\"></span>", "-");
            string fileName = "pricingDownload-" + DateTime.Now.ToString("u").Replace(':', '-').Replace('.', '-').Replace(' ', '-') + ".pdf";
            var    result   = PdfConvertor.ConvertReport(tableHtml, fileName);

            return(File(result, MediaTypeNames.Application.Pdf, fileName));
        }
コード例 #3
0
        public ServiceResponse QuotePackageCreate(SubmittalRequestModel model)
        {
            //bool chkAllSubmittalSheets = (Request.Form["chkAllSubmittalSheets"] != null);
            //bool chkAllInstallationManuals = (Request.Form["chkAllInstallationManuals"] != null);
            //bool chkAllOperationalManuals = (Request.Form["chkAllOperationalManuals"] != null);
            //bool chkAllGuideSpecs = (Request.Form["chkAllGuideSpecs"] != null);
            //bool chkAllProductBrochures = (Request.Form["chkAllProductBrochures"] != null);

            //bool chkAllRevitDrawing = (Request.Form["chkAllRevitDrawing"] != null);
            //bool chkAllCADDrawing = (Request.Form["chkAllCADDrawing"] != null);
            //bool chkAllProductFlyer = (Request.Form["chkAllProductFlyer"] != null);

            var quotePackage   = submittalService.GetQuoteQuotePackage(this.CurrentUser, model).Model as SubmittalRequestModel;
            var currentProject = projectService.GetProjectModel(this.CurrentUser, model.ProjectId).Model as ProjectModel;

            //ViewData["CurrentUser"] = this.CurrentUser;

            var currentProjectNameAsFileName = currentProject.Name;

            //create valid filename out of project name
            foreach (char c in System.IO.Path.GetInvalidFileNameChars())
            {
                currentProjectNameAsFileName = currentProjectNameAsFileName.Replace(c, '_');
            }

            var coverPageModel = new QuotePackageModel
            {
                Quote = quoteService.GetQuoteModel(this.CurrentUser, model.ProjectId, model.QuoteId).Model as QuoteModel
            };

            coverPageModel.Quote.Project     = currentProject;
            coverPageModel.AttachedFiles     = quotePackage.QuotePackageAttachedFiles;
            coverPageModel.SelectedDocuments = new List <QuotePackageSelectedItemModel>();

            var documents = new List <string>();

            var existingDocs = new List <string>();

            foreach (var item in quotePackage.Items)
            {
                var itemForCoverPage = new QuotePackageSelectedItemModel
                {
                    ProductNumber = item.ProductNumber
                };

                // var itemForCoverPage = new QuotePackageSelectedItemModel();

                if (item.LineItemTypeId == (byte)LineItemTypeEnum.Configured)
                {
                    itemForCoverPage.ProductNumber = item.CodeString;
                }
                else
                {
                    itemForCoverPage.ProductNumber = item.ProductNumber;
                }

                foreach (var document in item.Documents)
                {
//                    var isSelected = (Request.Form["doc" + document.FileName] + "" != "");
//
//                    if (isSelected == false) isSelected = (chkAllSubmittalSheets && document.DocumentTypeId == (int)DocumentTypeEnum.SubmittalData);
//                    if (isSelected == false) isSelected = (chkAllInstallationManuals && document.DocumentTypeId == (int)DocumentTypeEnum.InstallationManual);
//                    if (isSelected == false) isSelected = (chkAllOperationalManuals && document.DocumentTypeId == (int)DocumentTypeEnum.OperationManual);
//                    if (isSelected == false) isSelected = (chkAllProductBrochures && document.DocumentTypeId == (int)DocumentTypeEnum.ProductBrochure);
//                    if (isSelected == false) isSelected = (chkAllGuideSpecs && document.DocumentTypeId == (int)DocumentTypeEnum.WrittenGuideSpec);
//                    if (isSelected == false) isSelected = (chkAllRevitDrawing && document.DocumentTypeId == (int)DocumentTypeEnum.RevitDrawing);
//                    if (isSelected == false) isSelected = (chkAllCADDrawing && document.DocumentTypeId == (int)DocumentTypeEnum.CADDrawing);
//                    if (isSelected == false) isSelected = (chkAllProductFlyer && document.DocumentTypeId == (int)DocumentTypeEnum.ProductFlyer);
                    var isSelected = false; //temporary fix
                    if (isSelected && !existingDocs.Exists(n => n == document.FileName))
                    {
                        if (item.LineItemTypeId == (byte)LineItemTypeEnum.Configured)
                        {
                            itemForCoverPage.Items.Add((int)document.DocumentTypeId);
                            documents.Add(item.CodeString + "@" + "Configured Submittl Datasheet" + "@" + document.AbsoultePath);
                        }
                        else
                        {
                            itemForCoverPage.Items.Add((int)document.DocumentTypeId);
                            documents.Add(item.ProductNumber + "@" + document.Type + "@" + document.AbsoultePath);
                        }

                        existingDocs.Add(document.FileName);
                    }
                }

                if (itemForCoverPage.Items.Count > 0)
                {
                    coverPageModel.SelectedDocuments.Add(itemForCoverPage);
                }
            }

            //bool chkAllAttachedFiles = (Request.Form["chkAllAttachedFiles"] != null);

            var quotePackageDirectory = Utilities.GetQuotePackageDirectory(model.QuoteId.Value);

            var quotePackageFilename = quotePackageDirectory + Utilities.QuotePackageFileName(model.QuoteId.Value);

            documents = documents.Distinct().ToList();

            if (documents.Count > 0 || quotePackage.QuotePackageAttachedFiles.Count() > 0)
            {
                var locked = true;

                var lockFile = quotePackageFilename.Replace(".zip", ".lck");

                try
                {
                    lock (htmlService)
                    {
                        locked = (System.IO.File.Exists(lockFile));

                        if (!locked)
                        {
                            System.IO.File.Create(lockFile).Close();
                        }
                    }

                    if (!locked)
                    {
                        if (System.IO.File.Exists(quotePackageFilename))
                        {
                            System.IO.File.Delete(quotePackageFilename);
                        }

                        using (var zip = ZipFile.Open(quotePackageFilename, ZipArchiveMode.Create))
                        {
                            var productNumbers = "";
                            var builder        = new System.Text.StringBuilder();
                            builder.Append(productNumbers);

                            foreach (var doc in documents)
                            {
                                var split = doc.Split('@');

                                var productnumber = split[0];

                                var type = split[1];
                                var file = split[2];


                                if (type.ToLower().Contains("submittal"))
                                {
                                    type = "Submittals Sheets";
                                    builder.Append((productNumbers.Length == 0) ? productnumber : ("," + productnumber));
                                }
                                else
                                {
                                    var filename = System.IO.Path.GetFileName(file).Replace("GENERATED_", "");
                                    var fileRef  = (type + "\\" + filename);
                                    if (System.IO.File.Exists(file))
                                    {
                                        zip.CreateEntryFromFile(file, fileRef, CompressionLevel.Optimal);
                                    }
                                }
                            }
                            productNumbers = builder.ToString();

                            if (productNumbers.Length > 0)
                            {
                                var sdsfile = quotePackageDirectory + "DPO_QuotePackage_SubmittalDataSheets.pdf";

                                var pdf            = new PdfConvertor();
                                var productService = new ProductServices();

                                foreach (var productNumber in productNumbers.Split(','))
                                {
                                    //add product tags, project info and user info to header of each submittal sheet
                                    //if no specific template type if given, add in the external submittal sheet(if it exists)
                                    var product = quotePackage.Items.Where(x => x.ProductNumber == productNumber).FirstOrDefault();

                                    if (product.GetSubmittalSheetTemplateName != "SubmittalTemplate")
                                    {
                                        var file = productService.GenerateSubmittalDataFileForPackage(productNumber, product.QuoteItemId, currentProject.ProjectId);

                                        if (file != null)
                                        {
                                            pdf.AppendHtml(file);
                                        }
                                    }
                                    else
                                    {
                                        var submittalDocument = product.Documents.Where(d => d.DocumentTypeId == (int)DocumentTypeEnum.SubmittalData).FirstOrDefault();

                                        var fullFile = Utilities.GetSubmittalDirectory() + submittalDocument.FileName + @".pdf";

                                        if (System.IO.File.Exists(fullFile))
                                        {
                                            pdf.AppendFile(fullFile);
                                        }
                                    }
                                }

                                pdf.WriteToFile(sdsfile);

                                if (System.IO.File.Exists(sdsfile))
                                {
                                    zip.CreateEntryFromFile(sdsfile, "Submittals Sheets\\SDS_" + currentProjectNameAsFileName + ".pdf", CompressionLevel.Optimal);
                                }
                            }

                            foreach (var doc in quotePackage.QuotePackageAttachedFiles.ToList())
                            {
                                var fullFile = quotePackageDirectory + doc.FileName;

                                if (System.IO.File.Exists(fullFile))
                                {
                                    var filename = System.IO.Path.GetFileName(fullFile);

                                    //bool isSelected = (Request.Form["doc" + doc.FileName] + "" != "");

                                    //if (isSelected == false) isSelected = (chkAllAttachedFiles && doc.DocumentTypeId == (int)DocumentTypeEnum.QuotePackageAttachedFile);

                                    //f (isSelected)
                                    //{
                                    zip.CreateEntryFromFile(fullFile, "AttachedFiles\\" + filename, CompressionLevel.Optimal);
                                    //}
                                }
                            }
                        }

                        //var coverPageFile = projectService.GenerateQuotePackageCoverPageFile((long)model.QuoteId, base.RenderView(this, "QuotePackageCoverPage", coverPageModel));

                        // if (coverPageFile != null)
                        // {
                        using (var zip = ZipFile.Open(quotePackageFilename, ZipArchiveMode.Update))
                        {
                            //zip.CreateEntryFromFile(coverPageFile, "CoverSheet_" + currentProjectNameAsFileName + ".pdf", CompressionLevel.Optimal);
                        }
                        //}
                    }

                    // this.Response.ContentType = MimeMapping.GetMimeMapping(quotePackageFilename);
                    //Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "QuotePackage_" + currentProjectNameAsFileName + ".zip"));
                    //Response.TransmitFile(quotePackageFilename);

                    return(null);
                }
                finally
                {
                    lock (htmlService)
                    {
                        if (!locked)
                        {
                            System.IO.File.Delete(lockFile);
                        }
                    }
                }
            }

            // return base.RedirectToAction("QuotePackage", new { ProjectId = model.ProjectId, QuoteId = model.QuoteId });
            return(null);
        }
コード例 #4
0
        public void CreateOrderFormPdfForSendMail(OrderViewModelLight orderVMLight)
        {
            log.InfoFormat("Enter CreateOrderFormPdfForSendMail");

            long quoteId    = orderVMLight.QuoteId;
            long projectId  = orderVMLight.ProjectId;
            var  urlAuth    = Utilities.DocumentServerURL();
            var  controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

            var urlOrderFormBody   = string.Format("{0}/{1}?orderId={2}&projectId={3}&quoteId={4}", controller, "OrderPrint", orderVMLight.OrderId, projectId, quoteId);
            var urlOrderFormHeader = string.Format("{0}/{1}", controller, "OrderPrintHeader", projectId, quoteId);
            var urlOrderFormFooter = string.Format("{0}/{1}", controller, "OrderPrintFooter");

            log.DebugFormat("quoteId: {0}, projectId: {1}, url:{2}, controller:{3}",
                            quoteId, projectId, urlAuth, controller);

            log.DebugFormat("urlOrderFormBody: {0}", urlOrderFormBody);

            var pdf = new PdfConvertor();
            var web = new WebClientLocal(System.Web.HttpContext.Current);

            pdf.Options.NoLink             = false;
            pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlOrderFormHeader);
            pdf.Options.FooterHtmlFormat   = web.DownloadString(urlOrderFormFooter);
            pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

            pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);
            pdf.AppendHtml(web.DownloadString(urlOrderFormBody));

            string root        = System.Web.HttpContext.Current.Server.MapPath("~");
            string parent      = System.IO.Path.GetDirectoryName(root);
            string grandParent = System.IO.Path.GetDirectoryName(parent);

            log.DebugFormat("root directory: {0}", root);

            string _last5DigitsOfProjectId = orderVMLight.ProjectIdStr.Substring(orderVMLight.ProjectIdStr.Length - 5);
            string nameFile = "Daikin City Order " +
                              DateTime.Now.ToString("MM-dd-yyyy") +
                              "-" +
                              _last5DigitsOfProjectId + ".pdf";

            string subPath = grandParent + "/CustomerDataFiles/OrderSubmitFiles/" + orderVMLight.QuoteId;

            log.DebugFormat("subPath: {0}", subPath);

            bool exists = System.IO.Directory.Exists(subPath);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(subPath);
            }

            string filePath = grandParent + "/CustomerDataFiles/OrderSubmitFiles/" + orderVMLight.QuoteId + "/" + nameFile;

            log.DebugFormat("filePath: {0}", filePath);

            try
            {
                pdf.Document.Save(filePath);
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Create pdf error for file name:{0}", filePath);
                log.ErrorFormat("Error Message: {0}", ex.Message);
                log.ErrorFormat("Error Details Message: {0}", ex.InnerException.Message);
                log.ErrorFormat("Error Stack Trace: {0}", ex.StackTrace);
            }

            log.InfoFormat("Finished CreateOrderFormPdfForSendMail");
        }
コード例 #5
0
 public ActionResult Test()
 {
     PdfConvertor.AddTask(Guid.NewGuid().ToString());
     return(Content(DateTime.Now.ToString()));
 }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            var urlAuth = Utilities.DocumentServerURL();

            if (string.Compare(this.type, "QuotePrint", true) == 0 || string.Compare(this.type, "QuotePrintWithCostPrice", true) == 0)
            {
                var projectId = this.id;

                var quoteId = context.Request["quoteId"] as string;

                var controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

                var urlQuoteHeader = string.Format("{0}/{1}/{2}/{3}", controller, "QuotePrintHeader", projectId, quoteId);
                var urlQuoteBody   = string.Format("{0}/{1}/{2}/{3}", controller, this.type, projectId, quoteId);
                var urlQuoteFooter = string.Format("{0}/{1}/{2}/{3}", controller, "QuotePrintFooter", projectId, quoteId);

                var pdf = new PdfConvertor();

                var web = new WebClientLocal(HttpContext.Current);

                pdf.Options.NoLink = false;

                pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlQuoteHeader);
                pdf.Options.FooterHtmlFormat   = web.DownloadString(urlQuoteFooter);
                pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

                pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);

                pdf.AppendHtml(web.DownloadString(urlQuoteBody));

                pdf.WriteToSession("Quote Print");

                return;
            }

            if (string.Compare(this.type, "SubmittalTemplate", true) == 0)
            {
                var productNumber = this.id;

                var submittalFile = new ProductServices().GetSubmittalDataFile(productNumber);

                if (submittalFile != null)
                {
                    context.Response.ContentType = MimeMapping.GetMimeMapping(submittalFile);

                    context.Response.TransmitFile(submittalFile);
                }

                return;
            }

            if (string.Compare(this.type, "DiscountRequestPrint", true) == 0 || string.Compare(this.type, "DiscountRequestPrintWithCostPricing", true) == 0)
            {
                long discountRequestId = long.Parse(this.id);

                var quoteId   = context.Request["QuoteId"] as string;
                var projectId = context.Request["ProjectId"] as string;

                if (projectId == null)
                {
                    projectId = context.Request.Params["amp;ProjectId"] as string;
                }

                var controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

                var urlDiscountRequestFormBody   = string.Format("{0}/{1}?discountRequestId={2}&projectId={3}&quoteId={4}", controller, this.type, discountRequestId, projectId, quoteId);
                var urlDiscountRequestFormHeader = string.Format("{0}/{1}", controller, "DiscountRequestPrintHeader", projectId, quoteId);
                var urlDiscountRequestFormFooter = string.Format("{0}/{1}", controller, "DiscountRequestPrintFooter");

                var pdf = new PdfConvertor();

                var web = new WebClientLocal(HttpContext.Current);

                pdf.Options.NoLink             = false;
                pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlDiscountRequestFormHeader);
                pdf.Options.FooterHtmlFormat   = web.DownloadString(urlDiscountRequestFormFooter);
                pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

                pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);

                pdf.AppendHtml(web.DownloadString(urlDiscountRequestFormBody));

                var creaateDARpdf = false;

                if (context.Request.QueryString.ToString().Contains("createDARpdf=True"))
                {
                    creaateDARpdf = true;
                }

                string root        = System.Web.HttpContext.Current.Server.MapPath("~");
                string parent      = System.IO.Path.GetDirectoryName(root);
                string grandParent = System.IO.Path.GetDirectoryName(parent);


                string _last5DigitsOfProjectId = projectId.ToString().Substring(projectId.ToString().Length - 5);

                string nameFile = "Daikin City Discount " +
                                  DateTime.Now.ToString("MM-dd-yyyy") +
                                  "-" +
                                  _last5DigitsOfProjectId + ".pdf";

                string filePath = grandParent + "/CustomerDataFiles/DiscountRequestFiles/" + quoteId + "/" + nameFile;

                if (creaateDARpdf == true)
                {
                    pdf.Document.Save(filePath);
                }
                else
                {
                    pdf.WriteToSession("Discount Request Form");
                }

                return;
            }

            if (string.Compare(this.type, "CommissionRequestPrint", true) == 0 || string.Compare(this.type, "CommissionRequestPrintWithCostPricing", true) == 0)
            {
                long commissionRequestId = long.Parse(this.id);

                var quoteId = context.Request["QuoteId"] as string;

                var query = context.Request.Url.Query as string;
                int index = query.IndexOf("ProjectId=");
                index += 10;

                string projectId = query.Substring(index, query.Length - index);

                var controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

                var urlCommissionRequestFormBody   = string.Format("{0}/{1}?commissionRequestId={2}&projectId={3}&quoteId={4}", controller, this.type, commissionRequestId, projectId, quoteId);
                var urlCommissionRequestFormHeader = string.Format("{0}/{1}", controller, "CommissionRequestPrintHeader", projectId, quoteId);
                var urlCommissionRequestFormFooter = string.Format("{0}/{1}", controller, "CommissionRequestPrintFooter");

                var pdf = new PdfConvertor();

                var web = new WebClientLocal(HttpContext.Current);

                pdf.Options.NoLink             = false;
                pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlCommissionRequestFormHeader);
                pdf.Options.FooterHtmlFormat   = web.DownloadString(urlCommissionRequestFormFooter);
                pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

                pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);

                pdf.AppendHtml(web.DownloadString(urlCommissionRequestFormBody));

                pdf.WriteToSession("Commission Request Form");

                return;
            }

            if (string.Compare(this.type, "OrderPrint", true) == 0 || string.Compare(this.type, "OrderPrintWithCostPricing", true) == 0)
            {
                var query = context.Request.Url.Query as string;

                var projectId = context.Request["projectId"] as string;

                query = query.Replace("&amp", "");
                int position = query.IndexOf("QuoteId=");
                position += 8;

                var quoteId = query.Substring(position, query.Length - position);

                long orderId = long.Parse(this.id);

                var controller = string.Format("{0}/{1}", urlAuth, "ProjectDashboard");

                var urlOrderFormBody   = string.Format("{0}/{1}?orderId={2}&projectId={3}&quoteId={4}", controller, this.type, orderId, projectId, quoteId);
                var urlOrderFormHeader = string.Format("{0}/{1}", controller, "OrderPrintHeader", projectId, quoteId);
                var urlOrderFormFooter = string.Format("{0}/{1}", controller, "OrderPrintFooter");

                var pdf = new PdfConvertor();

                var web = new WebClientLocal(HttpContext.Current);

                pdf.Options.NoLink             = false;
                pdf.Options.HeaderHtmlFormat   = web.DownloadString(urlOrderFormHeader);
                pdf.Options.FooterHtmlFormat   = web.DownloadString(urlOrderFormFooter);
                pdf.Options.FooterHtmlPosition = pdf.Options.OutputArea.Bottom - 1.25f;

                pdf.Options.OutputArea = new System.Drawing.RectangleF(0f, 1.25f, pdf.Options.OutputArea.Width, pdf.Options.OutputArea.Height - 2.5f);

                pdf.AppendHtml(web.DownloadString(urlOrderFormBody));


                //string root = System.Web.HttpContext.Current.Server.MapPath("~");
                //string parent = System.IO.Path.GetDirectoryName(root);
                //string grandParent = System.IO.Path.GetDirectoryName(parent);

                //string nameFile = orderId.ToString() + ".pdf";

                //string subPath = grandParent + "/CustomerDataFiles/OrderSubmitFiles/" + orderId;

                //bool exists = System.IO.Directory.Exists(subPath);

                //if (!exists)
                //    System.IO.Directory.CreateDirectory((subPath));

                //string filePath = grandParent + "/CustomerDataFiles/OrderSubmitFiles/" + orderId + "/" + nameFile;

                //pdf.Document.Save(filePath);

                pdf.WriteToSession("Order Form");

                return;
            }

            //http://www.daikincity.com/document/dar/320370835699269632/?filename=132%20W%20%2026th%20St%20%20Quote%20_Rose%20Mech_REV%20_%204%202%2015.pdf
            if (string.Compare(this.type, "DAR", true) == 0)
            {
                long quoteid = long.Parse(this.id);

                string darfile = Path.Combine(Utilities.GetDARDirectory(quoteid), context.Request["filename"] as string);

                if (new AccountServices().CanAccessQuote(HttpContext.Current.User.Identity.Name, quoteid) && File.Exists(darfile))
                {
                    context.Response.ContentType = MimeMapping.GetMimeMapping(darfile);

                    context.Response.TransmitFile(darfile);
                }
                return;
            }

            //http://www.daikincity.com/document/quoteorder/320370835699269632/?filename=132%20W%20%2026th%20St%20%20Quote%20_Rose%20Mech_REV%20_%204%202%2015.pdf
            if (string.Compare(this.type, "QuoteOrder", true) == 0)
            {
                long quoteid = long.Parse(this.id);

                string poAttachment = Path.Combine(Utilities.GetPOAttachmentDirectory(quoteid), context.Request["filename"] as string);

                if (new AccountServices().CanAccessQuote(HttpContext.Current.User.Identity.Name, quoteid) && File.Exists(poAttachment))
                {
                    context.Response.ContentType = MimeMapping.GetMimeMapping(poAttachment);

                    context.Response.TransmitFile(poAttachment);
                }
                return;
            }

            context.Response.Clear();

            var file = Utilities.GetDocumentLocation(type, id);

            //TODO Get image from webservice then save as file
            if (file == null)
            {
                context.Response.StatusCode = 404;
                return;
            }

            context.Response.ContentType = MimeMapping.GetMimeMapping(file);

            context.Response.TransmitFile(file);

            return;
        }