I need to cancel edition by user when opening the PDF document. I tried FormFlattening=true but when i do it, all AcroFields in my document appear empty. What am i doing wrong??? Thanks even for reading this.
I have the folowing code: ... PlantillaImpresion oPlantilla = (PlantillaImpresion)Session["Plantilla"]; string pdfTemplate = @"c:\Temp\PDF\" + oPlantilla.Nombre + ".pdf"; string newFile = @"c:\Temp\PDF\terminado" + oPlantilla.Nombre + ".pdf"; PdfReader pdfReader = new PdfReader(pdfTemplate); pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create)); AcroFields pdfFormFields = pdfStamper.AcroFields; string oImpCampo = string.Empty; foreach (ImpresionContrato oImp in oSetImpresiones) { InsertarTexto(oImp.PlantillaCampo.Nombre, oImp.Valor, pdfStamper); string oAuxiliar=pdfFormFields.GetField(oImp.PlantillaCampo.Nombre); } pdfStamper.FormFlattening = true; DataTable oTemp = new DataTable(); System.Collections.Hashtable info = new System.Collections.Hashtable(); info["Title"] = oPlantilla.Nombre; info["Author"] = UserSession.Usuario.Apellido+" "+UserSession.Usuario.Nombre; info["Creator"] = "123"; pdfStamper.Close(); pdfStamper.Writer.CloseStream = true; System.Diagnostics.Process oProcess = new System.Diagnostics.Process(); oProcess.StartInfo.WorkingDirectory = @"C:\Temp\PDF"; oProcess.StartInfo.FileName = "terminado" + oPlantilla.Nombre + ".pdf"; oProcess.Start(); oProcess.Close(); ... where private void InsertarTexto(string oCampo, string oValor, PdfStamper pdfStamper) { //string oNom = pdfStamper.AcroFields.Xfa.DatasetsNode.ChildNodes[0].ChildNodes[0].ChildNodes[2].Name; bool oBandera = false; int oCont = 0; while (oBandera.Equals(false)) { if (pdfStamper.AcroFields.Xfa.DatasetsNode.ChildNodes[0].ChildNodes[0].ChildNodes[oCont].Name.Equals(oCampo)) { pdfStamper.AcroFields.Xfa.DatasetsNode.ChildNodes[0].ChildNodes[0].ChildNodes[oCont].InnerText = oValor; pdfStamper.AcroFields.Xfa.Changed = true; BaseFont helvetica = BaseFont.CreateFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED); pdfStamper.AcroFields.AddSubstitutionFont(helvetica); oBandera = true; } else { oCont++; } } } -- View this message in context: http://old.nabble.com/itextsharp-flatten-xfa-filled-document-not-working-tp28044204p28044204.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/