static async void PdfHeaderFooterEventHandler(object sender, TreeGridPdfHeaderFooterEventArgs e) { var width = e.PdfPage.GetClientSize().Width; PdfPageTemplateElement header = new PdfPageTemplateElement(width, 38); e.PdfDocumentTemplate.Top = header; PdfPageTemplateElement footer = new PdfPageTemplateElement(width, 30); e.PdfDocumentTemplate.Bottom = footer; var uri = new Uri("ms-appx:///Images/Header.png", UriKind.RelativeOrAbsolute); var srcfile = await StorageFile.GetFileFromApplicationUriAsync(uri); var stream = await srcfile.OpenStreamForReadAsync(); header.Graphics.DrawImage(PdfImage.FromStream(stream), 0, 0, width / 3f, 34); uri = new Uri("ms-appx:///Images/Footer.png", UriKind.RelativeOrAbsolute); srcfile = await StorageFile.GetFileFromApplicationUriAsync(uri); stream = await srcfile.OpenStreamForReadAsync(); footer.Graphics.DrawImage(PdfImage.FromStream(stream), 0, 0, width, 25); stream.Dispose(); }
private static void PdfHeaderFooterEventHandler(object sender, TreeGridPdfHeaderFooterEventArgs e) { var width = e.PdfPage.GetClientSize().Width; PdfPageTemplateElement header = new PdfPageTemplateElement(width, 38); header.Graphics.DrawImage(PdfImage.FromFile(@"Assets/treegrid/Header.png"), 155, 5, width / 3f, 34); e.PdfDocumentTemplate.Top = header; PdfPageTemplateElement footer = new PdfPageTemplateElement(width, 30); footer.Graphics.DrawImage(PdfImage.FromFile(@"Assets/treegrid/Footer.png"), 0, 0); e.PdfDocumentTemplate.Bottom = footer; }
private static void PdfHeaderFooterEventHandler(object sender, TreeGridPdfHeaderFooterEventArgs e) { var width = e.PdfPage.GetClientSize().Width; PdfPageTemplateElement header = new PdfPageTemplateElement(width, 38); Assembly assembly = typeof(ExportToPDFCommand).Assembly; Stream headerImgStream = assembly.GetManifestResourceStream("syncfusion.treegriddemos.wpf.Assets.treegrid.Header.png"); PdfImage headerImg = PdfImage.FromStream(headerImgStream) as PdfImage; header.Graphics.DrawImage(headerImg, 155, 5, width / 3f, 34); e.PdfDocumentTemplate.Top = header; PdfPageTemplateElement footer = new PdfPageTemplateElement(width, 30); Stream footerImgStream = assembly.GetManifestResourceStream("syncfusion.treegriddemos.wpf.Assets.treegrid.Footer.png"); PdfImage footerImg = PdfImage.FromStream(footerImgStream) as PdfImage; footer.Graphics.DrawImage(footerImg, 0, 0); e.PdfDocumentTemplate.Bottom = footer; }
private static void PdfHeaderFooterEventHandler(object sender, TreeGridPdfHeaderFooterEventArgs e) { var width = e.PdfPage.GetClientSize().Width; PdfPageTemplateElement header = new PdfPageTemplateElement(width, 38); #if NETCORE header.Graphics.DrawImage(PdfImage.FromFile("../../../Resources/Header.png"), 155, 5, width / 3f, 34); #else header.Graphics.DrawImage(PdfImage.FromFile(@"..\..\Resources\Header.png"), 155, 5, width / 3f, 34); #endif e.PdfDocumentTemplate.Top = header; PdfPageTemplateElement footer = new PdfPageTemplateElement(width, 30); #if NETCORE footer.Graphics.DrawImage(PdfImage.FromFile("../../../Resources/Footer.png"), 0, 0); #else footer.Graphics.DrawImage(PdfImage.FromFile(@"..\..\Resources\Footer.png"), 0, 0); #endif e.PdfDocumentTemplate.Bottom = footer; }