示例#1
0
        private string HTMLGetStylesHeader(int PageNumber)
        {
            FastString header = new FastString();

            if (singlePage && pageBreaks)
            {
                header.AppendLine("<style type=\"text/css\" media=\"print\"><!--");
                header.AppendLine("div.frpage { page-break-after: always; page-break-inside: avoid; }");
                header.AppendLine("--></style>");
            }
            header.AppendLine("<style type=\"text/css\"><!-- ");
            return(header.ToString());
        }
        private void WriteMHTHeader(Stream Stream, string FileName)
        {
            FastString sb = new FastString(256);
            string     s  = "=?utf-8?B?" + System.Convert.ToBase64String(Encoding.UTF8.GetBytes(FileName)) + "?=";

            sb.Append("From: ").AppendLine(s);
            sb.Append("Subject: ").AppendLine(s);
            sb.Append("Date: ").AppendLine(ExportUtils.GetRFCDate(SystemFake.DateTime.Now));
            sb.AppendLine("MIME-Version: 1.0");
            sb.Append("Content-Type: multipart/related; type=\"text/html\"; boundary=\"").Append(boundary).AppendLine("\"");
            sb.AppendLine();
            sb.AppendLine("This is a multi-part message in MIME format.");
            sb.AppendLine();
            ExportUtils.Write(Stream, sb.ToString());
            sb.Clear();
        }
 private void ExportPageStylesLayers(FastString styles, int PageNumber)
 {
     if (prevStyleListIndex < cssStyles.Count)
     {
         styles.Append(HTMLGetStylesHeader(PageNumber));
         for (int i = prevStyleListIndex; i < cssStyles.Count; i++)
         {
             styles.Append(HTMLGetStyleHeader(i, PageNumber)).Append(cssStyles[i]).AppendLine("}");
         }
         styles.AppendLine(HTMLGetStylesFooter());
     }
 }
示例#4
0
        private string HTMLGetStylesHeader()
        {
            FastString header = new FastString();

            if (singlePage && pageBreaks)
            {
                header.AppendLine("<style type=\"text/css\" media=\"print\"><!--");
                header.Append("div." + pageStyleName +
                              " { page-break-after: always; page-break-inside: avoid; ");
                if (d.page.Landscape)
                {
                    header.Append("width:").Append(Px(maxHeight * Zoom).Replace(";", " !important;"))
                    .Append("transform: rotate(90deg); -webkit-transform: rotate(90deg)");
                }

                header.AppendLine("}")
                .AppendLine("--></style>");
            }
            header.AppendLine("<style type=\"text/css\"><!-- ");
            return(header.ToString());
        }
示例#5
0
 private void HTMLGetStyle(FastString style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, Padding Padding, bool RTL, bool wordWrap, float LineHeight, float ParagraphOffset)
 {
     HTMLFontStyle(style, Font, LineHeight);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign, wordWrap);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding, ParagraphOffset);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
示例#6
0
        private void ExportHTMLPageStart(FastString Page, int PageNumber, int CurrentPage)
        {
            if (webMode)
            {
                if (!layers)
                {
                    pages[CurrentPage].CSSText = Page.ToString();
                    Page.Clear();
                }
                pages[CurrentPage].PageNumber = PageNumber;
            }

            if (!webMode && !singlePage)
            {
                Page.AppendLine(BODY_BEGIN);
            }
        }
示例#7
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);
     }
 }
        private void WriteMimePart(Stream stream, string mimetype, string charset, string filename)
        {
            FastString sb = new FastString();

            sb.Append("--").AppendLine(boundary);
            sb.Append("Content-Type: ").Append(mimetype).Append(";");
            if (charset != String.Empty)
            {
                sb.Append(" charset=\"").Append(charset).AppendLine("\"");
            }
            else
            {
                sb.AppendLine();
            }
            string body;

            byte[] buff = new byte[stream.Length];
            stream.Position = 0;
            stream.Read(buff, 0, buff.Length);
            if (mimetype == "text/html")
            {
                sb.AppendLine("Content-Transfer-Encoding: quoted-printable");
                body = ExportUtils.QuotedPrintable(buff);
            }
            else
            {
                sb.AppendLine("Content-Transfer-Encoding: base64");
                body = System.Convert.ToBase64String(buff, Base64FormattingOptions.InsertLineBreaks);
            }
            sb.Append("Content-Location: ").AppendLine(ExportUtils.HtmlURL(filename));
            sb.AppendLine();
            sb.AppendLine(body);
            sb.AppendLine();
            Stream.Write(Encoding.ASCII.GetBytes(sb.ToString()), 0, sb.Length);
            sb.Clear();
        }
        private void Layer(FastString Page, ReportComponentBase obj,
                           float Left, float Top, float Width, float Height, FastString Text, string style, FastString addstyletag)
        {
            if (Page != null && obj != null)
            {
                string onclick = null;

                if (!String.IsNullOrEmpty(ReportID))
                {
                    if (!String.IsNullOrEmpty(obj.ClickEvent) || obj.HasClickListeners())
                    {
                        onclick = "click";
                    }

                    CheckBoxObject checkBoxObject = obj as CheckBoxObject;
                    if (checkBoxObject != null && checkBoxObject.Editable)
                    {
                        onclick = "checkbox_click";
                    }

                    TextObject textObject = obj as TextObject;
                    if (textObject != null && textObject.Editable)
                    {
                        onclick = "text_edit";
                    }
                }

                // we need to adjust left, top, width and height values because borders take up space in html elements
                float borderLeft   = 0;
                float borderRight  = 0;
                float borderTop    = 0;
                float borderBottom = 0;
                HTMLBorderWidthValues(obj, out borderLeft, out borderTop, out borderRight, out borderBottom);

                Page.Append("<div ").Append(style).Append(" style=\"").
                Append(onclick != null ? "cursor:pointer;" : "").
                Append("left:").Append(Px((leftMargin + Left) * Zoom - borderLeft / 2f)).
                Append("top:").Append(Px((topMargin + Top) * Zoom - borderTop / 2f)).
                Append("width:").Append(Px(Width * Zoom - borderRight / 2f - borderLeft / 2f)).
                Append("height:").Append(Px(Height * Zoom - borderBottom / 2f - borderTop / 2f));

                if (addstyletag != null)
                {
                    Page.Append(addstyletag);
                }

                Page.Append("\"");

                if (onclick != null)
                {
                    string eventParam = String.Format("{0},{1},{2},{3}",
                                                      obj.Name,
                                                      CurPage,
                                                      obj.AbsLeft.ToString("#0"),
                                                      obj.AbsTop.ToString("#0"));

                    Page.Append(" onclick=\"")
                    .AppendFormat(OnClickTemplate, ReportID, onclick, eventParam)
                    .Append("\"");
                }

                Page.Append(">");
                if (Text == null)
                {
                    Page.Append(NBSP);
                }
                else
                {
                    Page.Append(Text);
                }
                Page.AppendLine("</div>");
            }
        }
示例#10
0
 private void Part(string str)
 {
     capacitor.AppendLine(str);
 }
示例#11
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();
            }
        }