Exemplo n.º 1
0
        public string CalculatedVirtualPath()
        {
            var parents = GetAllParentMediaDetails(this.LanguageID).Reverse();

            var virtualPath = "";

            foreach (var parent in parents)
            {
                if (parent is RootPage || parent is Website)
                {
                    continue;
                }

                virtualPath = StringHelper.CreateSlug(parent.LinkTitle) + "/" + virtualPath;
            }

            if (virtualPath == "")
            {
                virtualPath = "~/";
            }

            virtualPath = URIHelper.ConvertAbsUrlToTilda(virtualPath);

            return(virtualPath);
        }
Exemplo n.º 2
0
 private void DownloadPDF(byte[] downloadBytes, string downloadName)
 {
     System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
     response.Clear();
     response.AddHeader("Content-Type", "binary/octet-stream");
     response.AddHeader("Content-Disposition",
                        "attachment; filename=" + StringHelper.CreateSlug(downloadName) + ".pdf; size=" + downloadBytes.Length.ToString());
     response.Flush();
     response.BinaryWrite(downloadBytes);
     response.Flush();
     response.End();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Shortcut to generate PDF documents
        /// </summary>
        /// <param name="pathToPdfBodyTemplate">The path to PDF body template.</param>
        /// <param name="pathToPdfFooterTemplate">The path to PDF footer template.</param>
        /// <param name="objectToPassInToTemplate">The object to pass in to template.</param>
        /// <param name="keyValuePairTemplateVariables">The key value pair template variables.</param>
        /// <param name="downloadFileName">Name of the download file.</param>
        public static void QuickPDFGenerator(string pathToPdfBodyTemplate, string downloadFileName, string pathToPdfFooterTemplate = "", object objectToPassInToTemplate = null, Dictionary <string, string> keyValuePairTemplateVariables = default(Dictionary <string, string>))
        {
            string bodyHtml = ParserHelper.ParseData(LoaderHelper.RenderControl(pathToPdfBodyTemplate, objectToPassInToTemplate), keyValuePairTemplateVariables);

            string footerHtml = "";

            if (pathToPdfFooterTemplate == null)
            {
                footerHtml = ParserHelper.ParseData(LoaderHelper.RenderControl(pathToPdfFooterTemplate, objectToPassInToTemplate), keyValuePairTemplateVariables);
            }

            PDFHelper pdfHelper = new PDFHelper("Header Text");

            if (footerHtml != "")
            {
                pdfHelper.Converter.PdfFooterOptions.ShowPageNumber = false;
                pdfHelper.Converter.PdfFooterOptions.HtmlToPdfArea  = new HtmlToPdfArea(footerHtml, URIHelper.BaseUrl);
            }

            pdfHelper.ConvertHTMLToPDF(bodyHtml, StringHelper.CreateSlug(downloadFileName));
        }
Exemplo n.º 4
0
        public string GetFieldAssociationsAsString(string fieldCode, string seperator = ",", bool AsCssClasses = false)
        {
            var fieldAssociations = (LoadField(fieldCode) as MediaDetailField)?.FieldAssociations;
            var items             = new List <string>();

            if (fieldAssociations != null)
            {
                foreach (var fieldAssociation in fieldAssociations)
                {
                    var name = fieldAssociation.MediaDetail.SectionTitle;

                    if (AsCssClasses)
                    {
                        name = StringHelper.CreateSlug(name);
                    }

                    items.Add(name);
                }
            }

            var str = string.Join(seperator, items);

            return(str);
        }