public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { if (!string.IsNullOrEmpty(Style)) { if (Style.ToLower().Equals("bold")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.Bold); } else if (Style.ToLower().Equals("normal")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.Regular); } else if (Style.ToLower().Equals("italic")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.Italic); } else if (Style.ToLower().Equals("bolditalic")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.BoldItalic); } else if (Style.ToLower().Equals("strikeout")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.Strikeout); } else if (Style.ToLower().Equals("underline")) { owner.Font = new XFont(owner.Font.FontFamily.Name, owner.Font.Size, XFontStyle.Underline); } } }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { string globalPath = owner.Directory + "\\Web\\"; if (!string.IsNullOrEmpty(Url)) { if (Url.StartsWith("../")) { Url = Url.Replace("../", "").Replace("/", "\\"); } string imgPath = globalPath + Url; if (!File.Exists(imgPath)) { imgPath = globalPath + owner.Project + "\\" + Url; if (!File.Exists(imgPath)) { imgPath = ""; } } if (!string.IsNullOrEmpty(imgPath)) { XImage logo = XImage.FromFile(imgPath); double width = logo.PixelWidth * Width / logo.HorizontalResolution; double height = logo.PixelHeight * Height / logo.HorizontalResolution; Graphics.DrawImage(logo, X, Y, Width, Height); } } }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { if (!string.IsNullOrEmpty(Data)) { var watermark = Data; XSize size = Graphics.MeasureString(watermark, owner.Font); // Define a rotation transformation at the center of the page Graphics.TranslateTransform(Page.Width / 2, Page.Height / 2); Graphics.RotateTransform(-Math.Atan(Page.Height / Page.Width) * 180 / Math.PI); Graphics.TranslateTransform(-Page.Width / 2, -Page.Height / 2); // Create a graphical path XGraphicsPath path = new XGraphicsPath(); // Add the text to the path path.AddString(watermark, owner.Font.FontFamily, XFontStyle.BoldItalic, 150, new XPoint(0, (Page.Height / 2) - 80), XStringFormats.TopLeft); // Create a dimmed red pen and brush XPen pen = new XPen(XColor.FromArgb(50, 75, 0, 130), 3); XBrush brush = new XSolidBrush(XColor.FromArgb(50, 106, 90, 205)); // Stroke the outline of the path Graphics.DrawPath(pen, brush, path); } }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { if (!string.IsNullOrEmpty(Data)) { var tf = new XTextFormatter(Graphics); tf.Alignment = XParagraphAlignment.Left; var textSize = Graphics.MeasureString(Data, owner.Font); if (!string.IsNullOrEmpty(Flags)) { if (Flags == "center") { tf.Alignment = XParagraphAlignment.Center; X = X - (textSize.Width / 2); } else if (Flags == "default") { tf.Alignment = XParagraphAlignment.Default; } else if (Flags == "justify") { tf.Alignment = XParagraphAlignment.Justify; } else if (Flags == "left") { tf.Alignment = XParagraphAlignment.Left; } else if (Flags == "right") { tf.Alignment = XParagraphAlignment.Right; X = X - textSize.Width; } } var w = Graphics.MeasureString(Data, owner.Font); tf.DrawString(Data, owner.Font, new XSolidBrush(owner.TextColor), new XRect(X, Y, textSize.Width, textSize.Height), XStringFormats.TopLeft); } }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { Graphics.DrawEllipse(new XPen(owner.TextColor), new XSolidBrush(owner.FillColor), X, Y, R, R); }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { owner.TextColor = XColor.FromArgb(255, Ch1, Ch2, Ch3); }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { Page = Document.AddPage(); Graphics = XGraphics.FromPdfPage(Page); }
public virtual void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { Graphics.DrawLine(XPens.Black, new XPoint(X1, Y1), new XPoint(X2, Y2)); }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { //owner.LineWidth = Width; }
public override void Process(iPDF owner, ref PdfDocument Document, ref PdfPage Page, ref XGraphics Graphics) { owner.Font = new XFont(owner.Font.FontFamily.Name, Size, owner.Font.Style); }
protected override bool ProcessRequest(CefRequest request, CefCallback callback) { Task task = new Task(() => { try { var Title = ""; byte[] pdfBytes = null; if (this.pdf is string) { //var serializer = new JavaScriptSerializer(); //serializer.MaxJsonLength = Int32.MaxValue; //serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); var pdf = new iPDF(configuration.Application, Environment.CurrentDirectory, JsonMapper.ToObject <object>(this.pdf.ToString())); pdfBytes = Data = iPDF.CreatePDF(pdf); Title = pdf.Properties.Title; pages = pdf.Properties.Items; } else if (this.pdf is PdfDocument) { var doc = ((PdfDocument)this.pdf); Title = doc.Info.Title; } var dir = Environment.CurrentDirectory + "\\Web\\" + configuration.Application + "\\reports"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var dt = DateTime.Now.ToString("yyyyMMddHmmssfff"); var file = Title.Replace(" ", "_") + "_" + dt + "_" + pages + ".pdf"; var path = dir + "\\" + file; if (this.pdf is string && pdfBytes != null) { File.WriteAllBytes(path, pdfBytes); } else if (this.pdf is PdfDocument) { ((PdfDocument)this.pdf).Save(path); } var echo = JsonMapper.ToJson(new FileHelper("OK", "reports/" + file, Title, pages)); Data = Encoding.UTF8.GetBytes(echo); } catch (Exception ex) { Log.Trace(ex.Message, ex.StackTrace); var echo = JsonMapper.ToJson(new ErrorHelper(ex.Message, ex.StackTrace)); Data = Encoding.UTF8.GetBytes(echo); } callback.Continue(); }); task.Start(); return(true); }