private byte[] StreamToBytes(System.IO.Stream stream)
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
return bytes;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog file = new OpenFileDialog();
if (file.ShowDialog() == true)
{
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterCenterImage = StreamToBytes(file.File.OpenRead());
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterLeftImage = StreamToBytes(file.File.OpenRead());
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterRightImage = StreamToBytes(file.File.OpenRead());
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderCenterImage = StreamToBytes(file.File.OpenRead());
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderLeftImage = StreamToBytes(file.File.OpenRead());
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderRightImage = StreamToBytes(file.File.OpenRead());
}
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterCenter = "&G";
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterRight = "&G";
this.gcSpreadSheet1.ActiveSheet.PrintInfo.FooterLeft = "&G";
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderCenter = "&G";
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderRight = "&G";
this.gcSpreadSheet1.ActiveSheet.PrintInfo.HeaderLeft = "&G";
}
private void button2_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "PDF File (.pdf)|*.pdf";
bool? useClick = saveFileDialog.ShowDialog();
if (useClick == true)
{
var stream = saveFileDialog.OpenFile();
gcSpreadSheet1.SavePDF(stream, 0);
stream.Dispose();
}
}