We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot save XFA-Document

Err.png (14.7 KB)
XFAPDF.pdf (1.7 MB)
Hello,

i try to open a XFA-Document (see attachment), set one field-value in the XFA-Document and save it with same filename.
Even when i don’t try to change the field-value, i get the following error.

I’am using this code:

Dim doc As New Document("C:\temp\XFAPDF.pdf")
If doc.Form.Type = Forms.FormType.Dynamic AndAlso Not doc.Form.XFA Is Nothing AndAlso doc.Form.XFA.FieldNames.Count > 0 Then
               doc.Form.XFA.Item("us-request[0].ContentArea[0].sfApplicantInformation[0]sfApplicantName[0].firstName[0]") = "test"
End If
doc.Save() '<---- Here i get the error

Can you tell me what i’am doing wrong?

PS: I have to use the same filename for writing the changes cause otherwise Adobe Reader will not open the changed file correctly.

With kind regards,

T. Bunger

   bei System.IO.BinaryWriter..ctor(Stream output, Encoding encoding, Boolean leaveOpen)
   bei System.IO.BinaryWriter..ctor(Stream output)
   bei  ​  ..ctor(Stream  )
   bei  ​  . (Stream  )
   bei     ..ctor(Stream  ,       )
   bei  ​  . (Stream  ,       )
   bei     .    ​    ()
   bei     .    ​    ()
   bei Aspose.Pdf.Document.Save()
   bei XFA_Test.Form1.Button1_Click(Object sender, EventArgs e) in \\pbgfs1\Home\tbu\Eigene Dateien\Visual Studio-Projekte\XFA_Test\XFA_Test\XFA_Test\Form1.vb:Zeile 30.
   bei System.Windows.Forms.Control.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
   bei System.Windows.Forms.Button.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   bei XFA_Test.My.MyApplication.Main(String[] Args) in :Zeile 81.
   bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ThreadHelper.ThreadStart()<a class="attachment" href="/uploads/discourse_instance3/4907">Err.png</a> (14.7 KB)

@tbu

Thanks for contacting support.

You may use Document.Save() method (without argument(s)) while creating PDF document through incremental approach, whereas in case if you want to save PDF with same name, you may simply use Document.Save() method with filename argument. Please check following code snippet where I have filled form fields and saved document with the same name.

Dim pdfForm As New Aspose.Pdf.Facades.Form()
Dim doc As New Document(dataDir + "XFAPDF.pdf")
pdfForm.BindPdf(doc)

For Each name As String In pdfForm.FieldNames
	pdfForm.FillField(name, "12345")
Next

doc.Save(dataDir + "XFAPDF.pdf")

For your reference, I have attached generated PDF as well.

XFAPDF.pdf (1.7 MB)

Would you please explain a bit more about what type of issue you are stating here. We will definitely test it in our environment and address it accordingly.

Adobe_Err.png (87.7 KB)

Hello,

when i’am using Document.save() with filename argument the save-function works and i get no error. But then i’ll get an error when opening the saved file with adobe reader (see attachment).

With kind regards,

T. Bunger

@tbu

Thanks for writing back.

Extended features were enabled in the document, which you have shared earlier. It seemed that after processing the document through API, the extended features were gone, which is why the Adobe Reader is prompting this error dialog. Nevertheless, I have logged an investigation ticket as PDFNET-43189 in our issue tracking system.

We will further investigate it in detail and keep you posted with the status of its resolution. Please be patient and spare us little time.

We are sorry for this inconvenience.

@tbu,

Adding more to Asad’s comments, I have managed to replicate the above mentioned issue where we try to update the same document. For the sake of correction, I have logged it as PDFNET-43192 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.