asp.net - PDF creation using itextsharp is not working in client's server -


i tried build pdf dynamically based on conditions , works pretty in our machines , 1 of our client's machine. customer, when deployed system, pdf not generating correctly. have following code generate this

public void pdf_moderatedata(string name, string dob, string gender, string age) {      phrase pat_name = new phrase();     phrase phr_paitient_name = new phrase();     phrase phr_paitient_dob = new phrase();       paragraph pat_det = new paragraph();     paragraph paitient_name_dob = new paragraph();     paragraph mul_column = new paragraph();      itextsharp.text.font fntnormaltext = fontfactory.getfont(fontfactory.times, 12, itextsharp.text.font.normal);     itextsharp.text.font fntboldtext = fontfactory.getfont(fontfactory.times, 12, itextsharp.text.font.bold);     itextsharp.text.font fntsmalltext = fontfactory.getfont(fontfactory.times, 8, itextsharp.text.font.normal);        phr_paitient_name = new phrase(system.environment.newline + system.environment.newline + name + "                                                                                      " + dob, fntnormaltext);      pat_name = new phrase(system.environment.newline + "               " + system.environment.newline + "                                                                                                                                                            ", fntsmalltext);      pat_det.add(phr_paitient_name);     pat_det.add(pat_name);     phrase emt = new phrase();     paragraph emty = new paragraph();     emt = new phrase(system.environment.newline + "    ", fntnormaltext);     emty.add(emt);       httpcontext.current.response.contenttype = "application/pdf";     httpcontext.current.response.addheader("content-disposition", "attachment;filename=gridviewexport.pdf");     httpcontext.current.response.cache.setcacheability(httpcacheability.nocache);      document pdfdoc = new document();     pdfwriter.getinstance(pdfdoc, httpcontext.current.response.outputstream);      pdfdoc.open();       itextsharp.text.image logo = itextsharp.text.image.getinstance("c:/trial/dms/img/moderatetool.jpg");     logo.scaleabsolute(475, 600);     pdfptable table = new pdfptable(1);      table.totalwidth = 500f;      table.lockedwidth = true;      itextsharp.text.image barcode = itextsharp.text.image.getinstance("c:/trial/dms/barcode/brcode.gif");     barcode.scaleabsolute(100, 50);       pdfptable nested = new pdfptable(2);     mul_column.add(pat_det);      pdfpcell mul = new pdfpcell(mul_column);     mul.horizontalalignment = element.align_left;     mul.borderwidth = 0;     nested.addcell(mul);     //pdfpcell imag = new pdfpcell(barcode);     //imag.horizontalalignment = element.align_right;     //imag.borderwidth = 0;     //nested.addcell(imag);     pdfpcell imag = new pdfpcell(barcode);     imag.horizontalalignment = element.align_right;     imag.borderwidth = 0;     nested.addcell(imag);     pdfptable nested1 = new pdfptable(2);     //mul_column.add(pat_det);      pdfpcell mul1 = new pdfpcell(emty);     mul1.horizontalalignment = element.align_left;     mul1.borderwidth = 0;     nested1.addcell(mul1);     pdfpcell imag1 = new pdfpcell(barcode);     imag1.horizontalalignment = element.align_right;     imag1.borderwidth = 0;     nested1.addcell(imag1);        pdfpcell nesthousing = new pdfpcell(nested1);     nesthousing.padding = 0f;     nesthousing.borderwidth = 0;     table.addcell(nesthousing);      pdfpcell image_header = new pdfpcell(logo);     image_header.horizontalalignment = element.align_center;     image_header.borderwidth = 0;      table.addcell(image_header);      paragraph para = new paragraph();      //string pat = get_patientdet();      //para = new paragraph(pat);       pdfpcell header = new pdfpcell(para);     header.horizontalalignment = element.align_center;     header.colspan = 4;     header.borderwidth = 0;     //table.addcell(header);     pdfpcell nesthousing1 = new pdfpcell(nested);     nesthousing.padding = 0f;     nesthousing.borderwidth = 0;     nesthousing1.bordercolor = basecolor.white;     table.addcell(nesthousing1);       pdfdoc.add(table);       pdfdoc.close();      httpcontext.current.response.write(pdfdoc);     httpcontext.current.response.end(); } 

can guide me solve this..

server : windows 2008 r2 datacenter 64 bit servicepack1

when download pdf downloads " gridviewreoprt.pdf,attachment " , cannot work properly.

there's 99% chance problem caused by:

itextsharp.text.image logo = itextsharp.text.image.getinstance("c:/trial/dms/img/moderatetool.jpg"); itextsharp.text.image barcode = itextsharp.text.image.getinstance("c:/trial/dms/barcode/brcode.gif"); 

your customer crazy give access c: drive of servers. developers should avoid adding hard-coded paths files on c: drive in code. should encapsulate resources (images, barcodes, pdf templates,...) in web application app can deployed on every server without requirements regarding presence of , access files stored elsewhere on server.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -