Trouble getting ImportXML to work

I am trying to import XML into a Dynamic PDF file to populate form value. The ImportXML and Save methods seem to work without error but when I open the destination PDF, it does not display the values that exist in the XML.


To ensure I was using valid XML, I manually populated the fields in another copy of the PDF document and used the ExportXML method. I am using that exact XML file to Import into my other document.

Aspose.Pdf.Kit.Form form = new Aspose.Pdf.Kit.Form(sourceFileName, destinationFileName);

// Import XML
file = new FileStream(xml, FileMode.Open);
form.ImportXml(file);
file.Close();

// Save form
form.Save();

I am using version 4.9.0.0 of Aspose.PDF.Kit. Please could you advise what I might be doing wrong.

I have attached the source form and XML file that I am using.

Thanks.

Hi Charles,

Thank you for sharing the sample code and template file.

I tried your sample code with the latest merged Aspose.Pdf for .NET v6.7.0 and it works fine. I would like to inform you that Aspose.Pdf for .NET and Aspose.Pdf.Kit for .NET have been merged into a single product and Aspose.Pdf.Kit for .NET has been discontinued as a separate product. All the features of Aspose.Pdf.Kit for .NET are available under Aspose.Pdf.Facades namespace of Aspose.Pdf for .NET v6.x. Please download and try the latest version of Aspose.Pdf for .NET v6.7 and check if you still face any issue. You can check the following documentation links to upgrade your code from Aspose.Pdf.Kit for .NET to the new merged Aspose.Pdf for .NET.

http://www.aspose.com/blogs/aspose-blogs/shahzad-latif/archive/2011/06/11/migrating-from-legacy-code-to-merged-aspose.pdf-for-.net.html

Please feel free to contact support in case you need any further assistance.

Sorry for the inconvenience,

Nausherwan,


When I use PDF.Kit I am able to open a PDF that has had Reader extensions applied. Unfortunately it does not update the field values.

If I use the newer Aspose.Pdf, the PDF is broken when the file is saved. When opening the PDF it tells me that the document has changed since it was last saved and the use of extended features is no longer available.

This used to work in Pdf.Kit and I need it to work in Aspose.Pdf. Surely the ImportXml method should work in the older Pdf.Kit works?

Please assist me in getting around this problem.

Thanks,
Charles

Hi Charles,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I have shared your sample code, template and resultant file with our development team to further analyze your issue. I will update you via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

<span style=“font-family: “Tahoma”,“sans-serif”; font-size: 10pt;”>Hi Charles,

Thanks for your patience.

Please note that Extended usage rights remain in PDF document when using Aspose.Pdf for .NET in in licensed mode and in order to preserve the extended usage rights, PDF must be updated incrementally. For
that we must initialize Aspose.Pdf.Facades.Form with input file/stream ==
output file/stream. Otherwise output file/stream will be totally re-saved
and hence extended usage rights will become broken. Please try using the following code snippet to maintain the extended Rights feature when filling data inside PDF document.

The resultant PDF generated with Aspose.Pdf for .NET 7.2.0 is also attached.

[C#]
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Aspose.Pdf.Facades.Form form = new Aspose.Pdf.Facades.Form("d:/pdftest/Source+Form.pdf", "d:/pdftest/Source+Form.pdf");

// Import XML

FileStream file = new FileStream("d:/pdftest/pdf.xml", FileMode.Open);

form.ImportXml(file);

file.Close();

// Save form

form.Save();

The issues you have found earlier (filed as PDFNEWNET-20907) have been fixed in Aspose.Pdf for .NET 7.2.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)