How to place a word document in a TextFrame with InDesign CS2 scripting (JavaScript)?

I´m newbie with InDesign CS2 Scripting (JavaScript). I need some help to understand the way to place a Word document in an indesign template, using JavaScript(.jsx).
Thank you for the help,
Peter

//PlaceTextFileInFrame.jsx
//An InDesign CS3 JavaScript
//Places a text file in a text frame.
var myDocument = app.documents.add();
//Set the measurement units to points.
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
//Create a text frame.
var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myDocument, myDocument.pages.item(0))});
//Place a text file in the text frame.
//Parameters for TextFrame.place():
//File as File object,
//[ShowingOptions as Boolean = False]
//You'll have to fill in your own file path.
myTextFrame.place(File("/c/test.txt"));
function myGetBounds(myDocument, myPage){
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myPageHeight = myDocument.documentPreferences.pageHeight
if(myPage.side == PageSideOptions.leftHand){
var myX2 = myPage.marginPreferences.left;
var myX1 = myPage.marginPreferences.right;
else{
var myX1 = myPage.marginPreferences.left;
var myX2 = myPage.marginPreferences.right;
var myY1 = myPage.marginPreferences.top;
var myX2 = myPageWidth - myX2;
var myY2 = myPageHeight - myPage.marginPreferences.bottom;
return [myY1, myX1, myY2, myX2];

Similar Messages

  • How to place a word document that autoflows text boxes onto every other page?

    Is there a way to place a word document into InDesign that autoflows text boxes onto every other page?
    Example
    page 1 from word doc imports to page 1 in indesign,
    page 2 from word doc imports to page 3 in indesign,
    page 3 from word doc imports to page 5 in indesign, etc.
    Than, take a different word doc and import to the even pages of the same indesign document,
    Example
    page 1 from word doc#2 imports to page 2 in indesign,
    page 2 from word doc#2 imports to page 4 in indesign,
    page 3 from word doc#2 imports to page 6 in indesign, etc.
    Thanks

    I don't import Word docs... but I don't think there is a simple 1-click solution.
    You probably need to set up a facing pages document with a master text frame on each.
    Create the pages you need and link the left text frames to each other and the right to each other.
    Importing should work from there however not sure how the page-break works (if you have that set-up in Word).

  • How to restrict Firefox to open word document in browser window with href

    How to restrict firefox to open word document from a website link to open in the browser window, instead it should open in native program.
    1.I have tried other website, and have clicked on similar links they are opening word document correctly in native program
    2. MS word document from one specific site is opening in browser causing junk character in place of word document.
    Could you please help on this.

    Thanks for your response...
    But As i said, I have tried with other website on the same browser, there it is opening word document in native program. Also the above mentioned options have been tried earlier.
    I have some questions related to this?
    How is this href link is behaving differently opening in browser for mozilla only. Technically, Can we make it open it native program only? If so, then how?

  • 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

  • How to Append two  word documents into single  using   java

    How to Append two word documents into single using java
    we tried this but it's not append the one word document to other
    source code:public class AppendTwoWordFiles {
         public static void main(String []arg)throws IOException
              FileInputStream fi=null;
              FileOutputStream fo=null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                   File f1=new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2=new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2,true);
                   byte b[]=new byte[2];
                   while((fi.read(b))!=-1);
              fo.write(b);
    System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
              fi.close();
              fo.close();
    plz reply me quickly ,,,what can i follow

    Use this code ..
    and give the path of the both file like this.....
    source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
    destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
    import java.io.*;
    public class AppendTwoWordFiles {
         public static void main(String[] arg) throws IOException {
              FileInputStream fi = null;
              FileOutputStream fo = null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br = new BufferedReader(new InputStreamReader(
                             System.in));
                   File f1 = new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2 = new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2, true);
                   byte b[] = new byte[2];
                   int len = 0;
                   while ((len = fi.read(b)) > 0) {
                        fo.write(b, 0, len);
                   System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   fi.close();
                   fo.close();
    }

  • HT1284 How can I backup word documents and not have them crowd my screen? Thanks.

    Hi. How can I backup word documents and not have them crowd my screen? I know, you guessed it. I'm a novice, but not ashamed!

    Please explain what you mean when you say backup Word documents crowds your screen.
    I don't see any connection between backup and your screen.
    Allan

  • I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    I want to know how to turn a word document into a jpeg so I can put the document on Facebook as a picture. I have made posters and if I do a print screen they are unable to be read, or if i turn it into a PDF there is no save as jpeg??

    iOS device backups are stored in your iTunes library.
    Move your iTunes library to an external drive.

  • How to convert a Word Document to SAP SCript standard text.

    Hi team,
    Does any one know how to convert a word document or text in Word format to standard text.
    So that we can use that standard text in Script output.
    This might be very useful if we need to convert a lot of text into standard text.

    Hi,
    Create the name of the standard text you want in SO10.
    When the editor is called up, select Text -> Upload and then browse for your file(s). Must be saved in RTF format in Word remember.
    Cheers
    Colin.

  • How do I transfer powerpoint and word documents to my ipad with the new itunes?

    how do I transfer powerpoint and word documents to my ipad with the new itunes?

    Have a look at the following:
    http://itunes.apple.com/sg/app/quickoffice-pro-hd-edit-office/id376212724?mt=8&l s=1
    http://itunes.apple.com/sg/app/office2-hd/id364361728?mt=8&ls=1
    http://itunes.apple.com/sg/app/documents-to-go-premium-office/id317107309?mt=8&l s=1
    http://itunes.apple.com/sg/app/polaris-office/id513188658?mt=8&ls=1

  • How can I make word document window bigger. Have tried dragging bottom corner out & clicking on '+' sign but this does nothing?

    How can I make word document window bigger. Have tried dragging bottom corner out & clicking on '+' sign but this does nothing?

    Word - Microsoft Support

  • How to convert a word document into the PDF format?

    Please instruct me step by step on how to convert several Word documents into the PDF format?

    If properly installed and updated (depending on the WORD version), you can simply do any of the following:
    1. Open the doc in WORD and select Print, choose the Adobe PDF printer, print.
    2. Open the doc in WORD and go to the Acrobat menu in WORD and select create PDF (this uses PDF Maker).
    3. Open the doc in Acrobat and the conversion should be done based on PDF Maker.

  • How to embed the Word Document and PDF file into Crystal report?

    How to embed the Word Document and PDF file into Crystal report?
    I have word doc which having 10 pages. I need to show all of the 10 pages at a time. I tried OLE object but problem is it shows only one page.
    Is there any solution to show word doc / PDF file in CR?

    Symptom :
    When embedding a pdf document into a Crystal Report, only the one page shows.
    Reproducing the Issue
    Environment:
    Crystal Reports OLE object
    Cause
    An OLE object only displays the first page.
    Resolution
    Embed multiple objects, one for each page
    Or
    Use a hyperlink to the object instead
    Hope this helps!
    Regards,
    Vinay

  • How do I store word documents on my iPad or iPhone 5?

    how do I store word documents on my iPad or iPhone 5?

    Have a look at the following:
    http://itunes.apple.com/sg/app/quickoffice-pro-hd-edit-office/id376212724?mt=8&l s=1
    http://itunes.apple.com/sg/app/office2-hd/id364361728?mt=8&ls=1
    http://itunes.apple.com/sg/app/documents-to-go-premium-office/id317107309?mt=8&l s=1
    http://itunes.apple.com/sg/app/polaris-office/id513188658?mt=8&ls=1

  • How do I find word documents on iCloud?

    I have logged on to icloud but when I click on iWork, the only tabs are for keynote, numbers and pages. There is no tab for word documents but then how do I access word documents on iCloud?

    I have no idea as I am not ever going to use a Cloud system for storing my personal files. I have computers for that. Your best bet would be to use Google and type in "Uploading files to Apple's iCloud system". I bet you will get all the info you could ever ask for.
    Good Luck and Best Wishes
    mgmf wrote:
    Oh ok, that might be it. But how do I upload things from the documents folder onto iCloud?

  • How can I open word documents in my mac?

    I am trying to open some attachments sent to me which were written in microsoft word for windows 2007 in my mac word 2011 and it opens up a bunch of gibberish. Can someone tell me what I can do to open it correctly?

    I have been able to open all Word documents sent to me with Pages.
    Allan

Maybe you are looking for