We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Convert xml to Word, the xml has absolute positions

How to convert xml to Word or some template I could use, the xml elements have absolute positions, the placeholder(all select statements in XML) should be replaced later in c#.



Attachment: absolutePositionedXMLToWordOrSomeTemplate_52d7d856.7z

12 Replies

SV Sarathkumar V Syncfusion Team April 22, 2016 01:50 PM UTC

Hi Customer,

Currently DocIO does not has support for custom XML and we have already logged this as a feature and the feature will be available in any of our upcoming releases. Please check our website periodically for feature related updates.

Regards,
Sarath 



TE Testname April 22, 2016 01:54 PM UTC

Ok, but how can I use absolute positions on word or any template ,like in my exampl file?


SV Sarathkumar V Syncfusion Team April 25, 2016 09:21 AM UTC

Hi Customer,

Thank you for your update.

You can use our find and replace functionality to replace particular word/text in the Word document template. For more details about find and replace functionality of DocIO, please refer the following on line UG documentation link:

Online UG Link:
http://help.syncfusion.com/file-formats/docio/working-with-find-and-replace

Also please refer our online demo samples for your reference from the following link:

Online Demo link:

http://mvc.syncfusion.com/demos/web/docio/advancedreplace

Regards,
Sarath 



TE Testname April 25, 2016 09:32 AM UTC

I know, but imagine I have a blank page, where I need to set the position  absolute somethinglike in a coordinate system


SV Sarathkumar V Syncfusion Team April 26, 2016 10:52 AM UTC

Hi Customer,

Thanks for your update.

On further analyzing your requirement, you can add the text to the paragraph and then you can set the left indent to position the paragraph to achieve your requirement. For your reference please refer the following code snippet which will useful to achieve your requirement.

Code Snippet:
            //Create a new Word document 
            WordDocument document = new WordDocument(); 
            //Add new section to Word document 
            document.AddSection(); 
 
            //Add paragraph to section 
            WParagraph paragraph = document.LastSection.AddParagraph() as WParagraph; 
            //Add the text to paragraph 
            WTextRange textRange = paragraph.AppendText("coordinate {adj}") as WTextRange; 
            textRange.CharacterFormat.Font = new System.Drawing.Font("Arial", 12, FontStyle.Bold); 
 
            //Add paragraph to section 
            paragraph = document.LastSection.AddParagraph() as WParagraph; 
            //Set the left indent value to position the pargraph 
            paragraph.ParagraphFormat.LeftIndent = 18; 
            //Add the text to paragraph 
            textRange = paragraph.AppendText("nebengeordnetling.") as WTextRange; 
            textRange.CharacterFormat.Font = new System.Drawing.Font("Arial", 10, FontStyle.Regular); 
 
            //Add paragraph to section 
            paragraph = document.LastSection.AddParagraph() as WParagraph; 
            //Add the text to paragraph 
            textRange = paragraph.AppendText("coordinate {adj} [equal in rank or importance] [also: co-ordinate]") as WTextRange; 
            textRange.CharacterFormat.Font = new System.Drawing.Font("Arial", 12, FontStyle.Bold); 
 
            //Add paragraph to section 
            paragraph = document.LastSection.AddParagraph() as WParagraph; 
            //Set the left indent value to position the pargraph 
            paragraph.ParagraphFormat.LeftIndent = 18; 
            //Add the text to paragraph 
            textRange = paragraph.AppendText("gleichrangig") as WTextRange; 
            textRange.CharacterFormat.Font = new System.Drawing.Font("Arial", 10, FontStyle.Regular); 
 
            //Save the Word document 
            document.Save("Sample.docx");

If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description. Thereby we will analyse further on the mentioned case and will provided you appropriate solution.

Regards,
Sarath
 



TE Testname April 27, 2016 04:02 AM UTC

actually I would like to have a file where i change the position absolutely and read the file with syncfusion and replace placeholders


SV Sarathkumar V Syncfusion Team April 28, 2016 11:57 AM UTC

Hi Customer,

Thank you for your update.

On further analyzing your given details, we could not conclude your exact requirement. Please provide the following details to confirm your requirement: 
1.    Whether you are trying to position the text in the Word document or any other element? 
2.    Do you have any input Word document? If so, please provide us. 
3.    Can you provide us what type of palace holders do you have in Word document? 
4.    Screenshot of expected output and your complete work flow structure. 
Regards,
Sarath 



TE Testname April 29, 2016 06:27 AM UTC

1.    Whether you are trying to position the text in the Word document or any other element?
->I don't care, it depends on your library if you can take a word file I am fine, if you need a some kind of image i am fine with it as well
2.    Do you have any input Word document? If so, please provide us.
-> yes, but the document has been converted from a pdf and the pdf has been generated from an xml "absolutePositionedXMLToWordOrSomeTemplate_52d7d856.7z"(first post), the problem is if I had to add a new field to the converted docx the absolute positions wont fit anymore
3.    Can you provide us what type of palace holders do you have in Word document?
-> attachment
4.    Screenshot of expected output and your complete work flow structure.
->result.pdf

Attachment: result_c120fa60.7z


TE Testname April 29, 2016 06:28 AM UTC

the word attachment, the template

Attachment: template_9227d62.7z


SV Sarathkumar V Syncfusion Team May 2, 2016 01:24 PM UTC

Hi Customer,

Thank you for your update.

On further analyzing your given template Word document, we have found that the Word document has some custom defined tab stop positions. Hence after replacing the placeholders with text, the text will be positioned based on the custom tab stops defined in the corresponding paragraph in the Word document. It is an actual behavior of Microsoft Word document and DocIO also doing the same. So, we have modified your given input template Word document by removing the unnecessary tab stop positions in the Word document. Please find the modified input Word document from the following link and code snippet to replace the placeholder text using DocIO from below:

Modified Word document:
http://www.syncfusion.com/downloads/support/forum/123789/ze/template_Modified-1943144393.zip

Code Snippet:
            //Load the template document using DocIO 
            WordDocument document = new WordDocument(@"F:\Issue Samples\Incidents\123789  -  Convert xml to Word the xml has absolute positions\template_Modified.docx", FormatType.Docx); 
            //Replace the placeholder text 
            document.Replace("${kundennummer}", "xxx", false, false); 
            document.Replace("${vertragsNr}", "xxx", false, false); 
            document.Replace("${gueltigVonTag}", "xxx", false, false); 
            document.Replace("${gueltigVonMonat}", "xxx", false, false); 
            document.Replace("${gueltigVonJahr}", "xxx", false, false); 
            document.Replace("${gueltigBisTag}", "xxx", false, false); 
            document.Replace("${gueltigBisMonat}", "xxx", false, false); 
            document.Replace("${gueltigBisJahr}", "xxx", false, false); 
            document.Replace("${versicherungsscheinNr}", "xxx", false, false); 
            document.Replace("${kennzeichen}", "xxx", false, false); 
            document.Replace("${fahrzeugart}", "xxx", false, false); 
            document.Replace("${fabrikat}", "xxx", false, false); 
            //Saves the document in the given name and format 
            document.Save("Replace.docx", FormatType.Docx); 
            //Releases the resources occupied by WordDocument instance 
            document.Close();

If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description. Thereby we will analyse further on the mentioned case and will provided you appropriate solution.

Regards,
Sarath
 



TE Testname May 2, 2016 02:39 PM UTC

But if I want to add new fields ? what do do then ? in my xml i could use absolute positions but not in word ?!


SV Sarathkumar V Syncfusion Team May 3, 2016 12:45 PM UTC

Hi Customer,

Thank you for your update.

We have prepared a sample to add the absolute positioned place holder using paragraph tabs in the Word document. Please find the sample from the following link and let us know if it helps.

Sample Link:

http://www.syncfusion.com/downloads/support/forum/123789/ze/FindAndReplaceWordDemo2028988654.zip

If we misunderstood any of your requirement then kindly elaborate the actual requirement with detailed description. Thereby we will analyse further on the mentioned case and will provided you appropriate solution.

Regards,
Sarath 


Loader.
Up arrow icon