C# / JavaScript how to set the primary text block?

Hello

I'm working with InDesign scripting API with c# for my work. I'm new to both the InDesign scripting API and using InDesign as well.

I am building a gap of master, with blocks of text so that the text block on the left page of the cheese would pass in the block of text on the right page.


I read there is the option block of primary text for the master spread, but I can't seem to understand how to use it.

Is there someone who could show me an example of script code to define the framework of primary text for a master page/spread?


Here is the code I have for now.

The question I have is in line 53, where when I try to run it, it gives me a very generic error 'Invalid object for this request.', which leads me to believe I'm doing it wrong.

        public static byte[] CreatePageBasedOnCreatedMasterSpread(string savePath)
        {
            Application application = ActivateInDesign();


            // Create new document
            application.Documents.Add(true, application.DocumentPresets.FirstItem());


            // Get active document and change some settings
            Document document = application.ActiveDocument;
            document.DocumentPreferences.FacingPages = true;
            document.DocumentPreferences.PageWidth = 210;
            document.DocumentPreferences.PageHeight = 297;


            document.DocumentPreferences.CreatePrimaryTextFrame = true;
            document.TextPreferences.SmartTextReflow = true;


            MasterSpread masterSpread = document.MasterSpreads.Add();
            masterSpread.BaseName = "CustomMasterSpread";
            masterSpread.NamePrefix = "AC";


            //Set the document's ruler origin to page origin. This is very important
            //--if you don't do this, getting objects to the correct position on the
            //page is much more difficult.
            document.ViewPreferences.RulerOrigin = idRulerOrigin.idPageOrigin;


            Page leftPage = masterSpread.Pages.FirstItem();
            Page rightPage = masterSpread.Pages.LastItem();


            leftPage.MarginPreferences.Top = rightPage.MarginPreferences.Top = 10;
            leftPage.MarginPreferences.Bottom = rightPage.MarginPreferences.Bottom = 10;
            leftPage.MarginPreferences.Left = rightPage.MarginPreferences.Left = 30;
            leftPage.MarginPreferences.Right = rightPage.MarginPreferences.Right = 20;


            // Create a text frame. Do not add text to this, as this is a master spread text frame.
            // Link their flow together
            TextFrame primaryFirstPageTextFrame = leftPage.TextFrames.Add(document.Layers.FirstItem(), idLocationOptions.idUnknown, leftPage);
            TextFrame primarySecondPageTextFrame = rightPage.TextFrames.Add(document.Layers.FirstItem(), idLocationOptions.idUnknown, rightPage);
            primaryFirstPageTextFrame.NextTextFrame = primarySecondPageTextFrame;
            //Set primary text frame of master spread to be the two linked textframes


            primaryFirstPageTextFrame.GeometricBounds = GetPageBoundsWithMargin(leftPage, document);
            primarySecondPageTextFrame.GeometricBounds = GetPageBoundsWithMargin(rightPage, document);
         
            masterSpread.PrimaryTextFrame = primaryFirstPageTextFrame; //This causes the error
         
            return GetFileData(document, savePath);
        }

I noticed the JavaScript API that is very similar to c#, so it would be useful if I get a response from JavaScript.

Hi Michael,

Basically, you can do something like this (in ExtendScript):

//Store value:
var storedPreset = app.documentPresets[0].createPrimaryTextFrame;

//Let's set it to true:
app.documentPresets[0].createPrimaryTextFrame = true;

//Add the document, name the master as you wish etc.pp. :
app.documents.add
(

    {
        documentPrefreneces :
            {
                facingPages : true
                ,
                pageWidth : "210 mm"
                ,
                pageHeight : "297 mm"

            }
    }

);
//Reset to stored value:
app.documentPresets[0].createPrimaryTextFrame = storedPreset;

Uwe

Tags: InDesign

Similar Questions

  • How to set the banner text in Vcenter?

    Hello

    I'm looking how to set the Banner text in Vcenter not in the ESX Server.

    The banner message should apper when connecting users on the VCenter server.

    Thanks in advance.

    See screenshot:

  • How to set the ToolTip text programmatically?

    Anyone know how to set the ToolTip text programmatically? forms10g, db10g.

    Thank you
    m.

    Hello

    You can use the SET_ITEM_PROPERTY to define the criterion of an element tool tip.

    SET_ITEM_PROPERTY('.', TOOLTIP_TEXT, '');
    

    Kind regards

    Manu.

    If my answer or the answer to another person has been useful or appropriate, please mark accordingly

  • How to set the RTL text in InDesign CC?

    How to set my RTL text in InDesign CC? The icon in the palette of paragraphs illustrated on the Adobe web site does not appear in my palette.

    Yes, the Adobe help is, ah, garbage. You get RTL tools if you download the ME version of InDesign CC. In order to get that, you must delete the version of InDesign that you now, open your creative cloud application, click on the gear-preferences icon in the upper right corner, go to the language settings and choose a language setting as "English (Arabic)" or "English (Hebrew). You will get an interface with all editing tools in English ME as the character orientation, orientation of the paragraphs and so forth.

  • How to set the default text for a text entry area dynamically?

    I do a simulation and grabbing a my user text entry.  I store in a variable and you want to use as the default text for a text entry later in the simulation box.  It seems like it would need current for a software simulation.  However, I don't see a way to set the default text.  If I put the variable in a legend, I would use the syntax $$variablename$ $.  I tried to fix this in the text by default, but it did not work.  It is not interpreted as a variable.  Does anyone do this?  Please share.  Thank you.

    I had a need to do that as well... put a variable as default text name in a TBE field.

    I have a widget AS3 to do this, which can be found here.  There a Cp 4 demo file that does exactly what you describe.

    I would like to know how it goes...

    Jim Leichliter

  • How to set the primary file in custom filter UCM

    Hi all

    I have a requirement where I need to change the primary file that is downloaded.

    I use validateStandard filter and above the file gets checked... I want to change the primary file for some another file...

    But the problem is that I don't get what function I can set the value for the metadata of the primary file.

    Here is my code:

    public int doFilter (workspace ws, linking DataBinder, ExecutionContext cxt) survey DataException, ServiceException
    {
    Report.trace ("IMG_COMPRESS", "Start doFilter", null);

    String xcontentType = binder.getLocal ("xContentType");
    String primaryFilePath = binder.getLocal("primaryFile:path");
    String primaryFileName = binder.getLocal ("primaryFile");

    If (xcontentType.Equals ("CTID24"))
    {
    Report.trace ("IMG_COMPRESS", "Original file path:" + primaryFilePath, null);
    Report.trace ("IMG_COMPRESS", "file name:" + primaryFileName, null);

    Try
    {
    The output if the primaryFile:path are missing
    If (primaryFilePath == null | primaryFilePath.trim () .length () < 1)
    {
    Report.trace ("IMG_COMPRESS", "Could not find the primary file path", null);
    Back to CONTINUE;
    }

    Change the original image (input image) to the compressed Image (output image file)
    primaryFilePath = "E:\\ImgCompression";
    primaryFileName = "compressed.jpg.txt";

    binder.putLocal ("primaryFile:path", primaryFilePath + "\" + primaryFileName);
    binder.addFile (primaryFilePath + "\" + primaryFileName);

    Report.trace ("IMG_COMPRESS", "new Img path:" + primaryFilePath, null);
    Report.trace ("IMG_COMPRESS", "new Image Name:" + primaryFileName, null);
    }
    catch (System.Exception e)
    {
    Report.trace ("IMG_COMPRESS", "Unable to read file", null);
    }
    }
    executed properly, filter return CONTINUE
    Report.trace ("IMG_COMPRESS", "End doFilter", null);

    Return FilterImplementor.CONTINUE;
    }

    There is no function with addFile in the DataBinder class.

    Help, please

    As I understand it, you create your own compression via a custom filter and you want to replace the original file with this compression.

    That being said, why not do exactly as that - the original file is placed in some ~ temp directory on the server (after download), so go ahead, create compression and put it instead of the original file. One thing to consider is the MIME type - if replacing it, it should be the same; If it is not that you had to adjust first some metadata.

  • How to set the alternate text for a framework anchored in FrameMaker 11?

    What is the procedure in FrameMaker 11 to include the alt for anchored frames text? We need produce a tagged PDF output is consistent accessibility; This output should include the alternate text for each image in the document that a screen reader can read.

    In previous versions of FrameMaker, it was possible to set the text as follows:

    1. Select the image and choose the graphics > properties of the object.
    2. Click on object attributes.
    3. In the text attributes section, add your text and the text and then click on set.

    FrameMaker online help describes the same procedure, to http://help.Adobe.com/en_US/FrameMaker/using/WSd817046a44e105e21e63e3d11ab7f7960b-7f0f.htm l . However, I see that in FrameMaker 11, you get the choice of graphics > properties of the object has changed from previous versions, and I can't see the object attributes.

    Where the text is defined for an object in FrameMaker 11?

    In the Panel of the anchored frame, click the button object attributes.

  • How to set the unselectable text?

    There are moments where you don't want your user to select text, such as menus and buttons. Having dynamically editable on my buttons text is vital, but for now, it's incredibly annoying because when they click on it, it will choose the text and highlight it and it drives me crazy. And I speak not only for the buttons, I want to be able to make my text non-selectable/highlightable if I need to. Can someone please tell me how?

    Try this:

    .CSS ({$("text") sym.

    ' - webkit - touch-legend ': 'none ',.

    '- webkit - user - select': 'none ',.

    '- khtml - user - select': 'none ',.

    "- moz - user-select': 'none',"

    '- SM - user-select': 'none ',.

    'user-select': 'none '.

    });

    example here: https://app.box.com/s/molnk5crspd9l2jq6dsi

  • [JS] How to set the import text option?

    File-> location-> after import check "Import Option to see the property.

    Hello.

    I want to change character set to import a txt file.

    Please any advice for me.

    Thank you.

    See screenshot

  • How to set the hyperlink text in photoshop cc?

    I have a text that I want to be a hyperlink when I click on the text. y at - it sort of do?

    image 1.PNG

    These links are for a website to a cliet.

    Even the answer to your previous post http://forums.adobe.com/thread/1295865

    Photoshop does not links hyperlink (or hotspots on images). It is an image editor. Hotspots (clickable links on images) are a feature of web pages that run in browsers.

    You create art image in Photoshop as you did.

    Then, you use a web editor such as Dreamweaver to import the image in a web page, then add hotspots in DW. Then upload to the web.

  • How to set the different texts in the odd and even pages?

    I often need to design books of bilingual poetry (CS4) (same page, french; odd, English page), but all the methods I've tried are unnecessary.

    Applied only master pages; used an image from the film in one and two master pages; the layers together, etc.

    Of course, it is possible, first of all, that flows throughout the text and remove immediately, one by one, the odd frames; Secondly, it flows towards manually text, page to page, in the odd-numbered pages. But it's a waste of time when 400 pages are up to the task

    (I consulted the powerful Real World Indesign: O. Martin and D. Blatner or InDesign Secrets blog buy my search was not clever/erased at all)

    The short version is easy. Put a facing document pages and DON 'T control block of text type. Then go to the spread of master and draw the blocks of text on both left and right of the pages, but don't screw. AUTOFLOW will only fill one side or the other and add full spreads as necessary to access the next page in this position.

  • In a primary text block text block

    Hello

    as a newbee in indesign css 6 I watched several videos, myself worked through tutorials and try different things. I would like to create a complete book with about 350 pages composed almost entirely of text. Due to the amount of text I thought to use a block of text within pages of various books.

    However, there is a specialty. After some of the topics, there is a reference with the name of the author of this quote. Citations should be justified, but chocked right (the right edge of the block justified must be to the right of the page). A separate text block would be good for this. However, within a block of primary text I can't place another block of text, right? What options should I? I have to remove the primary text block and put all the text in a string of text frames manually?

    Kind regards

    Adobaen

    You can also try withdrawal left with a justified paragraph style.

  • How to set the height of cfinput text

    How to set the height of a "text box" in ColdFusion? When I look at this in dreamweaver, the box is multiline, but when it appears in the browser, is only a single line.

    < cfinput type = "text" name = "Comments" size = "40" height = "500" width = "150" >

    Hmmm... just changed to

    and it works... didn't even worry Pass Through.

  • How to set the condition of rule to check the Primary Key, Foreign Key and Unique

    I use Oracle 10.2
    Could someone tell me please how to set the rule condition to check the primary key, foreign key constraint of uniqueness?

    Hello

    Primary key, unique constraints and foreign key are better applied using the native functionality of database constraint. If you like the rules to check if a key exists at the time of the evaluation, you can use a function defined by the user in a rule condition and this function can ask to turn the table keys.

    Hope this helps,
    -Aravind.

  • How to set the font for this SuperNova will display the text properly

    I have a problem with the use of Firefox with Supernova. Supernova is a program for the Visual disabled allowing you to enlarge the office. When you visit the page

    http://www.raadvanstate.nl/Uitspraken/zoeken-in-Uitspraken/Tekst-uitspraak.html?ID=73735 & summary_only =

    you will see orange colored text in the main text block. It appears correctly. However when I enlarge the screen with Supernova this orange text is barely readable due to the fact that the letters seems constructed points instead of a smooth line.

    Note that this happens even with this page where I enter these details of the issues. Supernove enlarged rhe screen, texts outside of the text box are horrible while the text in this text box is good.

    I ask this question here because when I use Internet explore this problem does not occur.

    I tried to make a screenshot, but the screenshot feature only "sees" the screen is enlarged. So when I zoom to 100% with Supernova, the text in the screenshot seems to agree.

    I realize that this is a difficult question to reproduce, but any help is welcome. Note that it is not a real option for me to enlarge the font with the Firefox options. Supernova expands the full screen, not only the text on the Web page. In this way, I am also able to see the menu / bookmarks of Firefox itself.

    Thank you very much
    Hans

    You can use an extension to set a page zoom and the size of the default font on the web pages.

    Try disabling hardware acceleration in Firefox.

Maybe you are looking for