15,906,625 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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);
}