Using integers/characters as bookmarks in rtf document

first of all, i am self taught (ie i know practically nothing)
i am trying to write an application which includes a database and produces standard letters with individual clients' details inserted. it is driving me insane.
i am using rtf files and the code below (part of which i stole off the internet) copies everything just fine
the code below works ok for a limited number of 'fields' - the integers in the 'switch' apply to characters such as # $ [ and they seem to be the integers the code uses.......(the code inserts my fields as it should)
and this is where my ignorance kicks in big-time - i have tried everything, putting the character itself into the switch instead of the integer, using Unicode symbols - to expand the range so i can use more 'fields' - but i have to confess i am really out of my depth, i don't really understand Unicode........
for example, i have tried using 'à' as an example, but no matter whether i use the integer (the default one recovered from the rtf document by this code), the character itself, or the Unicode value........the code just ignores it, does not insert the field i require, instead just re-types the à in the copy document.
tall order, but is there any simple way for me to have a much wider range of 'bookmarks' so i can insert fields?
void doLetter(String lettCode, Client client, Defendant defendant)
FileReader in = null;
out = null;
currClient = client;
currDefendant = defendant;
lett = lettCode;
try
File inputFile = new File("C:\\testBill\\" + lett + ".rtf");
in = new FileReader(inputFile);
out = new FileWriter(createPath(lett));
int c;
while ((c = in.read()) != -1)
System.out.print(" " + c);
if (insertField(c)) continue;
out.write(c);
catch (Exception io)
System.out.println(io.getMessage());
finally
try
in.close();
out.close();
catch (Exception ex)
System.out.println(ex.getMessage());
private boolean insertField(int d) throws Exception
int a = d;
switch(a)
case 35: doField(currClient.getTitle());
return true;
case 36: doField(currClient.getFirstName());
return true;
case 91: doField(currClient.getLastName());
return true;
case 93: doField(currClient.getFirstAddress());
return true;
case 126: doField(currClient.getSecondAddress());
return true;
case 95: doField(currClient.getThirdAddress());
return true;
case 94: doField(currClient.getFourthAddress());
return true;
case 124: doField(currClient.getPostCode());
return true;
case 33: doField(currDefendant.getPPI());
return true;
case 64: doField(currDefendant.getLastName());
//System.out.println(currDefendant.getLastName());
return true;
return false;
private void doField(String champ) throws Exception
String whatever = champ;
char cbuf[] = whatever.toCharArray();
out.write(cbuf);
}

hi mel
first of all thanks for taking the trouble to answer my query. i am rather embarrassed on two counts - first for the mistake in my code (i did admit to ignorance after all) and secondly that i seem to have found an answer to my problem - after about 3 months of tearing out what hair i have, perhaps posting here galvanised me, i don't know.
re your solution, yes i could switch happily between the characters themselves, the integers the rtf document seemed to be using (cp1252 or something like that?) and unicode symbols, but the problem was the code was only recognising certain symbols, such as $ and [, but it steadfastly refused to recognise (and therefore act upon) the accented a character (and every other character which was not a letter or a number), which effectively left me with about 12 fields to play with in my standard letters.
anyway, this seems to be working!:
int c;
while ((c = in.read()) != -1)
System.out.print(" " + c);
if (c == '%')
char cbuf[] = new char[3];//in my rtf document i am using %001, %002 etc
cbuf[0] = (char)in.read();
cbuf[1] = (char)in.read();
cbuf[2] = (char)in.read();
if (insertField(Integer.parseInt(new String(cbuf)))) continue;
out.write(c);
catch (Exception io)
System.out.println(io.getMessage());
finally
try
in.close();
out.close();
catch (Exception ex)
System.out.println(ex.getMessage());
private boolean insertField(int d) throws Exception
int a = d;
switch(a)
case 1: doField(currClient.getTitle());//35 - these are integers i was using previously
return true;
case 2: doField(currClient.getFirstName());//36
return true;
case 3: doField(currClient.getLastName());//91
return true;
case 4: doField(currClient.getFirstAddress());//93
return true;
etc
i just have to make sure i have no %s in my standard letters, otherwise i should use some other symbol. i will now worry until i am sure you are not going to point out why this will not work long term, but it seems to have worked so far and has helped expand my armoury of fields..........
thanks once again for your help
ant

Similar Messages

  • How to construct checkbox in rtf document using iText?

    Hi fiends
    I am developing a rtf document usng iText api ,I am facing problem when i want to draw a check box in the document so is there any way using iText only to draw a checkbox in rtf document?Or iText doesn't allow construct checkbox?please suggest.An example will be appreciated.Thanks in advance.
    Regards soumyanil

    For your kind information this is a site that provides support for JAVA programming and JAVA Servlets related questions.
    You need some information regarding a third party API, so please dont hesitate to contact your vendor.
    The vendor URL: http://itextdocs.lowagie.com/
    The tutorial you need to learn before starting iText is http://itextdocs.lowagie.com/tutorial/
    All the best!

  • How do I use a font variation in a pages document. I no longer have the "viewer" -glyph option in special characters pane only new mbPro with Lion. I know the variation is available because I can see it in the font book. so now what I just want to be

    How do I use a font variation in a pages document? or other app for that matter? I no longer have the "viewer" - glyph option in the special characters pane (under edit  in toolbar). I know the varaition ia available because I can see it in my font book. I depended on that alot so I need to find a way to still use character and embellishments. I don't want to have to go back to my od computer (from2007) Please Help!

    I really don't understand.
    The menu item is available :
    Maybe, you didn't activate the tool :
    Yvan KOENIG (VALLAURIS, France) mardi 2 août 2011 23:10:17
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Directly Printing RTF document using java

    Hi,
    can we directly print RTF document using java, without giving any preview or any other screen in between.
    Actually we created inventory system, in which when user create any sale information, it should print the bill for the same with single button click.
    Any sample code or help will be highly appreciated
    Thanks in advance

    Hi,
    can we directly print RTF document using java, without giving any preview or any other screen in between.
    Actually we created inventory system, in which when user create any sale information, it should print the bill for the same with single button click.
    Any sample code or help will be highly appreciated
    Thanks in advance

  • Can I create bookmarks on PDF document using stadard acrobat writer? or only using professional acrobat writer?

    can I create bookmarks on PDF document using stadard acrobat writer? or only using professional acrobat writer?

    Hi hagitl14083762,
    Bookmarking in available in both Acrobat Pro and Standard. You'll find instructions here: Adobe Acrobat X Standard * Create a bookmark (while written for Acrobat X, these instructions apply to Acrobat XI as well).
    Please let us know if you have additional questions.
    Best,
    Sara

  • How to insert hyperlinks in RTF document shown in JEditorPane?

    This is a compound question so bear with me on this one :)
    What I need is to insert an hyperlink in a JEditorPane; Store it as RTF code; Retrieve it; Show it and click on it to go the the destination.
    1) So, first question, is there some method to automatically add the hyperlink and will it be saved in RTF with RTFEditorKit? (I'm actually using AdvancedRTFEditorKit but an answer to either will be enough)
    2) I tried a method that adds what appears as a link but the document that is stored doesn't have the necessary RTF codes, only the formatting that makes it look like a link. I also checked the actual RTF codes I'd need to add and they seem easy to do. So, is there a way to add the actual underlying RTF codes to the document while it's in the JEditorPane?
    I know the question(s) isn't too specific, if you can shed some light over the whole thing and point me in the right direction, it'd be great!

    Just a follow up to my own question. I found a way to answer my question 2) and I'm now storing the rtf code for hyperlinks. Now, when I show the document in JEditorPane with RTFEditorKit, I get the name of the hyperlink with no formatting indicating that it's a hyperlink.
    Example. The link "http://www.google.com" with the name "Google", only shows "Google" in plain text.
    Is it because the components I'm using don't support hyperlinks from RTF files even though they're supported from HTML files?
    Is there any way you can see this working? Is it possible to include something inside the JEditorPane that the user can click, instead of the hyperlink?

  • How to set data in rtf document?

    Hi friends,
    I have a rtf document can anyone suggest how to set data in cells of an rtf document?Is there any way?
    Thanks in advance..
    Regards ,
    Soumyanil

    Convert the resultSet from the db to a Object[][], let's call it result.
    Then create a JTable (jTable1).
    On the JTable you need to define the headers, and the data itself.
    You can get the headers from ResultSetMetaData. Convert these to an array again (headers).
    Now use these methods to create a model and set the model of the JTable.
    Model model =  new DefaultTableModel(result, headers);
    jTable1.setModel(model);That's about the basics.
    If you need more info, use at the tutorial at sun's homepage.
    How to use Tables:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

  • 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

  • I am using photoshop cc 2014.2 And when I use save for Web it gives me a dialog box that says it is using Latin characters I've never seen this before. Does anyone have an answer for this problem or do I need to go back to the older version of Photoshop.

    I'm using Photoshop cc 2014.21 I you save for Web and dialog box comes up that says that Photoshop is using Latin characters and that servers cannot recognize Latin characters in webpages and you may have trouble viewing these pages does anyone have an answer for this problem?

    What Firefox version is currently installed on the computer?
    You can find the full version of the current current Firefox release (37.0.2) in all languages and all operating systems here:
    *https://www.mozilla.org/en-US/firefox/all/
    If you have a very old Firefox version then you could consider to uninstall that version to clean up existing registry keys (especial the uninstall key).
    Make sure NOT to remove "personal data" when you uninstall Firefox, because that will remove all profile folders and you lose personal data like bookmarks and passwords including data in profiles created by other Firefox versions.
    Check the Firefox program folder and remove the Firefox program folder if there are still files left in it.
    *(32 bit Windows) "C:\Program Files\Mozilla Firefox\"
    *(64 bit Windows) "C:\Program Files (x86)\Mozilla Firefox\"
    It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other personal data are stored in the Firefox profile folder and won't be affected by an uninstall and (re)install, but make sure NOT to remove personal data when you uninstall Firefox as that will remove all Firefox profile folders and you lose your personal data.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • How do you change the default setting for RTF documents from TextEdit to MS Word

    How do you change the default setting for RTF documents from TextEdit to MS Word, I download forms from the Canadian government and they use RTF as a standard, they are supposed to open as MS Word documents (Yes I have Office for MAC 2011) but when download the document it goes to TextEdit which messes up the form format. I can down load it right click and go "open with" MS Word but how can I get the default chnaged to save this step.

    richr604 wrote:
    Thanks I knew this, I like Safari as I want to keep everything MAC, but if I use Firefox the documents open in MS Word straight away, I was just curious if there was some setting I could change?
    In Firefox > Preferences, click the Applications tab. If RTF is there, use the pulldown menu in the Action column to pick MS Word. If RTF is not there, there are instructions here for how to add file types.

  • How do I restore links to bookmarks in Pages documents in OS X 10.9?

    When using Mountain Lion I created numerous links between Pages documents and to bookmarks within Pages documents. After converting to Mavericks none of those links works and I cannot find a way of restoring those links. Suggestions?

    After trying a variety of approaches, I was virtually certain that the feature had been eliminated (as you knew). I was dismayed that the Pages 4.3 bookmarks and links didn't work in Pages 5.0 since I had created hundreds of business documents using those features.
    On the advice of Alexander Wolff and the local Apple store, I've restored Pages 4.3 and retrieved the documents I had converted to Pages 5.0 from my Time Machine.
    Per your suggestion, I'm leaving feedback for the Pages team.
    Thanks for the information and advice.

  • Characters corrupted converting hpj+rtf to chm help

    Hi,
    Sorry this was originally posted in htmlhelp but there were no answers so I'm reposting here to see if anyone can help.
    I'm trying Robohelp to see if I can use it to create localised versions of our help files.
    I have the old .hlp project .hpj file and .rtf files from all of the languages that we need to create.
    - For Windows_1252 languages I can use Microsoft's HTML workshop with no problems.
    - For non Windows_1252 languages such as Russian (Windows_1251) the htm files created by the MS tool show the correct page content but the Titles and Keywords are corrupted and the href links are missing.
    Hence my attempt to try Robohelp.
    So far I've found that importing the hpj file and the desired rtf file works fine again for Windows_1252 languages. But that's not much help as I could already create those in the MS tool.
    When I try to import the hpj file with a non Windows_1252 rtf file such as Russian, I can create a chm and all of the links seem to be intact, but all of the characters including the page content characters are corrupted.
    This can be seen in the htm file displayed in Robohelp as soon as the new project import has finished. I've tried setting the language for all the .htm files to Russian, I've set the language for the project to Russian and I've picked Russian as the language in the .chm build dialog. Unfortunately I think none of these are likely to work as the characters have already been corrupted in the htm files created during the import.
    I've tried the Robohelp build on XP with the Locale set to Russian, and I've tried it on Windows 7 x64 with the Russian language pack installed, Russian selected as the display language and Russian set as the Locale.
    I notice the codepage in the Robohelp created htm's are set as UTF-8 as opposed to Windows_1251.
    I'm pretty sure this is just something I'm doing wrong as the MS HTML Workshop manages to get the correct characters out of the rtf page content.
    Any idea where I might be going wrong? Is there someway to define the language of the RTF before the import process?

    Hi there
    Drawing from distant memory here. I believe RoboHelp expects Word DOC files. It saves as .RTF if you create WinHelp files, but I believe the main file type is .DOC. I'm unaware of any way to force it to only work with RTF.
    Then again, I never ever claim to know it all about any given subject. So perhaps someone has a clue on how it might be accomplished.
    Out of curiosity, if you want CHM files and CHM files are HTML based, why the insistence on RTF as your source? Why not convert to RoboHelp HTML and work with HTML content?
    Cheers... Rick
    Begin learning RoboHelp HTML 7 within the day - $24.95!
    Click here for Adobe Certified Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • Help in merging the output rtf/documents reports

    Hi,
    I am working with XML pub tool for a user requirement that 2 output reports(rtf documents) were genated using XML processor from 2 rtf templates, XML data files etc. No I need to merge the 2 output rtf/doc reports . Is there any function in XML publisher so that I can merge these output reports as one report.(Same as merging 2 documents in microsoft word)
    Thanks
    Raj

    You can merge/append 2 documents with a third party tools wihtout using XMLP publisher.
    HTH
    Shaun S

  • Using PDF Pack to convert a .docx document containing internal hyperlinks

     
    I just used PDF Pack to convert a .docx document to pdf format. The document contained a hyperlink to a bookmark within the document. The text converted OK, and the hyperlinked text was underlined, but not active. Clicking on the hyperlinked text did nothing. It seems that internal hyperlinks don’t convert using this software.
    Thanks for any advice
    David

    Hi,
    When you export your PDF file to Word file please select .doc format option rather than docx format for MS Word.
    Thank you.
    Hisami

  • 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

  • Creating Links to Object but not using the record id field in the web add

    Hello, Im trying to create a link between OnDemand an another system but the other system is the source system so it will be creating the HTML Link based on values the user selectes. What i am trying to do is create a link link the following: https:/

  • Hotshot video conversion resolution?  No full screen ever?

    I have the Pantech Hotshot.  The screen resolution of the phone is 400wide x 240high.  When I convert a video to that resolution the phone always reduces it to 320 wide instead of filling the screen to the 400 wide and makes the 240 high even smaller

  • How well does my macbook pro support Civil Engineering programs?

    I'm starting college in a few months, and im really hoping macs can be compatible with CAD software and other needed programs. Unfortunately, I do not know the names of the programs I'll have to use. Hopefully you guys will know from experience

  • UME Configuration for 2 groups

    Hi All, We have configured our UME with one LDAP source having group path as 'ou=groups,ou=SAP ePortal,ou=Applications,ou=Intranet,dc=<companyname>,dc=com'. But if we create a new group, can we configure the XML such that it will have both the groups

  • Revision no of Routing/Inspection plan in Purchase order

    Hi MM friends, I have two requirements from client 1. Is it possible to update the revision number of Routing/inspection plan or attaching any document in Purchase order to inform the vendor the relevant changes. 2 Also the Routing changed revision n