c# - How to append the file extension .pdf to a String entered by the user? -
i coding program need save texts (from rich text box) pdf.
i use itextsharp , code:
document doc = new document(itextsharp.text.pagesize.letter, 10, 10, 42, 35); pdfwriter wri = pdfwriter.getinstance(doc, new filestream("titleofpdf.pdf", filemode.create));//textbox1(in form) assign here title of document doc.open(); //open document in order write inside. paragraph paragraph = new paragraph(richtextbox1.text); // adds above created text using different class object our pdf document doc.add(paragraph); doc.close();
i title of file flexible , assigned user (from text box).
if change line:
pdfwriter wri = pdfwriter.getinstance(doc, new filestream("titleofpdf.pdf", filemode.create));
to:
pdfwriter wri = pdfwriter.getinstance(doc, new filestream(textbox1.text, filemode.create));
then works fine, but file hasn't got extension .pdf
.
how can make title of document flexible user can assign it, , extension .pdf
?
thanks user mkl found answere. had put:
textbox1.text + ".pdf"
Comments
Post a Comment