johnstahl Posted January 22, 2011 Share Posted January 22, 2011 I am trying to include a text file into a rule. The test file is basically a series of style sheets that are then used to format text in the document. I want to use the text file to do this so that I can have a single set of styles for all application for this customer. I used the line shown below with various variations. I get "syntax error" and can not seem to get it to work. I wanted to include in the JavaScriptGlobals for the application. This is where I keep teh styles when they are coded into each application. I may be able to put them in OnRecordStart but this does not seem to be the correct location. <include file="\\\\dir1\\programing\\dir2\\TESTdir3\\StylesSeet.txt"> Thank you John Link to comment Share on other sites More sharing options...
johnstahl Posted January 23, 2011 Author Share Posted January 23, 2011 I am trying to include a text file into a rule. The test file is basically a series of style sheets that are then used to format text in the document. I want to use the text file to do this so that I can have a single set of styles for all application for this customer. I used the line shown below with various variations. I get "syntax error" and can not seem to get it to work. I wanted to include in the JavaScriptGlobals for the application. This is where I keep teh styles when they are coded into each application. I may be able to put them in OnRecordStart but this does not seem to be the correct location. <include file="\\\\dir1\\programing\\dir2\\TESTdir3\\Styles Sheet.txt"> Also tried the very simple <include file=StylesSheet.txt> still a syntax error Thank you John Link to comment Share on other sites More sharing options...
Dan Korn Posted January 24, 2011 Share Posted January 24, 2011 You can bring in the contents of a text file from a rule with the CreateResource function, like so: return CreateResource("\\\\dir1\\programing\\dir2\\TESTdir3\\Styles Seet.txt");However, it seems like you're trying to do something like a CSS style sheet, as if you were programming HTML, but FusionPro simply doesn't support that concept. You can modify paragraph and character styles in the Variable Text Editor, or you can use markup tags, but you can't define a named style to be applied. Well, actually, you can, if you're using FusionPro Server, and you use the DIF control API to modify the internal paragraph styles, but they aren't exposed in FusionPro Desktop. Link to comment Share on other sites More sharing options...
johnstahl Posted January 26, 2011 Author Share Posted January 26, 2011 so include does not work as suggested in the documentation. Basically we have variables set to font and paragraph setting values and we insert the variable before each set of text where a style change is needed. The variable then puts all of the values we set the variable to infront of the text. This works well and we have a common stylesheet that has all of the styles in a text file. The documentation suggests to just include file at the start of a rule (vbscript). We wanted to add it at JavaScript Globals... so that it is available to us through out the documtent. We do have Server but this seemed to be an easy approach. Please fill in the blanks for me. will CreateResouce make the contents of the Text file usable as code inside of a rule? This is out of the TagsRefGuide: Include Tag Syntax <include file=C:\Example\input.txt> Example <include file=input.txt> Function References a text file so that you can insert text chunks from various text files. Further explanation of including text files in hypertext is provided in Hypertext on page 65. Attributes file Required. Name of the text file to be inserted. Link to comment Share on other sites More sharing options...
Dan Korn Posted January 27, 2011 Share Posted January 27, 2011 so include does not work as suggested in the documentation. ... This is out of the TagsRefGuide: Include Tag Syntax <include file=C:\Example\input.txt> Example <include file=input.txt> Function References a text file so that you can insert text chunks from various text files. Further explanation of including text files in hypertext is provided in Hypertext on page 65. Attributes file Required. Name of the text file to be inserted. That only works inside a tagged markup input file, not from a JavaScript rule. I apologize that the documentation isn't more clear about this. Basically we have variables set to font and paragraph setting values and we insert the variable before each set of text where a style change is needed. The variable then puts all of the values we set the variable to infront of the text. Okay, this is possible. It's a reasonable way to do what you're doing. Although there are other ways to accomplish this kind of thing, with Formatted Text resources, or even with reusable components; I'd have to look at your job to suggest something more specific. This works well and we have a common stylesheet that has all of the styles in a text file. The documentation suggests to just include file at the start of a rule (vbscript). Which documentation is this which references VBScript? We wanted to add it at JavaScript Globals... so that it is available to us through out the documtent. No, if you want to apply some formatting (markup) tags to text, you have to do it before each bit of text you want to modify. You can't globally modify text throughout the job (except for certain specific characteristics such as word spacing and superscript/subscript/small caps ratios and offsets). You can read in the contents of a tagged file resource into a global variable in JavaScript, so that you don't have to read the file every time you want to apply the tags, but you still need to apply the tags to text in specific instances. Please fill in the blanks for me. will CreateResouce make the contents of the Text file usable as code inside of a rule? Absolutely. It can be as simple as this: return CreateResource("filename.txt", "tagged text file").content + TaggedTextFromRaw(Field("Your Field Name"));The above will prepend the contents of the tagged text resource file before the contents of the field, in effect applying the formatting specified in the tags to the field value. You need to specify "tagged text file" as the type of resource so that markup characters in the file are treated as such instead of as literal characters. Likewise, the TaggedTextFromRaw call (NormalizeEntities in older versions of FusionPro) ensures that any special characters in the data field are handled as literal (raw) text instead of as markup (tagged). Also, make sure to check the "Treat returned strings as tagged text" box. As I said, you'll have to create a rule like this for each text field to which you want to apply the formatting. You can name the rule the same as the field to override instances of the field variable in your text frame contents. (Or you can override fields in batches with the FusionPro.Composition.AddVariable function in OnRecordStart.) However, another way to do this is to have to have the rule simply return the tagged markup from your text file, like so: return CreateResource("filename.txt", "tagged text file");Then you can insert the variable with the rule's name before any other text in your frames (in the Variable Text Editor). It still needs to be applied to each instance of text, however. And again, if you're using FusionPro Server, you can use the DIF API to modify the DIF (format) file to change the styles of text. You can even modify the default paragraph and character styles, named "(no style)", which FusionPro applies to all text in FP Desktop frames, which is effectively a global change for the entire job. This has to be done before the composition is run in FP Server, however, not in any JavaScript logic in the template itself. Link to comment Share on other sites More sharing options...
Doug Pershing Posted January 31, 2011 Share Posted January 31, 2011 Hi John, To load the common style sheet save it as a .js file. In the JavaScript Globals enter a Load command as: stylesheet="\\\\dir1\\programing\\dir2\\TESTdir3\\Styles Sheet.js" Load(stylesheet) The variables that have been set in your .js file (all of the text and character formatting) will then become available for use within all of your rules. This will work with both the Desktop and Server versions. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.