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

Free Support Forum - aspose.com

Convert XFA to Dynamic AcroForm and Flatten them using Aspose.PDF for .NET

Hi,

I am using Aspose PDF dll to flatten my fillable pdf’s and its not working.

My actual requirement is to concatenate two pdf’s. When i am trying to concatenate a fillable pdf with normal pdf it is not concatenating hence i thought of flatten the fillable pdf and concatenate them.

Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(“input.pdf”, “HelloWorldOutputConv1.pdf”);
pdfForm.FlattenAllFields();
pdfForm.Save();

I am using Aspose.pdf version 7.1.0.0 Aspose.pdf.kit 5.4.0.0

Any help will be appreciated.

Thanks in advance…

Hello is there anyone to help. I tried all possible ways as per the examples on your site. none of them are working. Please help me.

Hi Rajesh,


Thanks for your inquiry. Please note old versions of Aspose.Pdf do not support concatenation of an XFA form with other PDF files. In newer versions, you can convert XFA form to standard Acro form and concatenate with other PDF files. Please check following documentation for the purpose. You may download and try latest version of Aspose.Pdf for .NET, it will help to resolve the issue.


Please feel free to contact us for any further assistance.

Best Regards,
tilal.ahmad:
Hi Rajesh,

Thanks for your inquiry. Please note old versions of Aspose.Pdf do not support concatenation of an XFA form with other PDF files. In newer versions, you can convert XFA form to standard Acro form and concatenate with other PDF files. Please check following documentation for the purpose. You may download and try latest version of Aspose.Pdf for .NET, it will help to resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,

Thanks for your reply.

I downloaded the latest dll Aspose.pdf (9.6.0.0) and tried the following code
Aspose.Pdf.Document doc = new Document("Standard.pdf");

doc.Form.Type = FormType.Standard;

Aspose.Pdf.Document doc2 = new Document("Fillablepdf.pdf");

doc2.Form.Type = FormType.Standard;

doc.Pages.Add(doc2.Pages);
doc.Save("Output.pdf");

I am receiving "Value cannot be null." exception while changing the form type from dynamic to standard. the bold and red color part above in the code.


I am adding the stack trace for your reference.

at System.Convert.FromBase64String(String s)
at . . ( , PointF , SizeF )
at . . ( , PointF , SizeF )
at . . ( , PointF , SizeF )
at . . ( )
at . . ( , , )
at . .Convert(Stream , Stream , SizeF )
at Aspose.Pdf.InteractiveFeatures.Forms.Form. (String , String )
at Aspose.Pdf.InteractiveFeatures.Forms.Form.set_Type(FormType value)
at ConcatenatePDFs.Form1.btnConcatenate_Click(Object sender, EventArgs e) in c:\Users\Documents\Visual Studio 2012\Projects\ConcatenatePDFs\ConcatenatePDFs\Form1.cs:line 97
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ConcatenatePDFs.Program.Main() in c:\Users\Documents\Visual Studio 2012\Projects\ConcatenatePDFs\ConcatenatePDFs\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Hi Rajesh,


Please share the resource PDF form so that we can test the conversion at our end. We are sorry for your inconvenience.
codewarior:
Hi Rajesh,

Please share the resource PDF form so that we can test the conversion at our end. We are sorry for your inconvenience.

Thanks Nayyer,

Please find the attached pdf i tried the conversion on.

I also tried with the following code

FileStream fs1 = new FileStream(@“HelloWorld.pdf”, FileMode.Open, FileAccess.Read);
FileStream fs2 = new FileStream(@“blank.pdf”, FileMode.Open, FileAccess.Read);
FileStream fileOutputStreamOut = new FileStream(@“streamouttest.pdf”, FileMode.Create, FileAccess.Write);
// concatenate files
PdfFileEditor editor = new PdfFileEditor();
editor.CopyLogicalStructure = true;
bool success = editor.Concatenate(fs1, fs2, fileOutputStreamOut);
MessageBox.Show("Successful… " + success);
// close the streams
fileOutputStreamOut.Close();
fs1.Close();
fs2.Close();

HelloWorld.pdf is a flat pdf and blank.pdf is fillable pdf. i tried concatenating them but seeing he following message in the second page

Please wait…

If this message is not eventually replaced by the proper contents of the document, your PDF viewer may not be able to display this type of document.

You can upgrade to the latest version of Adobe Reader for Windows®, Mac, or Linux® by visiting http://www.adobe.com/go/reader_download.

For more assistance with Adobe Reader visit http://www.adobe.com/go/acrreader.

Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or other countries. Mac is a trademark of Apple Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

my acrobat reader is upgraded to the latest version. i dont understand why i am getting this message.

Please help me. I am attaching the output pdf in this message.

Hi Rajesh,


Thanks for sharing additional information. While testing the scenario with your shared dynamic PDF form, we have managed to reproduce the issue. We have logged a ticket PDFNEWNET-37478 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,
tilal.ahmad:
Hi Rajesh,

Thanks for sharing additional information. While testing the scenario with your shared dynamic PDF form, we have managed to reproduce the issue. We have logged a ticket PDFNEWNET-37478 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,


Thank you very much. Will be waiting for your resolution.

Hi Rajesh,


Sure, we will update as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,