or





<telerik:RadGridView Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" Margin="0,0,0,0" CanUserDeleteRows="False" CanUserInsertRows="False" IsReadOnly="True" IsFilteringAllowed="True" ColumnWidth="*" SelectionMode="Multiple" SelectionUnit="FullRow" AutoGenerateColumns="True" GroupRenderMode="Flat" AutoExpandGroups="True" IsSynchronizedWithCurrentItem="True" x:Name="GeotechGrid" ItemsSource="{Binding Path=ReportsToDisplay, Mode=OneWay}" SelectedItem="{Binding Path=SelectedReport, Mode=TwoWay}"> <telerik:RadGridView.Columns/></telerik:RadGridView><ListBox ItemsSource="{Binding Columns, ElementName=GeotechGrid}" x:Name="GeotechHideColListbox"> <ListBox.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding Header}" IsChecked="{Binding IsVisible, Mode=TwoWay}" /> </DataTemplate> </ListBox.ItemTemplate></ListBox>private void RetrieveSetupParameters(){ foreach(GeotechSetup x in this.context.GeotechSetups.ToList()) { // 1) x.Fieldname is the name of the field in the GeotechReport table // 2) x.FieldHeader is what I want to be the column header text // 3) x.FieldVisibility is what I want to use to set the listbox items // and hide the columns I specify in the database }}
//The Calling function private void dlgViewPDF_Load(object sender, EventArgs e){ MemoryStream ms = PDFcreator.GeneratePDFdata(id); rPdfView.LoadDocument(ms);}//The PDF generatorpublic static MemoryStream GeneratePDFdata(string id){ MemoryStream ms = new MemoryStream(); string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf"); PdfReader pdfReader = new PdfReader(sTemplate); PdfStamper pdfStamper = new PdfStamper(pdfReader, ms); PdfContentByte cb = pdfStamper.GetOverContent(1); BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED); BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED); cb.SetColorFill(iTextSharp.text.Color.BLACK); cb.SetFontAndSize(baseFontBold, 14); cb.BeginText(); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0); cb.EndText(); cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f)); cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f)); cb.MoveTo(139, 398); cb.LineTo(146, 398); cb.LineTo(146, 391); cb.LineTo(139, 391); cb.ClosePathEoFillStroke(); pdfStamper.Close(); pdfReader.Close(); return ms;}//The Calling functionprivate void dlgViewPDF_Load(object sender, EventArgs e){ MemoryStream ms = new MemoryStream(); FileStream file = new FileStream(@"c:\temp\testfile.pdf", FileMode.Open, FileAccess.Read); byte[] bytes = new byte[file.Length]; file.Read(bytes, 0, (int)file.Length); ms.Write(bytes, 0, (int)file.Length); rPdfView.LoadDocument(ms);}//The PDF generator public static void GeneratePDFdata(string id){ MemoryStream ms = new MemoryStream(); string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf"); PdfReader pdfReader = new PdfReader(sTemplate); FileStream fs = new FileStream(@"c:\temp\testfile.pdf", FileMode.Create, FileAccess.Write, FileShare.None); PdfStamper pdfStamper = new PdfStamper(pdfReader, fs); PdfContentByte cb = pdfStamper.GetOverContent(1); BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED); BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED); cb.SetColorFill(iTextSharp.text.Color.BLACK); cb.SetFontAndSize(baseFontBold, 14); cb.BeginText(); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0); cb.EndText(); cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f)); cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f)); cb.MoveTo(139, 398); cb.LineTo(146, 398); cb.LineTo(146, 391); cb.LineTo(139, 391); cb.ClosePathEoFillStroke(); pdfStamper.Close(); pdfReader.Close();}