private void CalcPageSize(HTMLPageData page, float MaxWidth, float MaxHeight)
 {
     if (!layers)
     {
         page.Width  = MaxWidth / Zoom;
         page.Height = MaxHeight / Zoom;
     }
     else
     {
         page.Width  = MaxWidth;
         page.Height = MaxHeight;
     }
 }
        /// <inheritdoc/>
        protected override void Start()
        {
            Init();

            if (saveStreams)
            {
                StartSaveStreams();
            }

            if (!webMode)
            {
                if (format == HTMLExportFormat.MessageHTML)
                {
                    StartMHT();
                }

                if (FileName == "" && Stream != null)
                {
                    targetFileName = "html";
                    singlePage     = true;
                    subFolder      = false;
                    navigator      = false;
                    if (format == HTMLExportFormat.HTML && !embedPictures)
                    {
                        pictures = false;
                    }
                }
                else
                {
                    targetFileName  = Path.GetFileNameWithoutExtension(FileName);
                    fileName        = targetFileName;
                    targetIndexPath = !String.IsNullOrEmpty(FileName) ? Path.GetDirectoryName(FileName) : FileName;
                }

                if (!String.IsNullOrEmpty(targetIndexPath))
                {
                    targetIndexPath += Path.DirectorySeparatorChar;
                }

                if (preview)
                {
                    pictures      = true;
                    printPageData = new HTMLPageData();
                }
                else if (subFolder)
                {
                    subFolderPath  = targetFileName + ".files" + Path.DirectorySeparatorChar;
                    targetPath     = targetIndexPath + subFolderPath;
                    targetFileName = subFolderPath + targetFileName;
                    if (!Directory.Exists(targetPath))
                    {
                        Directory.CreateDirectory(targetPath);
                    }
                }
                else
                {
                    targetPath = targetIndexPath;
                }

                navFileName = targetFileName + ".nav.html";
                //FOutlineFileName = FTargetFileName + ".outline.html";
                documentTitle = (!String.IsNullOrEmpty(Report.ReportInfo.Name) ?
                                 Report.ReportInfo.Name : Path.GetFileNameWithoutExtension(FileName));

                if (singlePage)
                {
                    if (navigator)
                    {
                        singlePageFileName = targetIndexPath + targetFileName + ".main.html";
                        if (saveStreams)
                        {
                            MemoryStream pageStream = new MemoryStream();
                            DoPageStart(pageStream, documentTitle, print);
                            GeneratedUpdate(singlePageFileName, pageStream);
                        }
                        else
                        {
                            using (Stream pageStream = new FileStream(singlePageFileName,
                                                                      FileMode.Create))
                            {
                                DoPageStart(pageStream, documentTitle, print);
                            }
                        }
                    }
                    else
                    {
                        singlePageFileName = String.IsNullOrEmpty(FileName) ? "index.html" : FileName;
                        if (saveStreams)
                        {
                            GeneratedUpdate(singlePageFileName, new MemoryStream());
                        }
                        DoPageStart((format == HTMLExportFormat.HTML) ? Stream : mimeStream, documentTitle, print);
                    }
                }
            }
            else
            {
                StartWeb();
            }
        }
Beispiel #3
0
        /// <inheritdoc/>
        protected override void Start()
        {
            htmlMeasureGraphics = Report.MeasureGraphics;
            cssStyles           = new List <string>();
            hPos = 0;

            count              = Report.PreparedPages.Count;
            pagesCount         = 0;
            prevWatermarkName  = String.Empty;
            prevWatermarkSize  = 0;
            prevStyleList      = null;
            prevStyleListIndex = 0;
            picsArchive        = new List <PicsArchiveItem>();
            generatedStreams   = new List <Stream>();

            if (saveStreams)
            {
                if (singlePage)
                {
                    GeneratedUpdate("index.html", null);
                }
                subFolder = false;
                navigator = false;
                //FSinglePage = true;
            }

            if (!webMode)
            {
                if (format == HTMLExportFormat.MessageHTML)
                {
                    subFolder  = false;
                    singlePage = true;
                    navigator  = false;
                    mimeStream = new MemoryStream();
                    boundary   = ExportUtils.GetID();
                }

                if (FileName == "" && Stream != null)
                {
                    targetFileName = "html";
                    singlePage     = true;
                    subFolder      = false;
                    navigator      = false;
                    if (format == HTMLExportFormat.HTML && !embedPictures)
                    {
                        pictures = false;
                    }
                }
                else
                {
                    targetFileName  = Path.GetFileNameWithoutExtension(FileName);
                    fileName        = targetFileName;
                    targetIndexPath = !String.IsNullOrEmpty(FileName) ? Path.GetDirectoryName(FileName) : FileName;
                }

                if (!String.IsNullOrEmpty(targetIndexPath))
                {
                    targetIndexPath += Path.DirectorySeparatorChar;
                }

                if (preview)
                {
                    pictures      = true;
                    printPageData = new HTMLPageData();
                }
                else if (subFolder)
                {
                    subFolderPath =
                        targetFileName + ".files" +
                        Path.DirectorySeparatorChar;
                    targetPath     = targetIndexPath + subFolderPath;
                    targetFileName = subFolderPath + targetFileName;
                    if (!Directory.Exists(targetPath))
                    {
                        Directory.CreateDirectory(targetPath);
                    }
                }
                else
                {
                    targetPath = targetIndexPath;
                }

                navFileName = targetFileName + ".nav.html";
                //FOutlineFileName = FTargetFileName + ".outline.html";
                documentTitle = (!String.IsNullOrEmpty(Report.ReportInfo.Name) ?
                                 Report.ReportInfo.Name : Path.GetFileNameWithoutExtension(FileName));

                if (singlePage)
                {
                    if (navigator)
                    {
                        singlePageFileName = targetIndexPath + targetFileName + ".main.html";

                        if (saveStreams)
                        {
                            MemoryStream PageStream = new MemoryStream();
                            ExportUtils.Write(PageStream, String.Format(templates.PageTemplateTitle, documentTitle));
                            if (print)
                            {
                                ExportUtils.WriteLn(PageStream, PRINT_JS);
                            }
                            ExportUtils.WriteLn(PageStream, BODY_BEGIN);
                            GeneratedUpdate(singlePageFileName, PageStream);
                        }
                        else
                        {
                            using (Stream PageStream = new FileStream(singlePageFileName,
                                                                      FileMode.Create))
                                using (StreamWriter Out = new StreamWriter(PageStream))
                                {
                                    Out.Write(String.Format(templates.PageTemplateTitle, documentTitle));
                                    if (print)
                                    {
                                        Out.WriteLine(PRINT_JS);
                                    }
                                    Out.WriteLine(BODY_BEGIN);
                                }
                        }
                    }
                    else
                    {
                        singlePageFileName = String.IsNullOrEmpty(FileName) ? "index.html" : FileName;
                        Stream PagesStream;

                        if (saveStreams)
                        {
                            PagesStream = new MemoryStream();
                            GeneratedUpdate(singlePageFileName, PagesStream);
                        }
                        else
                        {
                            if (format == HTMLExportFormat.HTML)
                            {
                                PagesStream = Stream;
                            }
                            else
                            {
                                PagesStream = mimeStream;
                            }
                        }
                        ExportUtils.Write(PagesStream, String.Format(templates.PageTemplateTitle, documentTitle));
                        if (print)
                        {
                            ExportUtils.WriteLn(PagesStream, PRINT_JS);
                        }
                        ExportUtils.WriteLn(PagesStream, BODY_BEGIN);
                    }
                }
            }
            else
            {
                pages.Clear();
                for (int i = 0; i < count; i++)
                {
                    pages.Add(new HTMLPageData());
                }
            }
        }