コード例 #1
0
        private void FinishSaveStreams()
        {
            // do append in memory stream
            int fileIndex = GeneratedFiles.IndexOf(singlePageFileName);

            ExportHTMLIndex(generatedStreams[fileIndex]);
            MemoryStream outStream = new MemoryStream();

            ExportHTMLNavigator(outStream);
            GeneratedUpdate(targetIndexPath + navFileName, outStream);
        }
コード例 #2
0
        private void GeneratedUpdate(string filename, Stream stream)
        {
            int i = GeneratedFiles.IndexOf(filename);

            if (i == -1)
            {
                GeneratedFiles.Add(filename);
                generatedStreams.Add(stream);
            }
            else
            {
                generatedStreams[i] = stream;
            }
        }
コード例 #3
0
 private void ExportHTMLPageFinal(FastString CSS, FastString Page, HTMLData d, float MaxWidth, float MaxHeight)
 {
     if (!webMode)
     {
         if (!singlePage)
         {
             Page.AppendLine(BODY_END);
         }
         if (d.PagesStream == null)
         {
             string pageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
             if (saveStreams)
             {
                 string fileName  = singlePage ? singlePageFileName : pageFileName;
                 int    i         = GeneratedFiles.IndexOf(fileName);
                 Stream outStream = (i == -1) ? new MemoryStream() : generatedStreams[i];
                 DoPage(outStream, documentTitle, CSS, Page);
                 GeneratedUpdate(fileName, outStream);
             }
             else
             {
                 GeneratedFiles.Add(pageFileName);
                 using (FileStream outStream = new FileStream(pageFileName, FileMode.Create))
                 {
                     DoPage(outStream, documentTitle, CSS, Page);
                 }
             }
         }
         else
         {
             DoPage(d.PagesStream, documentTitle, CSS, Page);
         }
     }
     else
     {
         ExportHTMLPageFinalWeb(CSS, Page, d, MaxWidth, MaxHeight);
     }
 }
コード例 #4
0
        /// <inheritdoc/>
        protected override void Finish()
        {
            if (!webMode)
            {
                if (navigator)
                {
                    if (saveStreams)
                    {
                        FinishSaveStreams();
                    }
                    else
                    {
                        if (singlePage)
                        {
                            if (saveStreams)
                            {
                                int fileIndex = GeneratedFiles.IndexOf(singlePageFileName);
                                DoPageEnd(generatedStreams[fileIndex]);
                            }
                            else
                            {
                                using (Stream pageStream = new FileStream(singlePageFileName,
                                                                          FileMode.Append))
                                {
                                    DoPageEnd(pageStream);
                                }
                            }
                        }
                        ExportHTMLIndex(Stream);
                        GeneratedFiles.Add(targetIndexPath + navFileName);
                        using (FileStream outStream = new FileStream(targetIndexPath + navFileName, FileMode.Create))
                        {
                            ExportHTMLNavigator(outStream);
                        }

                        //GeneratedFiles.Add(FTargetIndexPath + FOutlineFileName);
                        //using (FileStream OutStream = new FileStream(FTargetIndexPath + FOutlineFileName, FileMode.Create))
                        //    ExportHTMLOutline(OutStream);
                    }
                }
                else if (format == HTMLExportFormat.MessageHTML)
                {
                    FinishMHT();
                }
                else
                {
                    if (saveStreams)
                    {
                        if (!String.IsNullOrEmpty(singlePageFileName))
                        {
                            int fileIndex = GeneratedFiles.IndexOf(singlePageFileName);
                            DoPageEnd(generatedStreams[fileIndex]);
                        }
                    }
                    else
                    {
                        if (!singlePage)
                        {
                            DoPageStart(Stream, documentTitle, false);
                            int pageCounter = 0;
                            foreach (string genFile in GeneratedFiles)
                            {
                                string ext = Path.GetExtension(genFile);
                                if (ext == ".html" && genFile != FileName)
                                {
                                    string file = Path.GetFileName(genFile);
                                    if (subFolder)
                                    {
                                        file = Path.Combine(subFolderPath, file);
                                    }
                                    ExportUtils.WriteLn(Stream, String.Format("<a href=\"{0}\">Page {1}</a><br />", file, ++pageCounter));
                                }
                            }
                        }
                        DoPageEnd(Stream);
                    }
                }
            }
        }
コード例 #5
0
        /// <inheritdoc/>
        protected override void Finish()
        {
            if (!webMode)
            {
                if (navigator)
                {
                    if (saveStreams)
                    {
                        // do append in memory stream
                        MemoryStream strm = new MemoryStream();
                        int          i    = GeneratedFiles.IndexOf(singlePageFileName);
                        ExportHTMLIndex(generatedStreams[i]);
                        MemoryStream OutStream = new MemoryStream();
                        ExportHTMLNavigator(OutStream);
                        GeneratedUpdate(targetIndexPath + navFileName, OutStream);
                    }
                    else
                    {
                        if (singlePage)
                        {
                            if (saveStreams)
                            {
                                int    i          = GeneratedFiles.IndexOf(singlePageFileName);
                                Stream PageStream = generatedStreams[i];
                                ExportUtils.WriteLn(PageStream, BODY_END);
                                ExportUtils.Write(PageStream, templates.PageTemplateFooter);
                            }
                            else
                            {
                                using (Stream PageStream = new FileStream(singlePageFileName,
                                                                          FileMode.Append))
                                    using (StreamWriter Out = new StreamWriter(PageStream))
                                    {
                                        Out.WriteLine(BODY_END);
                                        Out.Write(templates.PageTemplateFooter);
                                    }
                            }
                        }
                        ExportHTMLIndex(Stream);
                        GeneratedFiles.Add(targetIndexPath + navFileName);
                        using (FileStream OutStream = new FileStream(targetIndexPath + navFileName, FileMode.Create))
                            ExportHTMLNavigator(OutStream);
                        //GeneratedFiles.Add(FTargetIndexPath + FOutlineFileName);
                        //using (FileStream OutStream = new FileStream(FTargetIndexPath + FOutlineFileName, FileMode.Create))
                        //    ExportHTMLOutline(OutStream);
                    }
                }
                else if (format == HTMLExportFormat.MessageHTML)
                {
                    ExportUtils.WriteLn(mimeStream, BODY_END);
                    ExportUtils.Write(mimeStream, templates.PageTemplateFooter);

                    WriteMHTHeader(Stream, FileName);
                    WriteMimePart(mimeStream, "text/html", "utf-8", "index.html");

                    for (int i = 0; i < picsArchive.Count; i++)
                    {
                        string imagename = picsArchive[i].FileName;
                        WriteMimePart(picsArchive[i].Stream, "image/" + imagename.Substring(imagename.LastIndexOf('.') + 1), "utf-8", imagename);
                    }

                    string last = "--" + boundary + "--";
                    Stream.Write(Encoding.ASCII.GetBytes(last), 0, last.Length);
                }
                else
                {
                    if (saveStreams)
                    {
                        if (!String.IsNullOrEmpty(singlePageFileName))
                        {
                            int i = GeneratedFiles.IndexOf(singlePageFileName);
                            ExportUtils.WriteLn(generatedStreams[i], BODY_END);
                            ExportUtils.Write(generatedStreams[i], templates.PageTemplateFooter);
                        }
                    }
                    else
                    {
                        int pageCnt = 0;
                        foreach (string genFile in GeneratedFiles)
                        {
                            string ext = Path.GetExtension(genFile);
                            if (ext == ".html" && genFile != FileName)
                            {
                                string file = Path.GetFileName(genFile);
                                if (subFolder)
                                {
                                    file = Path.Combine(subFolderPath, file);
                                }
                                ExportUtils.WriteLn(Stream, String.Format("<a href=\"{0}\">Page {1}</a><br />", file, ++pageCnt));
                            }
                        }
                        //ExportUtils.WriteLn(Stream, BODY_END);
                        //ExportUtils.Write(Stream, FTemplates.PageTemplateFooter);
                    }
                }
            }
        }
コード例 #6
0
        private void ExportHTMLPageFinal(FastString CSS, FastString Page, HTMLThreadData d, float MaxWidth, float MaxHeight)
        {
            if (!webMode)
            {
                if (!singlePage)
                {
                    Page.AppendLine(BODY_END);
                }
                if (d.PagesStream == null)
                {
                    if (saveStreams)
                    {
                        string FPageFileName;
                        if (singlePage)
                        {
                            FPageFileName = singlePageFileName;
                        }
                        else
                        {
                            FPageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
                        }
                        int    i = GeneratedFiles.IndexOf(FPageFileName);
                        Stream OutStream;
                        if (i == -1)
                        {
                            OutStream = new MemoryStream();
                        }
                        else
                        {
                            OutStream = generatedStreams[i];
                        }
                        if (!singlePage)
                        {
                            ExportUtils.Write(OutStream, String.Format(templates.PageTemplateTitle, documentTitle));
                        }
                        if (CSS != null)
                        {
                            ExportUtils.Write(OutStream, CSS.ToString());
                            CSS.Clear();
                        }
                        if (Page != null)
                        {
                            ExportUtils.Write(OutStream, Page.ToString());
                            Page.Clear();
                        }
                        if (!singlePage)
                        {
                            ExportUtils.Write(OutStream, templates.PageTemplateFooter);
                        }
                        GeneratedUpdate(FPageFileName, OutStream);
                    }
                    else
                    {
                        string FPageFileName = targetIndexPath + targetFileName + d.PageNumber.ToString() + ".html";
                        GeneratedFiles.Add(FPageFileName);
                        using (FileStream OutStream = new FileStream(FPageFileName, FileMode.Create))
                            using (StreamWriter Out = new StreamWriter(OutStream))
                            {
                                if (!singlePage)
                                {
                                    Out.Write(String.Format(templates.PageTemplateTitle, documentTitle));
                                }
                                if (CSS != null)
                                {
                                    Out.Write(CSS.ToString());
                                    CSS.Clear();
                                }
                                if (Page != null)
                                {
                                    Out.Write(Page.ToString());
                                    Page.Clear();
                                }
                                if (!singlePage)
                                {
                                    Out.Write(templates.PageTemplateFooter);
                                }
                            }
                    }
                }
                else
                {
                    if (!singlePage)
                    {
                        ExportUtils.Write(d.PagesStream, String.Format(templates.PageTemplateTitle, documentTitle));
                    }
                    if (CSS != null)
                    {
                        ExportUtils.Write(d.PagesStream, CSS.ToString());
                        CSS.Clear();
                    }
                    if (Page != null)
                    {
                        ExportUtils.Write(d.PagesStream, Page.ToString());
                        Page.Clear();
                    }
                    if (!singlePage)
                    {
                        ExportUtils.Write(d.PagesStream, templates.PageTemplateFooter);
                    }
                }
            }
            else
            {
                if (!layers)
                {
                    pages[d.CurrentPage].Width  = MaxWidth / Zoom;
                    pages[d.CurrentPage].Height = MaxHeight / Zoom;
                }
                else
                {
                    pages[d.CurrentPage].Width  = MaxWidth;
                    pages[d.CurrentPage].Height = MaxHeight;
                }

                if (Page != null)
                {
                    pages[d.CurrentPage].PageText = Page.ToString();
                    Page.Clear();
                }
                if (CSS != null)
                {
                    pages[d.CurrentPage].CSSText = CSS.ToString();
                    CSS.Clear();
                }
                pages[d.CurrentPage].PageEvent.Set();
            }
        }