Newbies sharkwood Posted September 14, 2010 Newbies Posted September 14, 2010 Hi all! I'm trying to simply export a field (or record if I have to) in RTF format so that the formatting I've assigned to this field's data (font, font size, style) will carry forth. Have tried every option I could find but none work. The resultant RTF file will be placed in InDesign ultimately, FWIW. Is this a job for Applescript? Thanks for any help!
meerestier Posted October 7, 2010 Posted October 7, 2010 I am having a similar situation... Is there any advice out there? ;-)
Lee Smith Posted October 7, 2010 Posted October 7, 2010 The list of supported Import and Export formats are in your User Guide, FileMaker's Online Help (when you have FileMaker open), just search for the Keywords [color:blue]Supported import/export file formats, It is also available Here Notice that RTF is not included. You can however, export using the current layout formatting for things such as numbers and dates by checking the box that appears when selecting which fields to include in the export, but it does not include text styles items li,e (font, size, style, color, etc.). HTH Lee
comment Posted October 7, 2010 Posted October 7, 2010 Over the years several methods have been suggested for exporting RTF from Filemaker. The basic idea is to produce a template in a word-processing application, then exchange the placeholders in the template with Filemaker data. These methods were successful to various degrees (mainly due to the "flexibility" of the format). However, the purpose of all these methods was to export data in a pre-formatted template - NOT to preserve user-formatting done inside Filemaker. That would be significantly more complex. In any case, if the ultimate target is another application (e.g. InDesign), RTF is hardly the best intermediate format. If the target application can read XML, then this would be my first choice. In-field formatting can be exported through either GetAsCSS() or GetAsSVG() functions.
fseipel Posted October 8, 2010 Posted October 8, 2010 (edited) If you need to export RTF, you can copy a field to the clipboard, then extract the RTF from it. This works, because the clipboard contains text and RTF representations of the data so copied, thus the font, color, size, etc are preserved. I tried the following, and it worked great under Windoze (360Works ScriptMaster required). This returns both the RTF in the text result, and writes it out to a file designated in fname (I used c:thetext.rtf for fname). When I double click thetext.rtf, the resulting file shows formatting identical to the filemaker field it was copied from, and opens in Wordpad, the default application for RTF in Windoze. This could definitely use some cleanup/optimization, but it is a good working proof of concept (needs try, catch to handle exceptions, check if clipboard contains only text with no RTF, read lines instead of bytes from inputstream to speed up, etc). The second listing dumps out all flavors present on the clipboard as a text result (may be useful so you can pick one). I include this because this may require some modification to run on Macs? import java.awt.*; import java.awt.datatransfer.*; // If a string is on the system clipboard, this method returns it; // otherwise it returns null. // get the clipboard contents Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = clipboard.getContents(null); RTF_Results = ""; DataFlavor flavor = new DataFlavor("text/rtf;class=java.io.InputStream"); InputStream stream = (InputStream) transferable.getTransferData(flavor); int b; char c; while ((b = stream.read()) != -1) { c = (char)b; RTF_Results = RTF_Results+ Character.toString©; } OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( fname ), "utf-8" ); writer.write( RTF_Results ); writer.close(); return RTF_Results; ------------------ //This generates list of flavors in clipboard import java.awt.*; import java.awt.datatransfer.*; Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = clipboard.getContents(null); // dump out all available flavors String flavor_list = ""; DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { flavor_list = flavor_list + flavors + "n"; } return flavor_list; -------------------------------------- Typical flavor list for some formatted text in Windoze FM11. Note the rtf representations. java.awt.datatransfer.DataFlavor[mimetype=application/x-java-text-encoding;representationclass= java.awt.datatransfer.DataFlavor[mimetype=text/rtf;representationclass=java.io.InputStream] java.awt.datatransfer.DataFlavor[mimetype=text/rtf;representationclass=java.nio.ByteBuffer] java.awt.datatransfer.DataFlavor[mimetype=text/rtf;representationclass= java.awt.datatransfer.DataFlavor[mimetype=application/x-java-serialized-object;representationclass=java.lang.String] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.Reader] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.lang.String] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.CharBuffer] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[C] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=unicode] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=UTF-16] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-8] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-8] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=UTF-8] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16BE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16BE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=UTF-16BE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16LE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16LE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=UTF-16LE] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ISO-8859-1] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=ISO-8859-1] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=ISO-8859-1] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=windows-1252] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=windows-1252] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=windows-1252] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=US-ASCII] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=US-ASCII] java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[b;charset=US-ASCII] Edited October 8, 2010 by Guest Clarification
fseipel Posted October 8, 2010 Posted October 8, 2010 It ought also be possible to do the reverse of what was requested; that is, insert an RTF file onto the clipboard, and from clipboard, paste formatted text into an FM field since FM scripting language supports Paste. Another interesting possibility would be to use JODConverter to convert between RTF and HTML, so that you could, say, convert HTML to RTF and thereby insert rendered HTML into a text field. JODConverter is still in beta, it uses Openoffice. I made a few changes to what I posted yesterday, so rudimentary error trapping is included and the clipboard is read a line at a time. To use this, use an FM script to copy a field to clipboard, then run the script which returns the RTF as text, and writes it to a file. Also be sure text color isn't white or it won't be visible in Wordpad. // // First copy field to clipboard, then run this script to extract RTF contents of field // Script returns RTF as text // Script also writes RTF to filename designated 'fname' // import java.awt.*; import java.awt.datatransfer.*; // If a string is on the system clipboard, this method returns it; // otherwise it returns null. // get the clipboard contents Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable transferable = clipboard.getContents(null); RTF_Results = ""; // This attempts to open an inputstream to the text/rtf flavor of the clipboard try { DataFlavor flavor = new DataFlavor("text/rtf;class=java.io.InputStream"); InputStream stream = (InputStream) transferable.getTransferData(flavor); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { RTF_Results = RTF_Results + strLine; } try { OutputStreamWriter writer = new OutputStreamWriter( new FileOutputStream( fname ), "utf-8" ); writer.write( RTF_Results ); writer.close(); return RTF_Results; } catch (Exception e2) { return e2;} // Exception will occur if output file fails to write } catch (Exception e) { return e; } // Exception will occur if clipboard does not contain rtf/text
Newbies c4d Posted November 30, 2013 Newbies Posted November 30, 2013 Q. Simply export a field? A. It is a Job for AppleScript The Table's Fields RichTextExporter::text -----Text Here is where you have the filemaker rich text you want to export RichTextExporter::text2 -----Text This is the field you use for temporarily storing the CSS-Text RichTextExporter::selfLocation -----Calculaltion Substitute ( (Substitute ( Get ( FilePath ) ; "file:/" ; "/Volumes/" )) ; "RichTextExporter.fmp12" ; "" )The ScriptSet Field [ RichTextExporter::text2; GetAsCSS ( RichTextExporter::text ) ] Export Field Contents [ RichTextExporter::text2; “file:RichTextExporter.htm” ] Perform AppleScript [ Calculated AppleScript: "set Source to "'" & RichTextExporter::selfLocation & "RichTextExporter.htm" & "'"" & ¶ & "set Dest to "'" & RichTextExporter::selfLocation & "RichTextExporter.rtf" & "'"" & ¶ & "set ShellScript to "textutil -cat rtf " & Source & " -output " & Dest" & ¶ & "set theReturn to do shell script ShellScript" ]
Newbies CryoGen114 Posted December 1, 2013 Newbies Posted December 1, 2013 We're using 360Works's Scribe plugin to do this. It actually punches out our contract text to a Word file, but it can export to many different formats. It operates as a glorified find-and-replace tool, but it actually works very nicely. Look here: http://www.360works.com/filemaker-pdf-plugin/
Recommended Posts
This topic is 4011 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now