Skip to content

Commit

Permalink
showing print message bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
BimalNSU committed Nov 29, 2018
1 parent 9c0a009 commit 698da09
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
15 changes: 7 additions & 8 deletions Tax Calculator/Form6_AssetAndLiabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,19 +1114,18 @@ private void btBack_Click(object sender, EventArgs e)

//pdf creating button. print button
private void btPrint_Click(object sender, EventArgs e)
{

{
//taking all assets and liabilities info in a string
UserInputs_AssetAndLiabilities();
MyPdfWriter myPdfWriter = new MyPdfWriter();



/* MessageBox.Show("PDF print functionality is available only on PRO Version.", //warnning message
"Notice", //window title
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation); //For cross Warning icon
*/

/* MessageBox.Show("PDF print functionality is available only on PRO Version.", //warnning message
"Notice", //window title
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation); //For cross Warning icon
*/
}
}
}
67 changes: 42 additions & 25 deletions Tax Calculator/MyPdfWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,55 @@ public class MyPdfWriter

public MyPdfWriter()
{

string file_name = "";
SaveFileDialog svg = new SaveFileDialog(); //show dialgue box to take a location with file name
svg.ShowDialog(); //getting new pdf file location and file name given by user
// size = reader.GetPageSizeWithRotation(1);
try
// size = reader.GetPageSizeWithRotation(1);

file_name = Path.GetFileName(svg.FileName); //getting file_name given by user
if (file_name.Length > 0) //checking user valid file_name input
{
using (var outputPdfStream = new FileStream(svg.FileName + ".pdf", FileMode.Create, FileAccess.Write))
try
{
using (var outputPdfStream = new FileStream(svg.FileName + ".pdf", FileMode.Create, FileAccess.Write))
{
//open the reader
PdfReader reader = new PdfReader(oldFile);

PdfStamper stamper = new PdfStamper(reader, outputPdfStream);
var pageSize = reader.GetPageSize(1); //getting page size by giving page number=1

pdfWrite_Form1(ref stamper, ref reader); //Personal_info form print
pdfWrite_Form2(ref stamper, ref reader); //salaries form print
pdfWrite_Form3(ref stamper, ref reader); //Investment-tax-credit form print
pdfWrite_Form5(ref stamper, ref reader); //statement-of-salary form print
pdfWrite_Form4(ref stamper, ref reader); //Expenses form print
pdfWrite_Form6(ref stamper, ref reader); //Asset and Liabilities form print
pdfWrite_Page8(ref stamper, ref reader); //last page of tex return form
stamper.Close();
MessageBox.Show("Print successfully " +
"\n File Name : " + file_name +
"\n File location: " + svg.FileName.ToString() , // messages
"Congratulation", //window title
MessageBoxButtons.OK,
MessageBoxIcon.Information); //For cross Warning icon
}
}
catch //if file is opened
{
//open the reader
PdfReader reader = new PdfReader(oldFile);

PdfStamper stamper = new PdfStamper(reader, outputPdfStream);
var pageSize = reader.GetPageSize(1); //getting page size by giving page number=1

pdfWrite_Form1(ref stamper, ref reader); //Personal_info form print
pdfWrite_Form2(ref stamper, ref reader); //salaries form print
pdfWrite_Form3(ref stamper, ref reader); //Investment-tax-credit form print
pdfWrite_Form5(ref stamper, ref reader); //statement-of-salary form print
pdfWrite_Form4(ref stamper, ref reader); //Expenses form print
pdfWrite_Form6(ref stamper, ref reader); //Asset and Liabilities form print
pdfWrite_Page8(ref stamper, ref reader); //last page of tex return form
stamper.Close();
MessageBox.Show("Print successfully");
MessageBox.Show("Please close your pdf file first.\n Or try different file name", //warnning message
svg.FileName.ToString() + " is already open", //window title
MessageBoxButtons.OK,
MessageBoxIcon.Hand); //For cross Warning icon
}
}
catch
{
MessageBox.Show("Please close your pdf file first.\n Or try different file name", //warnning message
svg.FileName.ToString() + " is already open", //window title
// if invalid file name given
else
MessageBox.Show("Please give a proper file name", //warnning message
"Warning", //window title
MessageBoxButtons.OK,
MessageBoxIcon.Hand); //For cross Warning icon
}
MessageBoxIcon.Warning); //For exclaimatory icon in trangle shape

}

private void pdfWrite_Form1(ref PdfStamper stamper, ref PdfReader reader)
Expand Down

0 comments on commit 698da09

Please sign in to comment.