RTF output

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
AL1969
Jr. Propeller Head
Posts: 2
Joined: Tue Sep 08, 2015 2:15 am

RTF output

Post by AL1969 »

We have a document (License Agreement) edited in Flare we have already as PDF output.
The same document should be shown in our setup.exe (installer, based on NSIS) - this needs to be RTF format. Right now we manage a copy (converted from Flare's doc output).
I want to generate the RTF file as Flare output too, but didn't find an options for that (only Word doc files or something like this).
Any idea?
Nita Beck
Senior Propellus Maximus
Posts: 3672
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: RTF output

Post by Nita Beck »

Welcome to the forums! :)

Flare does not have an RTF target type, so the only way I think you can achieve this is to use a Word target to generate a Word file and then use Word to save that file as an RTF file.

Probably not quite what you wanted to learn.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
SteveS
Senior Propellus Maximus
Posts: 2090
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: RTF output

Post by SteveS »

You could create a batch file that uses madbuild to create word output and then save the word output as a rich text file...
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
Paulie
Sr. Propeller Head
Posts: 140
Joined: Sun Mar 01, 2015 3:01 pm

Re: RTF output

Post by Paulie »

Hi there,

One way to achieve this would be to add the following code to your Normal.dot template. The AutoOpen() macro runs automatically each time that Word is opened, but the code below will exit without doing anything under most circumstances and should only create a .rtf file if:
  • The document comes from Flare (it checks for the Author being MadCap Software).
  • The document is the document that you want to convert (all other Flare documents will be ignored).
  • The document has not been processed before (The Author name is changed to your company name preventing the macro from running twice.
To use this you will need to change:
  • YourDocumentName.doc to the name of your document (name and extension only, the path is not required)
  • <Your Company Name> to the name of your company
Final disclaimer, I haven't tested this, so use it at your own risk! (however, I do use something similar for my own Flare projects). :-)

Code: Select all

Sub AutoOpen()

On Error GoTo ExitSub:
'
' This will check if the document opened is a Flare-generated document.
' If this is the first time that document has been opened, the headings will be updated.

If Application.Documents.Count = 0 Then Exit Sub
If TestIfFlareDocument() = False Or ActiveDocument.Name<>"YourDocumentName.doc" Then Exit Sub

Application.ScreenUpdating = False

Call UpdateTitleAndAuthorInfo
Call SaveAsRtf

ActiveDocument.Save
ExitSub:

Application.ScreenUpdating = True
End Sub

Function TestIfFlareDocument()

If ActiveDocument.BuiltInDocumentProperties("Author") = "MadCap Software" Then
TestIfFlareDocument = True
Else
TestIfFlareDocument = False
End If


End Function

Sub UpdateTitleAndAuthorInfo()
Set Doc = ActiveDocument
With Doc
.BuiltInDocumentProperties("Author") = "<Your Company Name>"
.BuiltInDocumentProperties("Company") = "<Your Company Name>"

End With


End Sub

Sub SaveAsRtf()
Dim FileName As String
With ActiveDocument

FileName = Left(.FullName, InStrRev(.FullName, ".") - 1) & ".rtf"

     .SaveAs2 FileName:=FileName, _
        FileFormat:=wdFormatRTF
End With

  
End Sub
"In an ideal world, software should be simple, well designed, and completely intuitive to end users. In the real world, good documentation is king."
AL1969
Jr. Propeller Head
Posts: 2
Joined: Tue Sep 08, 2015 2:15 am

Re: RTF output

Post by AL1969 »

Hi all,
thank you for the interesting answers.
But I forgot to mention that we have an automatic build process (Continuous Integration with the Flare Code in git and a kind of madbuild job in Atlassian Bamboo) creating our documentation PDF's automatically if a change is checked in.
That's why I need a batch way without opening Word or something interactive.
Anybody using a converter from Word to RTF?
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: RTF output

Post by RamonS »

You could try a macro. Seems as that /mmacroname starts Word and executes the named macro. Not sure if that helps because I am not that versed with Word macros.
Also found this http://wordribbon.tips.net/T013068_Pass ... Macro.html
A full list of the Word command line switches is here https://support.microsoft.com/en-us/kb/210565
Paulie
Sr. Propeller Head
Posts: 140
Joined: Sun Mar 01, 2015 3:01 pm

Re: RTF output

Post by Paulie »

Hi there,

If you are still looking for a solution, then you could combine Ramon's suggested start up switch with the SaveAsRtf() Macro that I originally attached.

So the steps would be:
1. Add the following Macro to your Normal template:

Code: Select all

Sub SaveAsRtf()
Dim FileName As String
With ActiveDocument

FileName = Left(.FullName, InStrRev(.FullName, ".") - 1) & ".rtf"

     .SaveAs2 FileName:=FileName, _
        FileFormat:=wdFormatRTF
End With
  
  Application.Quit
End Sub
2. Build your target using your existing process.

3. Add a post publishing step to your build process to shell execute the following (you will need to adjust the paths to your WINWORD executable and the source Word document):

Code: Select all

"C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" "C:\Documents\DocumentName.docx" /mSaveAsRtf /q 
Result: Word opens, saves the document as an RTF document, then immediately closes.
"In an ideal world, software should be simple, well designed, and completely intuitive to end users. In the real world, good documentation is king."
Post Reply