Click here to Skip to main content
15,906,625 members

Comments by Member 12425208 (Top 3 by date)

Member 12425208 31-Oct-16 7:00am View    
Another DataGridView Printer is very easy to use. What do you advise to use for printing?
Member 12425208 27-Oct-16 9:22am View    
Thank you very much for your reply. Since I am beginner in C Sharp, I have some misunderstandings. I did so as you mentioned. But it didn't work. I am sure I did wrong.

public static string IsFileOpen(string filename)
{
string result = string.Empty;
try
{
if (File.Exists(filename))
{
using (FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None))
{
}
}
}
catch(Exception ex)
{
result = ex.Message;
}
return result;
}

SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "PDF File |*.pdf";
sfd.Title = "PDF kimi saxlamaq";

if (sfd.ShowDialog() == DialogResult.OK)
{
string result = IsFileOpen(myFileName)
if (!string.IsNullOrEmpty(result))
{
MessageBox.Show(string.Format("Stupid rabbit, Trix are for kids! Because {0}", result));
}
else
{
Document pdfDoc = new Document(PageSize.A4, 85f, 10f, 28f, 20f);
PdfWriter wri = PdfWriter.GetInstance(pdfDoc, new FileStream(sfd.FileName, FileMode.Create));
pdfDoc.Open();
Paragraph paragraph = new Paragraph("Kreditin ödəmə planı", h);
paragraph.Alignment = Element.ALIGN_LEFT;
pdfDoc.Add(paragraph);
pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(pdfTable);
pdfDoc.Close();
MessageBox.Show("Ödəniş cədvəli PDF-ə çıxarıldı.", "PDF-ə çıxartma", MessageBoxButtons.OK, MessageBoxIcon.Information);
System.Diagnostics.Process.Start(Path.GetFullPath(sfd.FileName));
}
}
Member 12425208 25-Oct-16 7:45am View    
Thank you very much. It worked nice. I used try catch. But how can I print that I mentioned above?

SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "PDF File |*.pdf";
if (sfd.ShowDialog() == DialogResult.OK)
{
try
{
Document pdfDoc = new Document(PageSize.A4, 85f, 10f, 28f, 20f);
PdfWriter wri = PdfWriter.GetInstance(pdfDoc, new FileStream(sfd.FileName, FileMode.Create));
pdfDoc.Open();
Paragraph paragraph = new Paragraph("Kreditin ödəmə planı", h);
paragraph.Alignment = Element.ALIGN_LEFT;
pdfDoc.Add(paragraph);
pdfDoc.Add(new Paragraph(" "));
pdfDoc.Add(new Paragraph("Ödəniş metodu:" + " " + comboBox3.Text, f));
pdfDoc.Add(new Paragraph("Kreditin məbləği:" + " " + kreditmeblegi.ToString() + " " + comboBox1.Text, f));
pdfDoc.Add(new Paragraph("Faiz dərəcəsi:" + " " + illikfaiz.ToString() + "% illik", f));
pdfDoc.Add(new Paragraph("Kreditin müddəti:" + " " + Convert.ToDouble(textBox3.Text) + " " + comboBox2.Text, f));
pdfDoc.Add(new Paragraph("Verilmə tarixi:" + " " + dateTimePicker1.Text, f));
pdfDoc.Add(new Paragraph(" ", g));
pdfDoc.Add(new Paragraph("Aylıq ödəniş:" + " " + label9.Text, f));
pdfDoc.Add(new Paragraph("Cəmi məbləğ:" + " " + umumiodenis.ToString("N2") + " " + comboBox1.Text, f));
pdfDoc.Add(new Paragraph("Ödənilən faiz:" + " " + odenilenfaiz.ToString("N2") + " " + comboBox1.Text + "\n" + "\n", f));
pdfDoc.Add(pdfTable);
pdfDoc.Close();
MessageBox.Show("Table has been exported to PDF", "Export to PDF",, MessageBoxButtons.OK, MessageBoxIcon.Information);
}

catch
{
MessageBox.Show("PDF file is open."Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}