itext - saving modified data in pdf itextsharp -
i have created pdf using itextsharp contains editable fields, when service called pdf created. problem facing is, if changing in pdf , downloading changes not saved. want open pdf in new tab through server side.
code using is:
public static string[] languages_gc = { "english", "math", "science" }; [httpget] [odataroute("getpdf")] public void downloadpdf() { httpcontext.current.response.contenttype = "application/pdf"; httpcontext.current.response.addheader("content-disposition", "inline;filename=example.pdf"); httpcontext.current.response.cache.setcacheability(httpcacheability.nocache); document doc = new document(itextsharp.text.pagesize.a4, 10f, 10f, 100f, 0f); string pdffilepath = httpcontext.current.server.mappath(".") + "/pdffiles"; pdfwriter wri = pdfwriter.getinstance(doc, httpcontext.current.response.outputstream); doc.open(); doc.addauthor("test author"); doc.addcreationdate(); pdfcontentbyte cb = wri.directcontent; font _bf = new font(font.fontfamily.helvetica, 6); pdfformfield _radiogroup = pdfformfield.createradiobutton(wri, true); _radiogroup.fieldname = "language_gc"; rectangle _rect; radiocheckfield _radiog; pdfformfield _radiofield1; pdfformfield field; (int = 0; < languages_gc.length; i++) { _rect = new rectangle(46, 806 - * 40, 60, 788 - * 40); _radiog = new radiocheckfield(wri, _rect, null, languages_gc[i]); _radiog.backgroundcolor = new graycolor(0.8f); _radiog.bordercolor = graycolor.black; _radiog.checktype = radiocheckfield.type_circle; _radiofield1 = _radiog.radiofield; _radiogroup.addkid(_radiofield1); columntext.showtextaligned(cb, element.align_left, new phrase(languages_gc[i], new font(font.fontfamily.helvetica, 18)), 70, 790 - * 40, 0); } /* button */ _rect = new rectangle(300, 806, 370, 788); pushbuttonfield button = new pushbuttonfield(wri, _rect, "buttons"); button.backgroundcolor = new graycolor(0.75f); button.bordercolor = graycolor.grayblack; button.borderwidth = 1; button.borderstyle = pdfborderdictionary.style_beveled; button.textcolor = graycolor.grayblack ; button.fontsize = 12; button.text = "submit"; //button.layout = pushbuttonfield.layout_icon_left_label_right; button.scaleicon = pushbuttonfield.scale_icon_always; button.proportionalicon = true; button.iconhorizontaladjustment = 0; field = button.field; field.action = pdfaction.javascript("this.showbuttonstate()", wri); wri.addannotation(field); //} //return ms.toarray(); /*----------------------------------------------------*/ wri.addannotation(_radiogroup); wri.addannotation(button.field); cb = wri.directcontent; doc.close(); httpcontext.current.response.write(doc); httpcontext.current.response.end(); }
can suggest me solution??
let's make analogy here, simpler file-type. suppose you're showing user textfile. open in native .txt app (notepad) , make changes.
do expect changes communicated automatically server? or changes magically propagated? of course not. , if would, seems functionality notepad have provide, rather creator of file should do.
now, happens, there particular standard of pdf documents exists precisely use-case. essentially, document sets connection server, , synchronizes. however, standard rather obscure, not lot of viewers support it.
to best of knowledge, no pdf library (including itext) supports making documents that.
Comments
Post a Comment