How to write pdf on uri of local/server using itexsharp in WCF

Posted by Kunal09 under WCF on 9/13/2011 | Points: 10 | Views : 2367 | Status : [Member] | Replies : 1
Hi ,
I am doing code in WCF.
I have created pdf on my local machine but now i want save my pdf in uri of local/server.
How to write pdf in uri (i want to give a local/server uri) using ItextSharp.

writer = PdfWriter.GetInstance(doc, new FileStream(HttpContext.Current.Server.MapPath("~/myproj/pdf"), FileMode.Create));
Above code is not working, giving an error "Object Reference not set to an instance of an Object"

pdfwriter object i.e writer is showing null by debug.
but when i giving simple path like below , then its working properly. filpath="D:/";
writer = PdfWriter.GetInstance(doc, new FileStream(filpath, FileMode.Create));

but as i said want to create pdf by giving uri of local/server.

writer = PdfWriter.GetInstance(doc, new FileStream(HttpContext.Current.Server.MapPath("~/myproj/pdf"), FileMode.Create));

and this code is not working.
so plz help me ..

Thanks,




Responses

Posted by: Blessyjees on: 9/26/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Can you try "Page.ResolveUrl" in place of HttpContext.Current.Server.MapPath. I am not sure this is working, because I can't test it.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Kunal09, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response