// convert to image because of problems with graphicslayers not showing up // correctly (in lefttop corner instead on the correct location of the map) when writing to pdf WriteableBitmap wb = new WriteableBitmap(this.yourUIElement, new ScaleTransform() { ScaleX = 1, ScaleY = 1 }); Image image = new Image(); image.Height = 64; image.Margin = new Thickness(10); image.Source = wb; // make raddocument Section section = new Section(); Paragraph paragraph = new Paragraph(); InlineUIContainer container = new InlineUIContainer(); container.UiElement = image; container.Width = 750; container.Height = 1000; paragraph.Inlines.Add(container); section.Blocks.Add(paragraph); RadDocument document = new RadDocument(); document.DefaultPageLayoutSettings = new PageLayoutSettings(PaperTypes.Letter); document.PageViewMargin = new SizeF(0.0f, 0.0f); document.ParagraphDefaultSpacingBefore = 0; document.ParagraphDefaultSpacingAfter = 0; // use padding to center, perhaps find a more appropriate way to do this in the future. document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(32, 25, 0, 0); document.Children.Add(section); PdfFormatProvider provider = new PdfFormatProvider(); string extension = "pdf"; SaveFileDialog dialog = new SaveFileDialog() { DefaultExt = extension, Filter = String.Format("{1} file (*.{0})|*.{0}|All files (*.*)|*.*", extension, "PDF"), FilterIndex = 1 }; bool? dialogResult = dialog.ShowDialog(); if (dialogResult == true) { using (Stream output = dialog.OpenFile()) { provider.Export(document, output); provider.ExportSettings = new PdfExportSettings() { InlineUIContainersExportMode = 0 }; } }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.