Adding text to a RTF document

I'm reposting this because my last post was very poorly written. I have a JTextPane that uses a RTF editor kit, and what I want to do is add some text to the very beginning and end of the document with out losing the formatting of the RTF. What I do now is get a string from the Editor Kit that is RTF text but I can't just add to the front because of the formatting there, {rtf and all that jazz. What I do is use the getText() function to get just the unformatted text, then get the first 10 chars, and then search for that in the RTF string, and insert text there. It seems to be a bit of a crude way to go about it; even so I would be fine with it if it didn't fail with non-English characters. (You know like the French e with the accent or the German u with the 2 dots). So what I�m looking for is some sort of way to insert the text programmatically eliminating the need for searching and all that. Any help will be greatly appreciated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Forgive me if you know this already but I'd like to offer what I can...
The JTextComponent (and it's subclasses) makes use of a Document for a lot of its Model. If you haven't set a different one explicitly, then the RTFEditorKit will see that an appropriate StyledDocument is used on your JTextPane. The Document interface allows for raw text (without markup, formatting, etc) to be mutated with optional formatting attributes (inserts, replaces, etc.).
I think what you are looking for lies in the Document of the JTextPane. The getDocument() method will return the Document holding the text and can be mutated at will (either by typing into the component or programmatically inserting text).
When you call getText() on your text component, the call is delegated to the installed editor kit and returns the contents. The text component calls the write( Writer, .... ) on the EditorKit but the RTFEditorKit actually should throw an exception and cause null to be returned from the getText() method of JEditorPane. To get the marked up, rtf text you would need to call the write( OutputStream, ... ) method.
Here is programmatic insertion at the beginning and end...
    JTextPane textPane = new JTextPane();
    textPane.setEditorKit( new RTFEditorKit() );
    //pretend we've grabbed an rtf file and set it's contents with the setText() method.
    Document doc = textPane.getDocument();
    try{      
        doc.insertString( 0, "begin", null );
        doc.insertString( doc.getLength(), "end", null );
    }catch( BadLocationException ex ){
        //what ever you need to do
    //now of course to get the rtf formatted string out of the editor kit
    //you need to write it to an OutputStream (i.e. System.out, a FileOutputStream, etc.)
    try{
        textPane.getEditorKit().write( System.out, doc, 0, doc.getLength() );
    }catch( BadLocationException ex ){
        //what ever you need to do
    }catch( IOException ex ){
        //what ever you need to do
    }I didn't pass any formatting attributes into the calls of the insertString method but you could easily do that if you need to.
Hope that helps!
Matt

Similar Messages

  • Problem with adding text to a syntax document

    Hello,
    I am trying to write an editor with syntax highlighting option.
    The syntax document works fine but on a slow computer
    after loading a huge document it is impossible to write fluently.
    I think the method highlightKeyword() is not the problem because it highlights still only one line.
    The problem seems to be the rootElement.Has anybody an idea how to make the rootElement faster
    working?
    I also tried to use threads (such as http://ostermiller.org/syntax/editor.html) for inserting text, but then the document is highlighted very slowly.
    Can anybody help me?
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class SyntaxTest extends DefaultStyledDocument
         Element rootElement;
         String wordSeparators = ",:;.()[]{}+-/*%=<>!&|~^@? ";
         Vector keywords = new Vector();;
         SimpleAttributeSet keyword;
         public SyntaxTest()
              rootElement= this.getDefaultRootElement();
              keyword = new SimpleAttributeSet();
              StyleConstants.setForeground(keyword, Color.blue);
              keywords.add( "abstract" );
              keywords.add( "boolean" );
              keywords.add( "break" );
              keywords.add( "byte" );
              keywords.add( "case" );
              keywords.add( "catch" );
              keywords.add( "char" );
              keywords.add( "class" );
              keywords.add( "continue" );
              keywords.add( "default" );
              keywords.add( "do" );
              keywords.add( "double" );
              keywords.add( "else" );
              keywords.add( "extends" );
              keywords.add( "false" );
              keywords.add( "final" );
              keywords.add( "finally" );
              keywords.add( "float" );
              keywords.add( "for" );
              keywords.add( "if" );
              keywords.add( "implements" );
              keywords.add( "import" );
              keywords.add( "instanceof" );
              keywords.add( "int" );
              keywords.add( "interface" );
              keywords.add( "long" );
              keywords.add( "native" );
              keywords.add( "new" );
              keywords.add( "null" );
              keywords.add( "package" );
              keywords.add( "private" );
              keywords.add( "protected" );
              keywords.add( "public" );      
              keywords.add( "return" );
              keywords.add( "short" );
              keywords.add( "static" );
              keywords.add( "super" );
              keywords.add( "switch" );
              keywords.add( "synchronized" );
              keywords.add( "this" );
              keywords.add( "throw" );
              keywords.add( "throws" );
              keywords.add( "true" );
              keywords.add( "try" );
              keywords.add( "void" );
              keywords.add( "volatile" );
              keywords.add( "while" );
         public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
              super.insertString(offset, str, a);
              int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
              int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+str.length())).getEndOffset() -1;
              //highlight the changed line
              highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
         public void remove(int offset, int length) throws BadLocationException
              super.remove(offset, length);
              int startOfLine = rootElement.getElement(rootElement.getElementIndex(offset)).getStartOffset();
              int endOfLine = rootElement.getElement(rootElement.getElementIndex(offset+length)).getEndOffset() -1;
              //highlight the changed line
              highlightKeyword(this.getText(0,this.getLength()), startOfLine, endOfLine);
         public void highlightKeyword(String content,int startOffset, int endOffset)
              char character;
              int tokenEnd;
              while (startOffset < endOffset)
                   tokenEnd = startOffset;
                   //find next wordSeparator
                   while(tokenEnd < endOffset)
                   character = content.charAt(tokenEnd);
                        if(wordSeparators.indexOf(character) > -1)
                             break;
                        else
                             tokenEnd++;                    
                   //check for keyword
         String token = content.substring(startOffset,tokenEnd).trim();
                        if(keywords.contains(token))
                   this.setCharacterAttributes(startOffset, token.length(), keyword, true);
         startOffset = tokenEnd+1;
         public static void main(String[] args)
              JFrame f = new JFrame();
              JTextPane pane = new JTextPane(new SyntaxTest());
              JScrollPane scrollPane = new JScrollPane(pane);
              f.setContentPane(scrollPane);
              f.setSize(600,400);
              f.setVisible(true);

    I don't think the root element is the problem. Syntax highlighting is just plain slow for a large file. Here is an example, you can use for comparison purposes, that does [url http://www.discoverteenergy.com/files/SyntaxDocument.java]syntax highlighting. It is very slow when loading large files into the text pane, but works reasonably when modifying the contents of the text pane.

  • Automating adding text to a word document

    Tried before to make this automated before, but the line breaks weren't added, and the name of the word document was added after the pledge. For my school's announcement system.

    Tried before to make this automated before, but the line breaks weren't added, and the name of the word document was added after the pledge. For my school's announcement system.

  • Adding Text Type into Sales Document

    Hi,
    Is there a way to add Type (Text, Subtotal) using DI-API in marketing document (Delivery, Invoice)?
    Thanks

    Hi,
    I´m sorry to say that this is not currently possible with SAP Business One 2005A (not even SP1). It is supposed to be avaiable on the SAP Business One 2006A release.
    Regards,
    Ibai Peñ

  • Documents edited with added text and sketch not shown while emailing in iPad 2.

    Documents edited with added text and sketch not shown while emailing in iPad 2.

    Hi Rakmana,
    This is most likely an issue with Apple's iOS Mail program's.
    I think you are opening your modified PDF in Apple built-in PDF Preview. Apple's code does not properly draw the comments, but if you look at the PDF in virtually any other PDF application that isn't just using Apple''s code, or on any desktop computer, you will see the comments you've added.
    Thanks
    -Satyadev

  • Will you help me retrieve my rtf document in text edit?

    Will you help me retrieve my rtf document in text edit?

    What happened to your RTF document, and what backups do you have? If the answer to the first question is "I deleted it," and the answer to the second question is "none," then no one can help you.

  • How to insert a word document or an RTF document into RichTextEditor?

    How to insert a word document or an RTF document into af:richTextEditor. I am using Apache POI for reading the Word document and getting its contents. I am able to display the whole content of the document except the table and image within the document. The data in the table is getting displayed as a string and not as a table inside the editor.
    Can we insert a word/RTF document into a rich text editor?
    Can we insert images into the rich text editor?
    The following is the code that I used. On clicking a button the word document has to be inserted into the <af:richTextEditor>.
    <af:richTextEditor id="rte1" autoSubmit="true"
    immediate="true"
    columns="110" rows="20">
    <af:dropTarget dropListener="#{SendEmail.richTextEditorDrop}">
    <af:dataFlavor flavorClass="java.lang.String"/>
    </af:dropTarget>
    </af:richTextEditor>
    <af:commandButton text="Insert at position" id="cb2">
    <af:richTextEditorInsertBehavior for="rte1" value="#{RichTextEditorUtil.docFile}"/>
    </af:commandButton>
    Java Code: I am using Apache POI for reading the word document.
    import org.apache.poi.hwpf.HWPFDocument;
    import org.apache.poi.hwpf.extractor.WordExtractor;
    public String getDocFile() {
    File docFile = null;
    WordExtractor docExtractor = null ;
    WordExtractor exprExtractor = null ;
    try {
    docFile = new File("C:/temp/test.doc");
    //A FileInputStream obtains input bytes from a file.
    FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
    //A HWPFDocument used to read document file from FileInputStream
    HWPFDocument doc=new HWPFDocument(fis);
    docExtractor = new WordExtractor(doc);
    catch(Exception exep)
    System.out.println(exep.getMessage());
    //This Array stores each line from the document file.
    String [] docArray = docExtractor.getParagraphText();
    String fileContent = "";
    for(int i=0;i<docArray.length;i++)
    if(docArray[i] != null)
    System.out.println("Line "+ i +" : " + docArray);
    fileContent += docArray[i] + "\n";
    System.out.println(fileContent);
    return fileContent;

    Hi,
    images are not yet supported. Its an open enhancement request for the rich text editor.
    For tables, it seems they are supported but in a basic way (just HTML 4 style) if I interpret the tag documentation correct
    http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_richTextEditor.html
    Frank

  • Item text inconsistency for multiple item text in CRM Billling document

    Hi Experts,
    I am facing problem in adding item text in CRM Billiing document in Web UI.There are 3 line items in my billing document and their item text gets determined from Billing due list items but there is a requirement to change the item text at billling documnet level also to populate it in the invoice.Here comes the problem when I change item text of first item system alllows me to change in text type Sales Text but when I am doing the same with suceeeding items it throws me a exception like this.
    Business Server Page (BSP) error
    What happened?
    Calling the BSP page was terminated due to an error.
    SAP Note
    The following error text was processed in the system:
    Entry parameter ES_KEY of method CL_CRM_GENIL_CONTAINER_OBJECT->GET_KEY contains value , which is not allowed
    Exception Class CX_SY_IMPORT_MISMATCH_ERROR
    Error Name CONNE_IMPORT_WRONG_OBJECT_TYPE
    Program CL_CRM_GENIL_CONT_SIMPLE_OBJ==CP
    Include CL_CRM_GENIL_CONT_SIMPLE_OBJ==CM007
    ABAP Class CL_CRM_GENIL_CONT_SIMPLE_OBJ
    Method IF_GENIL_CONT_SIMPLE_OBJECT~GET_KEY
    Line 18 
    Long text During IMPORT it was ascertained that the object in the dataset has a different object type to the target object, or the structure of the complex object is not compatible with the structure of the target object. The target object has either a different length, a different number of decimal places or a different data type to the object that is to be imported.
    Error type: Exception
    Your SAP Business Server Pages Team
    This change in item text only works for first item and gives exception for all below items,Is this a standard SAP functionality or what can be done as same thing can be done from back end.

    Hi,
    The above given thread is the perfect solution for your requirement.
    Defaulting some data in the text field means, either you can use the the Substitution / BTE.
    Using the substitution, system not allows you to change the text field in case of any modification you want. But with the BTE you can specify only at the time of the document posting.
    BTE is the best option in this case.
    VVR

  • How do l delete all the text in my InDesign document in one go?

    Hi
               I managed to get the solution to my formatting problems for my book in InDesign CS6. I'm scared that with all the messing about something may have gone wrong. Is there a quick way to just delete the text - ie leave headers, footers and page numbering in place as well as the settings for automatically adding page numbers. I tried to sort this last night but the only solution I found seemed to want to take the whole page out and I don't want to go through all the setting up of headers, footers, page numbering and of course all the associated place holders. Anyone got a solution?
    John

    Hi Peter
                         I'm not sure I completely understand. The file is simply a 200 page+ Word document that was autoplaced in InDesign. You've been really helpful to me with this In Design document - thankyou. What I'm getting at is that because I increased the gutter size to comply with printing specifications after I placed the Word document for the first time - some text that was on page 100 and was the start of a chapter - and therefore had no header, now appears on page 110 in the new file which in the original placing of the text had got a header and footer on. All I want to do is delete the story text - ie the Word document that was autoplaced.
    Cheers Peter

  • Acrobat crashes whenever adding text

    This occurs whether there is a text box to be filled in or using the add text function. There may be other things also crashing it but this is the biggest issue for me on my Mac host system. If I open the same documents in a Windows VM using Reader, I can enter text without difficulty.
    Mac 10.8.4
    Acrobat XI Version 11.0.03
    Here's some of the error message displayed:
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Application Specific Information:
    abort() called
    terminate called throwing an exception
    Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    0   libsystem_kernel.dylib                  0x929d3a6a __pthread_kill + 10
    1   libsystem_c.dylib                       0x96905b2f pthread_kill + 101
    2   libsystem_c.dylib                       0x9693c4ec abort + 168
    3   libc++abi.dylib                         0x94e1a7e0 abort_message + 151
    4   libc++abi.dylib                         0x94e18249 default_terminate() + 34
    5   libc++abi.dylib                         0x94e18289 safe_handler_caller(void (*)()) + 13
    6   libc++abi.dylib                         0x94e182f1 std::terminate() + 23
    7   libc++abi.dylib                         0x94e193e6 __cxa_throw + 110
    8   com.adobe.linguistic.LinguisticManager          0x14054a46 0x1404e000 + 27206
    9   com.adobe.linguistic.LinguisticManager          0x1405dabb devtech::LM_FileSpec::LM_FileSpec(FSRef const&) + 43
    10  com.adobe.AcrobatPlugin.Spelling          0x1340b733 0x133d0000 + 243507
    11  com.adobe.AcrobatPlugin.Spelling          0x1340b05e 0x133d0000 + 241758
    12  com.adobe.AcrobatPlugin.Spelling          0x1340affb 0x133d0000 + 241659
    13  com.adobe.AcrobatPlugin.Spelling          0x13400acb 0x133d0000 + 199371
    14  com.adobe.Acrobat.framework             0x00286b29 0xda000 + 1755945
    15  com.adobe.Acrobat.framework             0x0028666a 0xda000 + 1754730
    16  com.apple.CoreFoundation                0x9743c406 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    17  com.apple.CoreFoundation                0x9743bda5 __CFRunLoopDoTimer + 709
    18  com.apple.CoreFoundation                0x97420bb2 __CFRunLoopRun + 1842
    19  com.apple.CoreFoundation                0x9742001a CFRunLoopRunSpecific + 378
    20  com.apple.CoreFoundation                0x9741fe8b CFRunLoopRunInMode + 123
    21  com.apple.HIToolbox                     0x9017ff5a RunCurrentEventLoopInMode + 242
    22  com.apple.HIToolbox                     0x9017fbf5 ReceiveNextEventCommon + 162
    23  com.apple.HIToolbox                     0x9017fb44 BlockUntilNextEventMatchingListInMode + 88
    24  com.apple.AppKit                        0x9070f93a _DPSNextEvent + 724
    25  com.apple.AppKit                        0x9070f16c -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 119
    26  com.apple.AppKit                        0x907055cc -[NSApplication run] + 855
    27  com.adobe.Acrobat.framework             0x000e38b0 0xda000 + 39088
    28  com.adobe.Acrobat.framework             0x000e1ff3 RunAcrobat + 307
    29  com.adobe.Acrobat.Pro                   0x000d3ed5 main + 91
    30  com.adobe.Acrobat.Pro                   0x000d3e71 start + 53

    I'm having a similar issue. Every third or fourth time I save after adding text Acrobat crashes with no meaningful reason (at least none in the crash message)...even though the added text is saved. I'm working through trying different text settings to see if there is a problem there. I'll post what I find.

  • Unable to print added text only in Acrobat Pro XI

    User is trying to print added text that's been added to an existing PDF page.  In Acrobat X she chose "Form fields only" under Comments & Forms from the Print menu.  In XI it produces a blank page.  The added text only shows up if she chooses Document or Document and Markups, but then she gets the entire document.  She only wants the added text to print.

    Thanks to all who commented here.  I found that adding text using Tools>Content Editing>Add Text will not allow the user to print solely the added text.  As everyone responded here, that's as designed.  However, using Comment>Annotations>Add Text does allow the user to print solely the added text as she was used to doing in Acrobat X.  I thought it was the same tool under two different headings, but obviously they interact differently in the print menu.  Choosing Form fields only from the Print Menu's Comments & Forms panel will produce solely the text added under the Comment panel's Add Text tool without printing the rest of the document page.  And the user doesn't have to turn the document into a form to do so.

  • Insert Text in a PDF Document

    I am trying to edit text (insert text) in a pdf document using Adobe 9 Pro.  When I click on Advanced Editing, touch up text tool.  I select a box around the text and begin to type, nothing appears the cursor moves but nothing is typed.  I need immediate help .

    Editing text and Adding text require different tools.
    The Touch up text tool would be used to modify; add, modify or delete within a line of existing text.
    To add text to an open area, the Typewriter tool would be necessary.
    Don't expect full editing abilities.

  • Added text & signatures do not print correctly

    I am using Acrobat Reader v10.4.4 on my iPad Mini with IOS 6.1.2 and am having issues printing. I can open any PDF and have it displayed correctly. I can add text and signatures and the document is saved correctly because it can be opened after the changes are made and they are still there. When I try to print the document where I have added text and signatures to, the document does not print correctly. All of the text and the signature are shrunk to a very small size and appear in the lower left hand of the page.
    I depend on my apps to work they way they should and having this issue makes my work very hard. I have to be very creative and perform unnecessary steps to get my PDF's to print the way they should. Does anyone have some insight in to this bug?

    Hi,
    Thanks for reporting this issue. We would like to investigate this issue at our end and if you could share one such pdf file in which you are facing the issue at [email protected], that would greatly help us.
    Thanks,
    Ankit

  • Coloring a Font with a RGB etc. without adding the color to the document swatches.

    Is there a way of coloring a font with a RGB, Lab or CMYK color without adding the color to the document swatches.
    The only way I know is to add a color to the swatches or use one that already exists.
    like
       app.selection[0].characters[0].fillColor=document.colors.add({colorValue: [255, 53, 160], space: ColorSpace.RGB});}
    This has the undesired effect of cluttering up the swatches when using a lot of colors.
    any ideas?

    Good Morning Uwe!
    After 3am by me 2am by you
    I had tried the link and it did download but I have cs5 cs6 and cc but not cs5.5 and all the scripts worked on them may because of the file conversion.
    So it looks like the following summary is all correct
    All documents new contain
    Swatches (Black, Registration, Paper and None) the index order will be the order that the swatches appear in the swatches panel
    And colors in an alphabetical index order
    named color "A" first "Z" last and then the unnamed colors.
    A such all new documents colors[-1] will be an unnamed color which we can duplicated to produce other unnamed colors taking note that the duplication must be process and not spot colors.
    So far so good, (not for long )
    Unnamed colors are not read only so if we make a positive effort to remove them we can do that.
    while (app.activeDocument.colors[-1].name == "") app.activeDocument.colors[-1].remove()
    We now won't have any unnamed swatches to duplicate and will have to resort to John's tagged text file method in 3 above.
    If there were no unnamed swatches and we try to duplicate colors[-1] and it was a color like "Yellow" then it seem's to crash indesign.
    Anyway the below method should always work (for regular non tint etc. type colors).
    // optimized for easy of use but not efficiency !!!
    var doc = app.documents.add();
    var p = doc.pages[0];
    p.textFrames.add({contents: "RGB", geometricBounds: ["0mm", "0mm", "30mm", "30mm"], fillColor: addUnnamedColor([0, 0,255])}); // will be a RGB
    p.textFrames.add({contents: "RGB", geometricBounds: ["0mm", "30mm", "30mm", "60mm"], fillColor: addUnnamedColor([0, 255,0], 1666336578)}); // will be a RGB because of value
    p.textFrames.add({contents: "RGB", geometricBounds: ["0mm", "60mm", "30mm", "90mm"], fillColor: addUnnamedColor([65, 50, 102], ColorSpace.RGB)}); // will be a RGB
    p.textFrames.add({contents: "RGB", geometricBounds: ["0mm", "90mm", "30mm", "120mm"], fillColor: addUnnamedColor([84, 90,40],"r")}); // will be a RGB
    p.textFrames.add({contents: "RGB", geometricBounds: ["0mm", "120mm", "30mm", "150mm"], fillColor: addUnnamedColor([232, 0, 128],1)}); // will be a RGB
    p.textFrames.add({contents: "Lab", geometricBounds: ["30mm", "0mm", "60mm", "30mm"], fillColor: addUnnamedColor([29.5, 67.5, -112])}); // will be a Lab because of -
    p.textFrames.add({contents: "Lab", geometricBounds: ["30mm", "30mm", "60mm", "60mm"], fillColor: addUnnamedColor([100, -128, 127], 1665941826)}); // will be a Lab because of value
    p.textFrames.add({contents: "Lab", geometricBounds: ["30mm", "60mm", "60mm", "90mm"], fillColor: addUnnamedColor([24.5, 16, -29], ColorSpace.LAB)}); // will be a Lab
    p.textFrames.add({contents: "Lab", geometricBounds: ["30mm", "90mm", "60mm", "120mm"], fillColor: addUnnamedColor([36.8, -9, 27],"l")}); // will be a Lab
    p.textFrames.add({contents: "Lab", geometricBounds: ["30mm", "120mm", "60mm", "150mm"], fillColor: addUnnamedColor([51, 78, 0], -1)}); // will be a Lab because of the 1
    p.textFrames.add({contents: "CMYK", geometricBounds: ["60mm", "0mm", "90mm", "30mm"], fillColor: addUnnamedColor([82, 72, 0, 0])}); // will be a CMYK because there are 4 color values
    p.textFrames.add({contents: "CMYK", geometricBounds: ["60mm", "30mm", "90mm", "60mm"], fillColor: addUnnamedColor([60, 0, 100, 0], 1129142603)}); // will be a CMYK because of value
    p.textFrames.add({contents: "CMYK", geometricBounds: ["60mm", "60mm", "90mm", "90mm"], fillColor: addUnnamedColor([84, 90,40, 0], ColorSpace.CMYK)}); // will be a CMYK
    p.textFrames.add({contents: "CMYK", geometricBounds: ["60mm", "90mm", "90mm", "120mm"], fillColor: addUnnamedColor([67, 53, 97.6, 21.7], "c")}); // will be a CMYK
    p.textFrames.add({contents: "CMYK", geometricBounds: ["60mm", "120mm", "90mm", "150mm"], fillColor: addUnnamedColor([0, 100, 0, 0], 0)}); // will be a CMYK
    function addUnnamedColor (cValue, space, docToAddColor) {
        docToAddColor = app.documents.length && (docToAddColor || (app.properties.activeDocument && app.activeDocument) || app.documents[0]);
        if (!docToAddColor) return;
        var lastColor = docToAddColor.colors[-1];
        if (!cValue) cValue = [0,0,0,0];
        if (space == 1129142603 || cValue && cValue.length == 4) space = ColorSpace.CMYK;
        else if ((space && space < 0) ||  space && space == 1665941826 || (space && /L|-/i.test(space.toString())) || (cValue && /-/.test(cValue ))) space = ColorSpace.LAB;
        else if ((space && space > 0) || space && space == 1666336578 || (space && /R/i.test(space.toString())) || (cValue && cValue.length == 3)) space = ColorSpace.RGB;
        else space = ColorSpace.CMYK;
        app.doScript (
            var newUnnamedColor = (lastColor.name == "") ? lastColor.duplicate() : taggedColor();
            newUnnamedColor.properties = {space: space, colorValue: cValue};
            ScriptLanguage.javascript,
            undefined,
            UndoModes.FAST_ENTIRE_SCRIPT
         function taggedColor() { // need to use this if no unnamed exists
                 var tagString = "<ASCII-" + ($.os[0] == "M" ? "MAC>\r " : "WIN>\r ") + "<cColor:COLOR\:CMYK\:Process\:0.1\,0.95\,0.3\,0.0><cColor:>"; // would make more sense to apply the correct value in the tagged text file but I can't be bothered !
                 var tempFile = new File (Folder (Folder.temp) + "/ " + (new Date).getTime() + ".txt");
                 tempFile.open('w');
                 tempFile.write(tagString);
                 tempFile.close();
                 var tempFrame = docToAddColor.pages[-1].textFrames.add();
                 $.sleep(250);
                 tempFrame.place(tempFile);
                 tempFrame.remove();
                 tempFile.remove();
             return docToAddColor.colors[-1];
        return newUnnamedColor;
    Shall apply the function to delete and replace swatch on the other thread at a more sane time
    Regards
    Trevor

  • Suppression of header leads to difference in behaviour in PDF and RTF documents

    Post Author: mani
    CA Forum: General
    I have a report with a header which i suppress based on some conditions.
    When the header is suppressed , the rtf documents generated have the rest of the contents moving up to occupy the empty space created due to suppression of header.
    But if we generate pdf documents the header space is retained (as empty) and the rest of the content remain in their same positions irrespective of header is suppressed or not.
    I want the behaviour to be uniform in both kinds of documents , has any one faced this or have a solution in mind?
    Thank you for looking into this issue.
    Cheers,
    Mani

    Post Author: V361
    CA Forum: General
    Instead of supressing the header, you could just change the font to match the background, base this formula on the same conditions that used to supress the header. This should leave the header the same size, but you will not "see" the text.

Maybe you are looking for

  • Conditional action does not work on iPad

    Dear all, Today I have experienced an issue regarding the HTML5 output of a project. In my project, I have three questions slides (without reporting), used for self-evaluation only, and six quiz slides. If the quiz is not passed, users can retake the

  • Bpm Workspace Message Error

    Hi, I'm editing the bpm workspace page and I clicked the add/remove columns change some things and then clicked saved and the next message appear se ha producido un error al acceder a la vista 'unified_inbox' in english: an error was produced trying

  • CSS Keepalive Problem

    Currently, I have two web server(A and B) with java engine running on top of the web server. It will give a error message "Internal error" if the java engine is mul-function. As such, CSS will detect that the Java engine of the web server(etc A) is d

  • AME Export from HDV source: Pixel aspect ratio squeezed in Queue; ok in direct export.

    I have some existing HDV footage that was converted to Cineform codec (CFHD) in an .avi file that I need to export.  My target requires Windows media format (.wmv Window Media video 9). My output settings are the following: 640x480, square pixels, 29

  • InDesign CS5 Slow Screen Redraw

    I've upgraded from the CS4 Suite to CS5. InDesign is almost impossible to use, the screen redraw is painfully slow. Much slower than CS4, which was instantaneous. Anyone at Adobe want to clue us in to what's going on? And yes, Live Update is off. Thi