public byte[] DevexHtmlToPdfExport(string htmlContentString, int invoiceId)
        {
            HtmlEditorSettings settings = new HtmlEditorSettings();

            settings.SettingsHtmlEditing.AllowedDocumentType      = AllowedDocumentType.Both;
            settings.SettingsHtmlEditing.AllowFormElements        = true;
            settings.SettingsHtmlEditing.AllowIdAttributes        = true;
            settings.SettingsHtmlEditing.AllowIFrames             = true;
            settings.SettingsHtmlEditing.AllowStyleAttributes     = true;
            settings.SettingsHtmlEditing.UpdateDeprecatedElements = true;
            settings.SettingsHtmlEditing.UpdateBoldItalic         = true;

            settings.Name       = "Invoice";
            settings.ActiveView = HtmlEditorView.Design;
            settings.Html       = htmlContentString;

            settings.CssFiles.Add(HttpContext.Request.ApplicationPath.TrimEnd("/"[0]) + "/Content/fontawesome/css/font-awesome.min.css");
            settings.CssFiles.Add(HttpContext.Request.ApplicationPath.TrimEnd("/"[0]) + "/Content/Themes/UI-WZ/jquery-ui.css");
            settings.CssFiles.Add(HttpContext.Request.ApplicationPath.TrimEnd("/"[0]) + "/Content/site.css");
            settings.CssFiles.Add(HttpContext.Request.ApplicationPath.TrimEnd("/"[0]) + "/Content/bootstrap.css");

            var filePath     = Server.MapPath(" ~/UploadedFiles/Invoices/" + invoiceId + "_") + DateTime.UtcNow.ToString("ddMMyyyyHHmmssfff") + ".pdf";
            var outputStream = System.IO.File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);

            HtmlEditorExtension.Export(settings, outputStream, HtmlEditorExportFormat.Pdf);
            var result = outputStream.ToByteArray();

            outputStream.Close();
            return(result);
        }
        public static HtmlEditorSettings SetHtmlEditorExportSettings(HtmlEditorSettings settings)
        {
            settings.Name = "heImportExport";
            settings.CallbackRouteValues = new { Controller = "HtmlEditor", Action = "ImportExportPartial" };
            settings.ExportRouteValues   = new { Controller = "HtmlEditor", Action = "ExportTo" };

            var toolbar = settings.Toolbars.Add();

            toolbar.Items.Add(new ToolbarUndoButton());
            toolbar.Items.Add(new ToolbarRedoButton());
            toolbar.Items.Add(new ToolbarBoldButton(true));
            toolbar.Items.Add(new ToolbarItalicButton());
            toolbar.Items.Add(new ToolbarUnderlineButton());
            toolbar.Items.Add(new ToolbarStrikethroughButton());
            toolbar.Items.Add(new ToolbarInsertImageDialogButton(true));
            ToolbarExportDropDownButton saveButton = new ToolbarExportDropDownButton(true);

            saveButton.CreateDefaultItems();
            toolbar.Items.Add(saveButton);

            settings.PreRender = (sender, e) => {
                ASPxHtmlEditor editor = (ASPxHtmlEditor)sender;
                editor.Width = Unit.Percentage(100);
            };

            return(settings);
        }
Exemplo n.º 3
0
        public ActionResult Izvezi(string format)
        {
            var settings = new HtmlEditorSettings();

            Customize(settings);
            var fileName     = "IzvozTeksta";
            var formatTeksta = HtmlEditorExportFormat.Rtf;

            switch (format)
            {
            case "Rtf":
                fileName += ".rtf";
                break;

            case "Txt":
                fileName    += ".txt";
                formatTeksta = HtmlEditorExportFormat.Txt;
                break;

            case "Pdf":
                fileName    += ".pdf";
                formatTeksta = HtmlEditorExportFormat.Pdf;
                break;

            case "Docx":
                fileName    += ".docx";
                formatTeksta = HtmlEditorExportFormat.Docx;
                break;
            }
            return(HtmlEditorExtension.Export(settings, formatTeksta, fileName));
        }
Exemplo n.º 4
0
 public static void Customize(HtmlEditorSettings settings)
 {
     settings.Name = "Html";
     settings.CallbackRouteValues        = new { action = "Editor" };
     settings.Settings.AllowHtmlView     = false;
     settings.SettingsText.DesignViewTab = "Unos";
     settings.SettingsText.PreviewTab    = "Pregled";
 }
        public static void SetupGlobalUploadBehaviour(HtmlEditorSettings settings)
        {
            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.FileSystemSettings.Assign(HtmlEditorFeaturesDemosHelper.FileSaveSettings.FileSystemSettings);
            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.ValidationSettings.Assign(HtmlEditorFeaturesDemosHelper.ImageUploadValidationSettings);

            long maxFileSize = 5 * 1024 * 1024;

            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertImageDialog.SettingsImageSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertAudioDialog.SettingsAudioUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertAudioDialog.SettingsAudioSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertFlashDialog.SettingsFlashUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertFlashDialog.SettingsFlashSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertVideoDialog.SettingsVideoUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertVideoDialog.SettingsVideoSelector.UploadSettings.ValidationSettings.MaxFileSize   = maxFileSize;
            settings.SettingsDialogs.InsertLinkDialog.SettingsDocumentSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.Init = (s, e) =>
            {
                var htmlEditor = s as DevExpress.Web.ASPxHtmlEditor.ASPxHtmlEditor;
                htmlEditor.ImageFileSaving += OnImageFileSaving;
                htmlEditor.AudioFileSaving += OnAudioFileSaving;
                htmlEditor.FlashFileSaving += OnFlashFileSaving;
                htmlEditor.VideoFileSaving += OnVideoFileSaving;

                htmlEditor.AudioSelectorFileUploading += OnFileSelectorAction;
                htmlEditor.AudioSelectorItemRenaming  += OnFileSelectorAction;
                htmlEditor.AudioSelectorItemMoving    += OnFileSelectorAction;
                htmlEditor.AudioSelectorItemDeleting  += OnFileSelectorAction;
                htmlEditor.AudioSelectorItemCopying   += OnFileSelectorAction;

                htmlEditor.FlashSelectorFileUploading += OnFileSelectorAction;
                htmlEditor.FlashSelectorItemRenaming  += OnFileSelectorAction;
                htmlEditor.FlashSelectorItemMoving    += OnFileSelectorAction;
                htmlEditor.FlashSelectorItemDeleting  += OnFileSelectorAction;
                htmlEditor.FlashSelectorItemCopying   += OnFileSelectorAction;

                htmlEditor.ImageSelectorFileUploading += OnFileSelectorAction;
                htmlEditor.ImageSelectorItemRenaming  += OnFileSelectorAction;
                htmlEditor.ImageSelectorItemMoving    += OnFileSelectorAction;
                htmlEditor.ImageSelectorItemDeleting  += OnFileSelectorAction;
                htmlEditor.ImageSelectorItemCopying   += OnFileSelectorAction;

                htmlEditor.VideoSelectorFileUploading += OnFileSelectorAction;
                htmlEditor.VideoSelectorItemRenaming  += OnFileSelectorAction;
                htmlEditor.VideoSelectorItemMoving    += OnFileSelectorAction;
                htmlEditor.VideoSelectorItemDeleting  += OnFileSelectorAction;
                htmlEditor.VideoSelectorItemCopying   += OnFileSelectorAction;

                htmlEditor.DocumentSelectorFileUploading += OnFileSelectorAction;
                htmlEditor.DocumentSelectorItemRenaming  += OnFileSelectorAction;
                htmlEditor.DocumentSelectorItemMoving    += OnFileSelectorAction;
                htmlEditor.DocumentSelectorItemDeleting  += OnFileSelectorAction;
                htmlEditor.DocumentSelectorItemCopying   += OnFileSelectorAction;
            };
        }
        public static void SetupGlobalUploadBehaviour(HtmlEditorSettings settings)
        {
            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.FileSystemSettings.Assign(HtmlEditorFeaturesDemosHelper.FileSaveSettings.FileSystemSettings);
            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.ValidationSettings.Assign(HtmlEditorFeaturesDemosHelper.ImageUploadValidationSettings);

            long maxFileSize = 5 * 1024 * 1024;

            settings.SettingsDialogs.InsertImageDialog.SettingsImageUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertImageDialog.SettingsImageSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertAudioDialog.SettingsAudioUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertAudioDialog.SettingsAudioSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertFlashDialog.SettingsFlashUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertFlashDialog.SettingsFlashSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertVideoDialog.SettingsVideoUpload.ValidationSettings.MaxFileSize = maxFileSize;
            settings.SettingsDialogs.InsertVideoDialog.SettingsVideoSelector.UploadSettings.ValidationSettings.MaxFileSize   = maxFileSize;
            settings.SettingsDialogs.InsertLinkDialog.SettingsDocumentSelector.UploadSettings.ValidationSettings.MaxFileSize = maxFileSize;
        }
Exemplo n.º 7
0
 public MyHtmlEditorExtension(HtmlEditorSettings settings, ViewContext ctx)
     : base(settings, ctx)
 {
 }
Exemplo n.º 8
0
        public ActionResult Sacuvaj([Bind(Prefix = "Tekst")] Tekst tekst)
        {
            var htmlEditorSettings = new HtmlEditorSettings();

            Customize(htmlEditorSettings);

            //using (var ms = new MemoryStream())
            //{
            //    HtmlEditorExtension.Export(htmlEditorSettings, ms, HtmlEditorExportFormat.Rtf);
            //    ms.Position = 0;
            //    tekst.Rtf = Encoding.UTF8.GetString(ms.ToArray());
            //}
            //using (var ms = new MemoryStream())
            //{
            //    HtmlEditorExtension.Export(htmlEditorSettings, ms, HtmlEditorExportFormat.Txt);
            //    ms.Position = 0;
            //    tekst.PlainText = Encoding.UTF8.GetString(ms.ToArray());
            //}
            tekst.Html = HtmlEditorExtension.GetHtml("Html");

            var zaSnimanje = tekst.ID == 0 ? new Tekst() : fRepositoryFactory.TekstoviRepository.VratiTekst(tekst.ID);

            zaSnimanje.Datum         = tekst.Datum;
            zaSnimanje.PublikacijaID = tekst.PublikacijaID;
            zaSnimanje.RubrikaID     = tekst.RubrikaID;
            zaSnimanje.TipTekstaID   = tekst.TipTekstaID;
            zaSnimanje.Nadnaslov     = tekst.Nadnaslov;
            zaSnimanje.Naslov        = tekst.Naslov;
            zaSnimanje.Podnaslov     = tekst.Podnaslov;
            zaSnimanje.PlainText     = tekst.PlainText;
            zaSnimanje.Rtf           = tekst.Rtf;
            zaSnimanje.Html          = tekst.Html;
            zaSnimanje.AutorID       = tekst.AutorID;
            zaSnimanje.TrenutnoKodID = tekst.TrenutnoKodID;
            zaSnimanje.ArhiviraniTekstovi.Add(new ArhiviranTekst()
            {
                Html = zaSnimanje.Html
            });

            fRepositoryFactory.TekstoviRepository.Add(zaSnimanje);
            // Obrisi materijale
            foreach (var m in zaSnimanje.Materijali.ToArray())
            {
                if (tekst.Materijali.All(x => x.ID != m.ID))
                {
                    zaSnimanje.Materijali.Remove(m);
                }
            }
            // Dodaj materijale
            foreach (var m in tekst.Materijali)
            {
                if (zaSnimanje.Materijali.All((x => x.ID != m.ID)))
                {
                    zaSnimanje.Materijali.Add(m);
                    fRepositoryFactory.MaterijalRepository.MarkUnchanged(m);
                }
            }
            if (!zaSnimanje.IsValid)
            {
                TempData["StatusMessage"] = new StatusMessage("Podaci nisu validni", StatusMessageType.Error);
                return(View("Tekst", new UnosTekstaViewModel
                {
                    Tekst = zaSnimanje,
                    Publikacije = fRepositoryFactory.PublikacijeRepository.Publikacije(),
                    TipoviTeksta = fRepositoryFactory.TipoviTekstovaRepository.TipoviTekstova(),
                }));
            }
            fRepositoryFactory.TekstoviRepository.Save();
            TempData["StatusMessage"] = new StatusMessage("Podaci su uspešno snimljeni", StatusMessageType.Success);
            return(RedirectToAction("IzmenaTeksta", new { id = zaSnimanje.ID }));
        }