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.
Unfortunately, activation email could not send to your email. Please try again.

Convert xml to Word, the xml has absolute positions

Thread ID:

Created:

Updated:

Platform:

Replies:

123789 Apr 21,2016 09:37 AM May 3,2016 08:45 AM ASP.NET MVC 12
loading
Tags: DocIO
Testname
Asked On April 21, 2016 09:37 AM

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

Sarathkumar V [Syncfusion]
Replied On April 22, 2016 09:50 AM

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 


Testname
Replied On April 22, 2016 09:54 AM

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

Sarathkumar V [Syncfusion]
Replied On April 25, 2016 05:21 AM

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 


Testname
Replied On April 25, 2016 05:32 AM

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

Sarathkumar V [Syncfusion]
Replied On April 26, 2016 06:52 AM

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
 


Testname
Replied On April 27, 2016 12:02 AM

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

Sarathkumar V [Syncfusion]
Replied On April 28, 2016 07:57 AM

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 


Testname
Replied On April 29, 2016 02:27 AM

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

Testname
Replied On April 29, 2016 02:28 AM

the word attachment, the template

Attachment: template_9227d62.7z

Sarathkumar V [Syncfusion]
Replied On May 2, 2016 09:24 AM

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
 


Testname
Replied On May 2, 2016 10:39 AM

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

Sarathkumar V [Syncfusion]
Replied On May 3, 2016 08:45 AM

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;