public void GetResumePdf(string
User_id)
{
var
useridarr = User_id.Split('^');
using (ZipFile zip = new ZipFile())
{
for
(int i = 0; i < useridarr.Length; i++)
{
string
cmd = "
select a.user_id,(a.first_name+' '+a.last_name) as
candidate_name,a.father_name,a.dob,a.address1," +
" a.marital_status,j.marital_text,case when
a.nationality=2 then 'Non-Indian' else 'Indian' end as nationality,"
+
"
a.profile_id,b.profile_name,c.degree_id,e.degree_name,e.degree_type,c.institution,inst_city,c.year_completion,"
+
"
d.subject_id,f.subject_name,a.total_exp_years,a.total_exp_months,a.pref_locality,"
+
" g.locality_name+','+h.city_name as
locality,a.skilla,a.comments,a.mob1,a.email_id," +
"
i.exp_id,i.org_name,i.job_title,i.job_desc,i.from_year,i.from_mon,"
+
"
(select month_name from month_master where month_id=i.from_mon) as
from_month_name,i.to_year,i.to_mon," +
" (select month_name from month_master where
month_id=i.to_mon) as to_month_name,i.till_date" +
"
from user_profile a,profile_master b,user_education c,user_subjects d,"
+
" degree_master e,profile_subj_master f
,locality_master g,city_master h,User_work_ex i,marital_status j where"
+
"
a.org_id=c.org_id and a.profile_id=b.profile_id " +
" and a.org_id=c.org_id and a.user_id=c.user_id
" +
" and a.org_id=d.org_id and a.user_id=d.user_id and
a.profile_id=d.profile_id" +
" and c.org_id=e.org_id and
c.degree_id=e.degree_id" +
" and d.org_id=f.org_id and
d.subject_id=f.subject_id" +
" and a.org_id=g.org_id and
a.pref_locality=g.locality_id" +
" and g.org_id=h.org_id and
g.city_id=h.city_id" +
" and a.org_id=i.org_id and
a.user_id=i.user_id" +
" and a.org_id=j.org_id and
a.marital_status=j.marital_id" +
" and a.user_id='" +
useridarr[i].ToString().Trim() + "'";
DataTable
dt_resume = new DataTable();
dt_resume = GetTableData(cmd);
DataView
dv_resume = dt_resume.DefaultView;
DataTable
dt_edu = dv_resume.ToTable(true, "degree_id");
DataTable
dt_exp = dv_resume.ToTable(true, "exp_id");
//---------------------
if
(dv_resume.Count > 0)
{
Document
document = new Document(PageSize.A4, 88f, 88f, 10f, 10f);
Font
NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL,
Color.BLACK);
Font
BoldFont = FontFactory.GetFont("Arial", 20, Font.BOLD,
Color.BLACK);
using
(System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
PdfWriter writer = PdfWriter.GetInstance(document,
memoryStream);
Phrase phrase = null;
PdfPCell cell = null;
PdfPTable table = null;
Color color = null;
document.Open();
//Header Table
table = new PdfPTable(2);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.5f,
0.5f });
//------------First Column
Phrase
phraseName = new Phrase();
phraseName.Add(new Chunk(Convert.ToString(dv_resume[0]["candidate_name"]), BoldFont));
cell =
PhraseCell(phraseName, PdfPCell.ALIGN_LEFT, "N");
table.AddCell(cell);
//---------Second Column
phrase = new Phrase();
phrase.Add(new Chunk("EmailId : " + Convert.ToString(dv_resume[0]["email_id"]) + "\n\n",
FontFactory.GetFont("Arial",
10, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("Mobile No. " + Convert.ToString(dv_resume[0]["mob1"]) + "
\n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["locality"]), FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_RIGHT, "N");
cell.VerticalAlignment
= PdfCell.ALIGN_TOP;
table.AddCell(cell);
//Separater Line
color = new Color(System.Drawing.ColorTranslator.FromHtml("#000000"));
DrawLine(writer, 25f,
document.Top - 58f, document.PageSize.Width - 25f, document.Top - 58f, color);
//DrawLine(writer, 25f, document.Top - 80f, document.PageSize.Width -
25f, document.Top - 80f, color);
document.Add(table);
//-------Working Experiwnce
table = new PdfPTable(1);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.3f
});
table.SpacingBefore =
12f;
//------------
phrase = new Phrase();
Chunk heading1_chunk = new Chunk("1. Working
Experience (" + Convert.ToString(dv_resume[0]["total_exp_years"]) + " Y " + Convert.ToString(dv_resume[0]["total_exp_months"]) + " M )
\n\n", FontFactory.GetFont("Arial", 15, Font.BOLD,
Color.BLACK));
heading1_chunk.SetUnderline(0.8f, -5);
phrase.Add(heading1_chunk);
//---------
string from_date = "";
string to_date = "";
for (int w = 0; w <
dt_exp.Rows.Count; w++)
{
from_date = "";
to_date = "";
dv_resume.RowFilter
= "exp_id='" + Convert.ToString(dt_exp.Rows[w]["exp_id"]) + "'";
from_date = Convert.ToString(dv_resume[0]["from_month_name"]) + " - " + Convert.ToString(dv_resume[0]["from_year"]);
if (Convert.ToString(dv_resume[0]["till_date"]) == "Y")
{
to_date = "Till Date";
}
else if (Convert.ToString(dv_resume[0]["to_mon"]) != ""
&& Convert.ToString(dv_resume[0]["to_mon"]) != "0"
&& Convert.ToString(dv_resume[0]["to_mon"]) != null)
{
to_date = Convert.ToString(dv_resume[0]["to_month_name"]) + " - " + Convert.ToString(dv_resume[0]["to_year"]);
}
else
{
to_date = "Till Date";
}
if (dv_resume.Count > 0)
{
phrase.Add(new Chunk(" "
+ Convert.ToString(dv_resume[0]["job_title"]) + "\n\n",
FontFactory.GetFont("Arial",
11, Font.BOLD, Color.BLACK)));
phrase.Add(new Chunk("
" + Convert.ToString(dv_resume[0]["Org_name"]) + "\n\n",
FontFactory.GetFont("Arial",
10, Font.NORMAL, Color.BLACK)));
phrase.Add(new Chunk("
" + Convert.ToString(from_date)
+ " to " + Convert.ToString(to_date) + "
\n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
}
}
//---------
Chunk heading2_chunk = new Chunk("2.
Education \n", FontFactory.GetFont("Arial",
15, Font.BOLD, Color.BLACK));
heading2_chunk.SetUnderline(0.8f, -5);
phrase.Add(heading2_chunk);
//-----------
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "N");
cell.VerticalAlignment
= PdfCell.ALIGN_TOP;
table.AddCell(cell);
//-----------
document.Add(table);
//---------Education
table = new PdfPTable(4);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.7f,
4.5f, 4f, 0.8f });
table.SpacingBefore =
5f;
//------------First Column
phrase = new
Phrase();
phrase.Add(new Chunk("Sr No.", FontFactory.GetFont("Arial", 11, Font.BOLD,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_CENTER, "Y");
table.AddCell(cell);
//------------Second Column
phrase = new Phrase();
phrase.Add(new Chunk("Degree", FontFactory.GetFont("Arial", 11, Font.BOLD,
Color.BLACK)));
cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
//------------Third Column
phrase = new Phrase();
phrase.Add(new Chunk("Institute", FontFactory.GetFont("Arial", 11, Font.BOLD,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
//------------Fourth Column
//phrase = new Phrase();
//phrase.Add(new Chunk(" City",
FontFactory.GetFont("Arial", 11, Font.BOLD, Color.BLACK)));
//cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
//table.AddCell(cell);
//------------Fifth Column
phrase = new Phrase();
phrase.Add(new Chunk(" Year", FontFactory.GetFont("Arial", 11, Font.BOLD,
Color.BLACK)));
cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
//----------------Second Row of Table
//------------First Column
for (int e = 0; e <
dt_edu.Rows.Count; e++)
{
dv_resume.RowFilter
= " degree_id='" + Convert.ToString(dt_edu.Rows[e]["degree_id"]) + "'";
if (dv_resume.Count > 0)
{
phrase = new Phrase();
phrase.Add(new Chunk(Convert.ToString(e + 1), NormalFont));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_CENTER, "Y");
table.AddCell(cell);
//------------Second Column
phrase = new Phrase();
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["degree_name"]), NormalFont));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
//------------Third Column
phrase = new Phrase();
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["institution"]), NormalFont));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
//------------Fourth Column
//phrase = new Phrase();
//phrase.Add(new Chunk(" " +
Convert.ToString(dv_resume[0]["inst_city"]), NormalFont));
//cell = PhraseCell(phrase, PdfPCell.ALIGN_LEFT,
"Y");
//table.AddCell(cell);
//------------Fifth Column
phrase = new Phrase();
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["year_completion"]), NormalFont));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "Y");
table.AddCell(cell);
}
}
//---------------------
document.Add(table);
//-------------Skill & Competences
table = new PdfPTable(1);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.3f
});
table.SpacingBefore =
12f;
//------------
phrase = new Phrase();
Chunk heading3_chunk = new Chunk("3. Skills
& Competences \n\n",
FontFactory.GetFont("Arial",
15, Font.BOLD, Color.BLACK));
heading3_chunk.SetUnderline(0.8f, -5);
phrase.Add(heading3_chunk);
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["skilla"]), FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "N");
cell.VerticalAlignment
= PdfCell.ALIGN_TOP;
table.AddCell(cell);
document.Add(table);
//-------------Skill & Competences
table = new PdfPTable(1);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.3f
});
table.SpacingBefore =
12f;
//------------
phrase = new Phrase();
Chunk heading4_chunk = new Chunk("4.
Achievements/Additional Information \n\n", FontFactory.GetFont("Arial",
15, Font.BOLD, Color.BLACK));
heading4_chunk.SetUnderline(0.8f, -5);
phrase.Add(heading4_chunk);
phrase.Add(new Chunk(Convert.ToString(dv_resume[0]["comments"]), FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "N");
cell.VerticalAlignment
= PdfCell.ALIGN_TOP;
table.AddCell(cell);
document.Add(table);
//-------------Skill & Competences
table = new PdfPTable(1);
table.TotalWidth =
550f;
table.LockedWidth = true;
table.SetWidths(new float[] { 0.3f
});
table.SpacingBefore =
12f;
//------------
phrase = new Phrase();
Chunk
heading5_chunk = new Chunk("5. Personal Details \n\n", FontFactory.GetFont("Arial",
15, Font.BOLD, Color.BLACK));
heading5_chunk.SetUnderline(0.8f, -5);
phrase.Add(heading5_chunk);
phrase.Add(new Chunk(" Father's
Name : " + Convert.ToString(dv_resume[0]["father_name"]) + " \n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
phrase.Add(new Chunk(" Marital
Status : " + Convert.ToString(dv_resume[0]["marital_text"]) + " \n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
phrase.Add(new Chunk("
Nationality : " + Convert.ToString(dv_resume[0]["nationality"]) + " \n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
string dob = "";
if (Convert.ToString(dv_resume[0]["dob"]) != ""
&& Convert.ToString(dv_resume[0]["dob"]) != null)
{
dob = Convert.ToDateTime(dv_resume[0]["dob"]).ToString("dd-MMM-yyyy");
}
else
{
dob = "N/A";
}
phrase.Add(new
Chunk(" Date of Birth : " + dob + " \n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
phrase.Add(new Chunk(" Address :
" + Convert.ToString(dv_resume[0]["address1"]) + "
\n\n", FontFactory.GetFont("Arial", 10, Font.NORMAL,
Color.BLACK)));
cell =
PhraseCell(phrase, PdfPCell.ALIGN_LEFT, "N");
cell.VerticalAlignment
= PdfCell.ALIGN_TOP;
table.AddCell(cell);
document.Add(table);
//----------------
document.Close();
byte[] bytes = memoryStream.ToArray();
memoryStream.Close();
//------------
if (useridarr.Length > 1)
{
zip.AddEntry(dv_resume[0]["candidate_name"].ToString()
+ "_" + (i + 1).ToString() + ".pdf", bytes);
}
//-------------
else
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename="+dv_resume[0]["candidate_name"].ToString());
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.Buffer
= true;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Close();
}
}
} //------------ dv
count Condition closed
//document.Open();
}
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=DownloadedFile.zip");
HttpContext.Current.Response.ContentType
= "application/pdf";
zip.Save(HttpContext.Current.Response.OutputStream);
HttpContext.Current.Response.End();
}
//---------------------
}
No comments:
Post a Comment