Sunday, April 4, 2010

how to get selection text in indesign...

Hi to all,

i need to get selection content text in indesign using C#

pls help me

Thank you


Thangaraj

how to get selection text in indesign...

The same as in the other scripting languages:

alert (app.selection[0].contents);

Thank youhow to get selection text in indesign...

Hi Jongware,

This is not correct in C# you have type cast all the object to another Object and then only we can access it in required format

for example

if want to get font in active Document

InDesign.Application myInDesign=?(InDesign.Application) COMCreateObject(''InDesign.Application'');

InDesign myDocument = (InDesign.Document)myInDesign.ActiveDocument;


InDesign.ParagraphStyles pStyles = (InDesign.ParagraphStyle)myDocument.ParagraphStyles

InDesign.ParagraphStyle pSteyls = (InDesign.ParagraphStyle)myDocument.ParagraphStyle

for(int i =0;i%26lt;pStyles.Count;i++)

{

pStyle = (InDesign.ParagraphStyle)myDocument.ParagraphStyles[i];

}

public static object COMCreateObject (string sProgID)
{
?// We get the type using just the ProgID
?Type oType = Type.GetTypeFromProgID (sProgID);
?if (oType != null)
?{?
?return Activator.CreateInstance( oType);
?}
?
?return null;
}

like above content

for selection content u have to type cast selection object.

InDesign.Selection = (InDesign.Selection).myDocument.Selection;

Console.Writeline(InDesign.Selection.Contents);

but it showing error....

like this you have to type cast all things in C# and you cannot simply get selection contents like app.selection[0].contents

pls help me

Thank you for your reply....

R. Thangaraj

O-kay. Seems a lot of stuff happens behind javascript's back.

Why would Writeline fail? You say it 'gives an error' but you don't say what error. I would guess this: ''selection'' is an untyped object in ID, because it can return all kinds of objects. In this particular case, you get a return value but you have to manually cast it to the type you would expect [*] -- in this case 'text'. An additional problem may be that it's probably Unicode (wide) text, and -- as documented -- if you select just one special character, it's not text at all but a long integer code for that special character.

[*] That's quite the opposite of what happens with JS, but I think it's the case here.

Hi to all,

I tried in Vb6 to get Indesign Com object and its working

You can get selection content like this

and you convert this code for C#

Dim Appl As InDesign.Application

Dim sel As Variant

Private Sub Command1_Click()
On Error GoTo Err1:

Set Appl = CreateObject(''InDesign.Application.CS3'')
Set sel = Appl.Selection(1) 'selection variable should be a variant
MsgBox (sel.AppliedFont)
MsgBox(sel.Contents)
Err1:
MsgBox Err.Number %26amp; '' '' %26amp; Err.Description

End Sub

  • eye color
  • Open pdf problem

    Server config : windows server 2003 , iis 6.0

    When the client (use IE 7.0)?download a pdf file?some error occur :

    If the pdf file size smaller than 500KB , it can open through the IE .

    If the pdf file size larger than 500KB , it can not open through the IE . The IE load very very long time and then the screen became white.

    However , if choose save the target , it can save the file in my PC and the file( larger than 500KB ) can open.

    Another method to open the file , change the pdf preferences. Set do noth open the pdf through the IE.

    What happen?? I don't know how to trouble shoot it.

    thanks!

    *p.s. Someone teach me use other pdf reader open the file through IE , it was success.

    ?What different between the pdf reader software.

    bookmarks for languages with special...

    hallo,

    Is there any easier way to develop bookmarks?at acrobat for languages with special characters??

    so far i have to use touch up text tool and copy paste every heading so that characters appear correct...

    It would be really helpful!!!

    [svn:osmf:] 10261: Fix for bug FM-69.

    Revision: 10261

    Author: evrijkom@adobe.com

    Date: 2009-09-15 02:51:15 -0700 (Tue, 15 Sep 2009)

    Log Message:

    ***********

    Fix for bug FM-69.

    Ticket Links:

    ************

    http://bugs.adobe.com/jira/browse/FM-69

    Modified Paths:

    **************

    osmf/trunk/apps/samples/framework/ExamplePlayer/org/openvideoplayer/examples/ch romeless/ChromelessPlayerElement.as

    Progressbar for DataGrid

    Hello,

    I've got an air application with a datagrid, the information thats goes in the datagrid comes from an xml.

    Sometimes it takes a while to load the information, but it doesn't tell you that the information is loading.

    Now what I need is an progressbar for the datagrid, it needs to tell you that the data is loading and how much time is left (or % ).

    The progressbar is already in place. I can't find the right answer, hopefully you can help me.

    I'm getting the information with the HttpService and an XML (php) file on my server.

    Progressbar for DataGrid

    It depends on where the time is being spent. If the XML is coming from a server, there should be progress events available. If the XML is on the local disk, it might get loaded in one gulp and the parsing of the XML is where you're spending time. It is much harder to show progress there. See the pseudo-threading post on my blog.

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc.

    Blog: http://blogs.adobe.com/aharui

    PDF Form in Particular Font 2

    I need to create a PDF-form with a particular font. I already embedded the font when exporting from InDesign and set the ''Subset fonts...'' to 0% as advised to in this link:

    http://forums.adobe.com/thread/426831

    However when I try to choose the specific font (Melior), I get this error-message:

    ''The selected font has a custom encoding and cannot be embedded ind the PDF-file because of licensing restrictions. (...)

    To avoid this situation, use a font that can be embedded in the PDF file, a font that does not have a custom encoding or a font that is known to be on all systems where the PDF file will be viewed.''

    What can I do?

    Thanks for your help!

    C

    Populate flex tree control on demand...

    First, I am sorry if the same post is already posted here but after spending 30 minutes or may be more I could not find the solution.

    By the way I have two problems. 1.) I am new to flex which I know if my own problem and soon I will handle it.

    2.) This is major problem for me. I have to populate Tree control from database and I used HTTPService to get the data from database.

    I created a object of HTTPService and on load of Tree control I am calling a function which calls the HTTP URL and returns me the first level of node for my Tree.

    When I click on any node a function is called again using HTTPService and result is appended to the currently selected node. The same goes until n level and it works fine. I was happy with my results. I am stuck in new problem. The problem is if the tree is already populated on my browser and I make some add/update/delete any node or child node, the flex doesn't make a call to HTTP URL and I am not getting updated data.

    The mxml code is below (this code has some extra things too).

    %26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
    %26lt;mx:Application xmlns:mx=''http://www.adobe.com/2006/mxml''
    layout=''vertical''?backgroundGradientAlphas=''[1.0, 1.0]''
    backgroundGradientColors=''[#000000, #868686]'' %26gt;
    %26lt;mx:Script%26gt;
    ?%26lt;![CDATA[
    import mx.utils.StringUtil;
    import mx.rpc.http.HTTPService;
    import mx.events.ListEvent;
    import mx.binding.utils.BindingUtils;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.collections.XMLListCollection;
    import mx.utils.ObjectProxy;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    import mx.utils.ArrayUtil;

    [Bindable]
    public var datalist:XMLListCollection = new XMLListCollection();

    [Bindable]
    public var xmlFromDatabase:HTTPService=new HTTPService();

    [Bindable]
    private var xmlForChildren:HTTPService;

    private function resultHandler( event:ResultEvent ):void
    {
    var x:XML = event.result as XML;?
    var xl:XMLList = XMLList( x );
    }

    private function faultHandler( event:FaultEvent ):void
    {
    ?Alert.show(event.message.toString());
    }

    private function display():void
    {
    ?var params:Object = {};
    ?params[''parent''] = ''0'';

    ?xmlFromDatabase.url = ''http://localhost:8080/GrailsFlex/department/tree'';
    ?xmlFromDatabase.method = ''GET'';
    ?xmlFromDatabase.resultFormat = ''e4x'';
    ?xmlFromDatabase.useProxy = false;
    ?xmlFromDatabase.send(params);
    ?xmlFromDatabase.addEventListener(ResultEvent.RESULT,displyTree,false,0,false);
    }


    private function displyTree(event:ResultEvent):void
    {
    ?XMLtree1.dataProvider =?event.result;
    ?XMLtree1.labelField = ''@name'';
    }

    private function getChilds(event:ListEvent):void
    {
    ?try
    ?{
    var xmlTree:Tree = event.currentTarget as Tree;

    var node:XML = xmlTree.selectedItem as XML

    var params:Object = {};

    params[''parent''] = node.@id;
    ?
    xmlForChildren = new HTTPService();
    xmlForChildren.url = ''http://localhost:8080/GrailsFlex/department/tree'';


    xmlForChildren.method = ''GET'';
    xmlForChildren.resultFormat = ''e4x'';
    xmlForChildren.useProxy = false;
    xmlForChildren.send(params);

    xmlForChildren.addEventListener(ResultEvent.RESULT,appendChild,false,0,false);
    xmlForChildren.addEventListener(ListEvent.ITEM_CLICK,getChilds,false,0,false);
    ?}
    ?catch (E:Error)
    ?{
    Alert.show(''getChilds Error:-- '' + E.message);
    ?}
    }

    private function deleteTreeNode(xmlItem:XML):void
    {
    ?var xmlParent:XML = XML(xmlItem).parent();
    ?
    ?if (xmlParent.@parent == null || StringUtil.trim(xmlParent.@parent) == '''')
    ?{
    xmlParent.@parent = ''0'';
    ?}
    ?
    ?if (xmlParent.@parent != ''0'')
    ?{
    //Recursive call until I get reach to children of root node
    deleteTreeNode(xmlParent);
    ?}
    ?else
    ?{
    // Now I am at root.
    var xmlRoot:XML = XML(xmlParent).parent();

    var bActualRoot:Boolean = false;

    if (xmlRoot == null)
    {
    ?xmlRoot = xmlParent;
    ?bActualRoot = true;
    }

    if (bActualRoot)
    {
    ?if (xmlRoot.@parent == ''0'')
    ?{
    try
    {
    ?for each (var xl:XML in xmlParent.children())
    ?{
    if (xl.@name != xmlItem.@name)
    {
    ?for (var cn:int=xl.children().length()-1; cn %26gt;=0; cn--)
    ?{
    delete xl.children()[cn];
    ?}
    }
    ?}
    }
    catch (ex:Error)
    {
    ?Alert.show(''error Real Root: '' + ex.toString());
    }
    ?}
    }
    else
    {
    ?for each (var nodexm:XML in xmlRoot.children() )
    ?{
    if (nodexm.@name != xmlParent.@name )
    {
    ?try
    ?{
    for (var cu:int=nodexm.children().length()-1; cu %26gt;=0; cu--)
    {
    ?delete nodexm.children()[cu];
    }
    ?}
    ?catch (ex:Error)
    ?{
    Alert.show(''error No Real Root: '' + ex.toString());
    ?}
    }

    ?}
    }


    ?}
    }

    private function appendChild(event:ResultEvent):void
    {
    ?
    ?var node:XML = event.result as XML
    ?
    ?var sItem: XML = XMLtree1.selectedItem as XML;
    ?
    ?if (sItem.children().length() %26gt; 0)
    ?{
    delete sItem.children();
    ?}
    ?
    ?
    ?for(var i:int=0; i %26lt; node.children().length(); i++)
    ?{
    ?var item:XML = node.children()[i];

    ?XMLtree1.selectedItem.appendChild(item);
    ?XMLtree1.expandItem(XMLtree1.selectedItem,true,true);
    ?}
    ?
    ?deleteTreeNode(XML(XMLtree1.selectedItem));
    }
    ?]]%26gt;
    %26lt;/mx:Script%26gt;



    %26lt;mx:Tree id=''XMLtree1'' width=''350'' height=''470''
    ?showRoot=''false'' creationComplete=''display()'' itemClick=''getChilds(event)''?/%26gt;


    %26lt;/mx:Application%26gt;

    Thanks in advance

    Populate flex tree control on demand...

    Looks like nobody knows how to do it.

    Populate flex tree control on demand...

    I am also interested in this solution.?I'm trying to accomplish something a little different, but any insight into your solution should help me with mine. I'm trying to populate a tree via webservice.?For me the backend is standard SOAP WebService implemented in ASP.NET.?I suspect my problem has something to do with mapping the datastructure I am returning to that of the tree, but I am at a loss for how right now.?Anyway, I hope you do get an answer to yours.?Sorry I couldn't help.

    -- Matthew

    try this

    %26lt;mx:Tree id=''XMLtree1'' width=''350'' height=''470''
    ?showRoot=''false'' change=''display()'' itemClick=''getChilds(event)''?/%26gt;

    this should work when you add or delete a node.

    also, make sure to populate the tree at the first time.

    Thanks buddy for the answer.

    Unfortunately the answer came after quite long time of posting the message. Anyway I was able to open a tree on demand using HttpService and due to my new requirement I changed it to RemoteObject.

    I my latest change I am able to populate tree nodes on demand and also the same solution if getting update from server via JMS using Consumer object.

    I kind a like this solution because it took me good amount of effort to find the right solution.

    If any one is intersted the he/she can reply to the post and I can provide code here or may at some location so that it can be easily downloaded.

    The solution is Flex-Grails combination.

    Thanks everybody.