private string HtmlExport(SectionDocument document, string pageRange)
        {
            if (!Directory.Exists(_htmlPath))
            {
                Directory.CreateDirectory(_htmlPath);
            }

            using (var htmlExport = new HtmlExport())
                htmlExport.Export(document, _htmlFilePath, pageRange);
            return(GetHtmlString());
        }
Beispiel #2
0
        public void Show(IInfo info)
        {
            HtmlExport exp  = new HtmlExport();
            string     path = info.GetTemp("kfpl.html");

            bool tryoutConsole = info.Settings.Get <bool>("kfpl.console");
            bool success       = exp.Exp(info.Timetable, path, info, tryoutConsole);

            if (success)
            {
                Process.Start(path);
            }
        }
Beispiel #3
0
        /// <summary>
        /// This prerender method is overriden so it saves the CSS rules to the head part of the html file.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (HtmlExport == null || HtmlExport.Workbook == null)
            {
                return;
            }


            string HtmlFileName = HttpContext.Current.Request.PhysicalPath;

            DeleteTemporaryImages();


            FExportState           = new TPartialExportState(null, null);
            HtmlExport.ClassPrefix = "flx_" + this.ID + "_";


            if (SheetExport == THtmlSheetExport.AllVisibleSheets)
            {
                int SaveActiveSheet = HtmlExport.Workbook.ActiveSheet;
                try
                {
                    for (int sheet = 1; sheet <= HtmlExport.Workbook.SheetCount; sheet++)
                    {
                        HtmlExport.Workbook.ActiveSheet = sheet;
                        if (HtmlExport.Workbook.SheetVisible != TXlsSheetVisible.Visible)
                        {
                            continue;
                        }

                        HtmlExport.PartialExportAdd(FExportState, HtmlFileName, FRelativeImagePath, ImageExportMode != TImageExportMode.CustomStorage);
                    }
                }
                finally
                {
                    HtmlExport.Workbook.ActiveSheet = SaveActiveSheet;
                }
            }
            else
            {
                HtmlExport.PartialExportAdd(FExportState, HtmlFileName, FRelativeImagePath, ImageExportMode != TImageExportMode.CustomStorage);
            }

            StyleSheetControl StyleSheet = new StyleSheetControl(FExportState);

            this.Page.Header.Controls.Add(StyleSheet);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;

            // select export format type
            switch (identificator)
            {
            case EXPORT_EXTENSION_HTM:
            case EXPORT_TYPE_NAME_HTM:
                export = new HtmlExport();
                break;

            case EXPORT_EXTENSION_PDF:
            case EXPORT_TYPE_NAME_PDF:
                export = new PdfExport();
                break;

            case EXPORT_EXTENSION_RTF:
            case EXPORT_TYPE_NAME_RTF:
                export = new RtfExport();
                break;

            case EXPORT_EXTENSION_TIF:
            case EXPORT_TYPE_NAME_TIF:
                export = new TiffExport();
                break;

            case EXPORT_EXTENSION_TXT:
            case EXPORT_TYPE_NAME_TXT:
                export = new TextExport();
                break;

            case EXPORT_EXTENSION_XLS:
            case EXPORT_TYPE_NAME_XLS:
                export = new XlsExport();
                break;

            default:
                Debug.Assert(false);     // NOTE: not supported
                break;
            }

            return(export);
        }
Beispiel #5
0
        public void ProcessRequest(HttpContext context)
        {
            if (!context.Request.Url.AbsolutePath.EndsWith(HandlerExtension))
            {
                if (!context.Request.Url.AbsolutePath.EndsWith(HandlerCacheExtension))
                {
                    return;
                }

                // return image
                var keyName   = Path.GetFileName(context.Request.FilePath);
                var cacheItem = context.Cache[keyName];
                context.Response.BinaryWrite((byte[])cacheItem);
                return;
            }

            var rpxFile     = context.Server.MapPath(context.Request.Url.LocalPath);
            var htmlHandler = new HtmlOutputHandler(context.Cache, Path.GetFileNameWithoutExtension(rpxFile));

            context.Response.ContentType = "text/html";
            try
            {
                using (var report = new SectionReport())
                    using (var reader = XmlReader.Create(rpxFile))
                    {
                        report.ResourceLocator = new DefaultResourceLocator(new Uri(Path.GetDirectoryName(rpxFile) + @"\"));
                        report.LoadLayout(reader);
                        report.Run(false);
                        using (var html = new HtmlExport {
                            IncludeHtmlHeader = true
                        })
                            html.Export(report.Document, htmlHandler, "");
                        report.Document.Dispose();
                    }
            }
            catch (ReportException eRunReport)
            {
                // Failure running report, just report the error to the user.
                context.Response.Write(Properties.Resource.Error);
                context.Response.Write(eRunReport.ToString());
                return;
            }

            context.Response.BinaryWrite(htmlHandler.MainPageData);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionReport rpt = new SectionReport();

            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\NwindLabels.rpx");
            rpt.LoadLayout(xtr);
            xtr.Close();
            try
            {
                rpt.Run(false);
            }
            catch (ReportException eRunReport)
            {
                // Show error message to the user when there is a failure in generating the report.
                Response.Clear();
                Response.Write("<h1>Error running report:</h1>");
                Response.Write(eRunReport.ToString());
                return;
            }
            // Used when the page output is already getting created.
            Response.Buffer = true;
            // Clear the output contents from the buffer stream.
            Response.ClearContent();
            // Clear any headers from the buffer stream (such as the content type for an HTML page).
            Response.ClearHeaders();
            // Notify the browser that cache should not be created.
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            // Specify the appropriate viewer for the browser.
            Response.ContentType = "text/html";
            // Create an instance of the HTMLExport class.
            HtmlExport html = new HtmlExport {
                IncludeHtmlHeader = true
            };

            // Export the report to HTML in this session's webcache.
            RpxHandler.HtmlOutputHandler output = new RpxHandler.HtmlOutputHandler(Cache, "Custom HTML");
            html.Export(rpt.Document, output, string.Empty);
            Response.BinaryWrite(output.MainPageData);
            // Send all buffered content to the client
            Response.End();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);

            Trace.Listeners.Add(myWriter);
            PFCDocAnalyzer pfcDoc = new PFCDocAnalyzer();
            KTKDocAnalyzer ktkDoc = new KTKDocAnalyzer();

            PowerScriptCompiler.AddAnalyzer(pfcDoc);
            PowerScriptCompiler.AddAnalyzer(ktkDoc);
            Workspace workspace = Workspace.Load(args[0], args[1]);

            workspace.Compile();
            ktkDoc.ResolveReferenceLinks(workspace.MainTarget, true);

            HtmlExport export = new HtmlExport();

            export.Export(workspace, args[2]);

            workspace.Close();
        }
Beispiel #8
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            FilterPosts(chkMatchRows.Checked);

            var saveFileDialog = new SaveFileDialog
            {
                InitialDirectory = Directory.GetCurrentDirectory(),
                Filter           =
                    "HTML Files (*.html) |*.html; *.HTML; *.Html |CSV Files (*.csv) |*.csv; *.CSV; *.Csv |All files (*.*)|*.*",
                FilterIndex      = 0,
                RestoreDirectory = true,
                Title            = "Export " + toSave.Count + " Posts..."
            };

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Console.WriteLine("File Extension: " + Path.GetExtension(saveFileDialog.FileName.ToLower()));

                    switch (Path.GetExtension(saveFileDialog.FileName.ToLower()))
                    {
                    case ".csv":
                        var csv = new CsvExport(toSave);
                        csv.ExportToFile(saveFileDialog.FileName);
                        break;

                    case ".html":
                        var html = new HtmlExport(toSave);
                        html.ExportToFile(saveFileDialog.FileName);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not save file to disk. Error: " + ex.Message);
                }
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;
            // select export format type
            switch (identificator)
            {
                case EXPORT_EXTENSION_HTM:
                case EXPORT_TYPE_NAME_HTM:
                    export = new HtmlExport();
                    break;

                case EXPORT_EXTENSION_PDF:
                case EXPORT_TYPE_NAME_PDF:
                    export = new PdfExport();
                    break;

                case EXPORT_EXTENSION_RTF:
                case EXPORT_TYPE_NAME_RTF:
                    export = new RtfExport();
                    break;

                case EXPORT_EXTENSION_TIF:
                case EXPORT_TYPE_NAME_TIF:
                    export = new TiffExport();
                    break;

                case EXPORT_EXTENSION_TXT:
                case EXPORT_TYPE_NAME_TXT:
                    export = new TextExport();
                    break;

                case EXPORT_EXTENSION_XLS:
                case EXPORT_TYPE_NAME_XLS:
                    export = new XlsExport();
                    break;

                default:
                    Debug.Assert(false); // NOTE: not supported
                    break;
            }

            return export;
        }
Beispiel #10
0
        private void Export()
        {
            if (Options() != "0") //only run if cancel not clicked
            {
                CommonDialog dialog = new CommonDialog();
                dialog.InitialDirectory = People.ApplicationFolderPath;
                dialog.Filter.Add(new FilterEntry(Properties.Resources.htmlFiles, Properties.Resources.htmlExtension));
                dialog.Title            = Properties.Resources.Export;
                dialog.DefaultExtension = Properties.Resources.DefaulthtmlExtension;
                dialog.ShowSave();

                if (string.IsNullOrEmpty(dialog.FileName))
                {
                    //return without doing anything if no file name is input
                }
                else
                {
                    if (!string.IsNullOrEmpty(dialog.FileName))
                    {
                        HtmlExport html = new HtmlExport();

                        int start = minYear;
                        int end   = DateTime.Now.Year;

                        string filename = dialog.FileName;
                        if (Options() == "1")
                        {
                            html.ExportAll(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());  //Export the all individuals
                        }
                        if (Options() == "2")
                        {
                            html.ExportCurrent(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "3")
                        {
                            html.ExportDirect(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());     //Export current person and immediate family relatives
                        }
                        if (Options() == "4")
                        {
                            html.ExportGenerations(family, source, repository, Ancestors(), Descendants(), dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "5")
                        {
                            html.ExportFilter(family, source, repository, searchtextvalue(), searchfieldvalue(), searchfieldindex(), dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), Sources());
                        }
                        if (Options() == "6")
                        {
                            html.ExportEventsByDecade(family, source, repository, dialog.FileName, Path.GetFileName(familyCollection.FullyQualifiedFilename), Privacy(), start, end);
                        }

                        MessageBoxResult result = MessageBox.Show(Properties.Resources.SourcesExportMessage, Properties.Resources.ExportResult, MessageBoxButton.YesNo, MessageBoxImage.Question);

                        try
                        {
                            if (result == MessageBoxResult.Yes)
                            {
                                System.Diagnostics.Process.Start(filename);
                            }
                        }
                        catch { }
                    }
                }
            }
        }