You are viewing limited content. For full access, please sign in.

Question

Question

exported text file has errors opening in EDI Notepad

asked on March 16, 2017

I am using Quick Fields to replace characters in a text file, then exporting the text to a unc path.  I am seeing a couple issues on the file:

1.  The file size doubles

2.  The file will not open in EDI Notepad with the following error:

It appears that exporting the text does some sort of encryption or something to the file in general and I need to know what it is so I can change it!  Any help is much appreciated.  

-Nate

0 0

Answer

SELECTED ANSWER
replied on March 17, 2017

I found that it was easier to export the text without using a documentexporter.  Here is my code

            String sTxt = null;
            if (this.ScriptEntryInfo.EntryType == EntryType.Document)
            {
                using (DocumentInfo CurDoc = (DocumentInfo)ScriptEntryInfo)
                {
                    using (PageInfoReader pReader = CurDoc.GetPageInfos())
                    {
                        foreach (PageInfo PI in pReader)
                        {
                            if (PI.HasText)
                            {
                                using (System.IO.StreamReader reader = PI.ReadTextPagePart())
                                {
                                    if (String.IsNullOrEmpty(sTxt))
                                    {
                                        sTxt = reader.ReadToEnd();
                                    }
                                    else
                                    {
                                        sTxt = sTxt + Environment.NewLine + reader.ReadToEnd();
                                    }
                                }
                            }
                        }
                    }
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\Temp\\" + CurDoc.Name + ".txt"))
                    {
                        file.Write(sTxt);
                    }
                }
            }
            else
            {
                // Entry is not a document
            }

Hope this helps.

3 0

Replies

replied on March 16, 2017

When testing the file export from the Client, make sure that you're not exporting the text with Unicode formatting.

Go into Tools > Options > Export > Text and uncheck the option to "Format text using Unicode"

Then export the document text again and confirm that it can be opened in EDI Notepad now.

1 0
replied on March 16, 2017

Alex,

Unicode is the issue.  If I make this setting change on my client, does the impact my workflow?  I am using the DocumentServices.DocumentExporter class to export the text.

0 0
replied on March 16, 2017

Try to use the DocumentExporter.TextEncoding to set it to ASCII.

1 0
replied on March 16, 2017

Bert,

I think I am on the correct track, but I cannot get the text to appear now.  Any help you can provide is much appreciated!  Here is the code I am using that returns empty text files.  

public class Script1 : RAScriptClass102
    {
        public Encoding TextEncoding {get; set;}
        public string Text {get; set;}
        /// <summary>
        /// This method is run when the activity is performed.
        /// </summary>
        protected override void Execute()
        {
            // Write your code here. The BoundEntryInfo property will access the entry, RASession will get the Repository Access session
            DocumentExporter exporter = new DocumentExporter();
            int docID = Convert.ToInt32(this.GetTokenValue("Entry ID"));
            using (DocumentInfo docInfo = Document.GetDocumentInfo(docID, this.Connection)) {
                docInfo.Lock(LockType.Exclusive);
                exporter.ExportElecDoc(docInfo, "//myservername//" + docInfo.Name + ".txt");
                docInfo.Unlock();
            }
        }

Thanks,

Nate

0 0
SELECTED ANSWER
replied on March 17, 2017

I found that it was easier to export the text without using a documentexporter.  Here is my code

            String sTxt = null;
            if (this.ScriptEntryInfo.EntryType == EntryType.Document)
            {
                using (DocumentInfo CurDoc = (DocumentInfo)ScriptEntryInfo)
                {
                    using (PageInfoReader pReader = CurDoc.GetPageInfos())
                    {
                        foreach (PageInfo PI in pReader)
                        {
                            if (PI.HasText)
                            {
                                using (System.IO.StreamReader reader = PI.ReadTextPagePart())
                                {
                                    if (String.IsNullOrEmpty(sTxt))
                                    {
                                        sTxt = reader.ReadToEnd();
                                    }
                                    else
                                    {
                                        sTxt = sTxt + Environment.NewLine + reader.ReadToEnd();
                                    }
                                }
                            }
                        }
                    }
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\Temp\\" + CurDoc.Name + ".txt"))
                    {
                        file.Write(sTxt);
                    }
                }
            }
            else
            {
                // Entry is not a document
            }

Hope this helps.

3 0
replied on March 16, 2017

Can you open the file in MS Notepad?  Is it possible that your editing is removing/replacing separator or delimiter characters and invalidating the EDI standard?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.