internal void Render(UIElement element, PdfRenderContext context) { if (element == null || element.Visibility != Visibility.Visible || element.Opacity == 0) { return; } var compositeSave = new CompositeDisposableObject(); compositeSave.Add(UIElementRendererBase.SaveMatrixPosition(context.drawingSurface, element as FrameworkElement)); compositeSave.Add(UIElementRendererBase.SaveClip(context.drawingSurface, element)); compositeSave.Add(UIElementRendererBase.SaveOpacity(context, context.opacity * element.Opacity)); using (compositeSave) { foreach (UIElementRendererBase renderer in this.renderers) { bool success = renderer.Render(element, context); if (success) { return; } } } System.Diagnostics.Debug.WriteLine("" + element + " could not be exported correctly."); }
public static void DrawTextBlock(string text, PdfRenderContext context, Brush foreground, double width, double height, FontFamily fontFamily, double fontSize, System.Windows.FontWeight fontWeight) { if (!string.IsNullOrEmpty(text)) { using (context.drawingSurface.SaveProperties()) { UIElementRendererBase.SetFill(context, foreground, width, height); SetFontFamily(context.drawingSurface, fontFamily, fontWeight); context.drawingSurface.TextProperties.FontSize = fontSize; Block block = new Block(); block.TextProperties.CopyFrom(context.drawingSurface.TextProperties); block.GraphicProperties.CopyFrom(context.drawingSurface.GraphicProperties); string[] textLines = text.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); foreach (string textLine in textLines) { block.InsertText(textLine); block.InsertLineBreak(); } context.drawingSurface.DrawBlock(block); } } }
internal void AddRenderer(UIElementRendererBase renderer) { this.renderers.Add(renderer); }