17 Replies Latest reply: May 14, 2012 10:58 PM by Bill joy RSS

    how to access indesign cs3 document through VC++

      Hello

      i am new to VC++, i need to communiacte Indesign CS3 through VC++, for this what can i do? inorder to access indesign docuemnts,

      i also need to access a Third party API for CS3 through VC++, for the two puproses, i dont have any idea, so

      kindly help me

      with regards,
      ram
        • 1. Re: how to access indesign cs3 document through VC++
          Hi ram

          InDesign exposes all its methods through a COM object. Don't know how to use it in VC++, but in C# I simply add a reference to the COM object (Adobe InDesign CS3 Type Library), whereafter I can instantiate (start up) InDesign, open documents and manipulate them in any way I want.

          Others in this forum uses VB to access the COM object, so it should also be possible to use VC++.

          BR
          Bo
          • 2. Re: how to access indesign cs3 document through VC++
            Community Member
            Hi ram,

            You probably want to ask this question in the InDesign SDK forum--that's where the third-party API developers hang out.

            You can work with the InDesign scripting object model using C++, but I think you're probably asking about developing InDesign plug-ins using the C++ SDK.

            Thanks,

            Ole
            • 3. Re: how to access indesign cs3 document through VC++
              Community Member
              Hi Peter,

              Thanks for ur reply,

              i know and i also access indesign in C#, but i need to access a third party plug-in (In-Math Styles Plugin) for this they give a C/C++ Header Files(API's), and they tell try to access the third party plugin with the help of the header files,

              for this, C# does not allow header files, so i will try to access this with VC++, but i am new to VC++, so i dont know how to add a COM to the project and access through that COM,

              if u have idea, or please disscuss this with ur friends and then reply me

              thanks and with regrds,
              ram
              • 4. Re: how to access indesign cs3 document through VC++
                [Jongware] CommunityMVP
                My friends think you should ask about COM objects in a VC group, not a typesetters' hangout.

                They also appreciate the odd capital and think l33tsp33k is so 2001.
                • 5. Re: how to access indesign cs3 document through VC++
                  Community Member
                  Hi ram,

                  I don't know if In-Math supports InDesign scripting, but you have not yet realized that the C++ API and the COM objects exposed to scripting (i.e., VBScript, C#) are TWO FUNDAMENTALLY DIFFERENT THINGS. Which do you want to use? If they gave you C++ header files, you want the SDK forum. That's a different forum. This is the InDesign scripting forum.

                  Thanks,

                  Ole

                  PS. jongware: teh 4LL C4PS pwnz ur 133+ :-)
                  • 6. Re: how to access indesign cs3 document through VC++
                    Community Member
                    Hi ram<br /><br />As Olav has pointed out, you need to decide whether to use COM or SDK.<br /><br />SDK is hard core - and I really mean HARD CORE. I consider myself to be a reasonably good VC++ programmer, but when I tried to develop an InDesign plug-in using SDK and VC++ I was completely lost.<br /><br />However it is possible to use VC++ to control InDesign via the COM object.<br /><br />Here is what you should do:<br /><br />1) Make a new VC++ project (MFC, MFC Application)<br />2) In Wizard dialog select Dialog Based and leave everything else unchanged (simply press Next)<br />3) You now have a simple empty dialog with 2 buttons<br />4) Double-click the OK button<br />5) Insert the following code (before OnOK()):<br /><br />// COM support required for this<br />//  Call CoInitialize() to initialize the COM library on the current thread<br />if(::CoInitialize(NULL) != S_OK) return;<br /><br />// Create instance of InDesign Application<br />InDesign::_ApplicationPtr app;<br />// Use the appropriate version here<br />//  This string will be used to search the registry for the application<br />//  associated with it and the same is invoked. <br />//  If you have different builds of the same version and you want to work<br />//  with a specific build, call CreateProcess() for that build and then<br />//  call CreateInstance() so that the currently running instance is returned.<br />app.CreateInstance(L"InDesign.Application.CS3");<br /><br />// Open existing document<br />InDesign::DocumentPtr doc = app->Open("C:\\InDesign\\myDocument.indd", true);<br />InDesign::PagePtr page = doc->Pages->FirstItem();<br />InDesign::TextFramePtr textFrame = doc->TextFrames->FirstItem();<br />textFrame->Contents = "Hello world";<br /><br />6) Go to the start of the file<br />7) Insert the following code before // CAboutDlg dialog used for App About<br /><br />// Required for calling COM initialization methods<br />#include <objbase.h><br /><br />// Import InDesign's Type Library<br />#import "C:\Documents and Settings\All Users\Application Data\Adobe\InDesign\Version 5.0\Scripting Support\5.0\Resources for Visual Basic.tlb"<br /><br />8} Build and run the project (F5). When you press OK, InDesign should launch, open your document, find the first page, find the first TextFrame and replace the text (contents) with "Hello world"<br /><br />How to get in contact with your third-party API is a completely different ball game (not in the scope of this forum), but at least you now have a VC++ project with header files etc.<br /><br />If your third-party API is indeed an InDesign plug-in, I totally agree with Olav that you have to direct your questions to the SDK forum.<br /><br />Best regards,<br />Bo
                    • 7. Re: how to access indesign cs3 document through VC++
                      Community Member
                      Hi Peter,

                      Thanks for ur reply, sorry for long time, because i have included in another project work

                      Now, i accessed the Indesign through VC++, with the help of your code as in above mail,

                      but i need to know how to access the textframe->content with font and colours, so i will get some ideas of accessing the InMath Third Party Plug-in.

                      so u knidly give me some scripting examples for Indesign throgh VC++

                      reply me ASAP

                      thanks and with regrds,
                      ram
                      • 8. Re: how to access indesign cs3 document through VC++
                        Community Member
                        Hi ram,

                        re: "but i need to know how to access the textframe->content with font and colours, so i will get some ideas of accessing the InMath Third Party Plug-in."

                        Does InMath support InDesign scripting? I don't know. If it doesn't, learning about the native InDesign scripting objects/properties/methods will not do you any good. If they gave you C++ header files, chances are good that they do not support scripting, but do provide a C++ API. These are two very different things. Do you understand the difference?

                        Thanks,

                        Ole
                        • 9. Re: how to access indesign cs3 document through VC++
                          Community Member
                          Hi Ole,

                          i also dont know that the InMath plugin support the InDesign scripting, but the InMath Plugin works succesfully in InDesign, my work is to access the plugin through source code(programming)

                          re: "If they gave you C++ header files, chances are good that they do not support scripting, but do provide a C++ API. These are two very different things. Do you understand the difference?"

                          if there is change to access the plugin through Header files what are the ways to access that?,
                          I Think API means the header files, but i not sure

                          please explain the differences

                          Thanks,

                          Ram
                          • 10. Re: how to access indesign cs3 document through VC++
                            [Jongware] CommunityMVP
                            >i also dont know that the InMath plugin support the InDesign scripting

                            An easy way to check is if you can access it through JavaScript. If so, you can do the same in C++ as you can do in JS -- that is, using the objects, properties, and methods they provide to use the plugin.

                            The alternative way is, in effect, writing your
                            i own
                            plugin. That is definitely NOT for the faint hearted, let alone for the casual explorer you appear.
                            In that case you need the original C++ header files for the plugin, just as Adobe provided the original C++ header files to all InDesign components -- scriptable and other.

                            >please explain the differences

                            I think Ole's point was, if you need the differences explained to you, you're already in more trouble than you can handle.
                            • 11. Re: how to access indesign cs3 document through VC++
                              Community Member
                              Hi Ram,

                              If InMath does not support InDesign scripting, then you would not use COM--you'd create a plug-in, DLL, or separate program to address the InMath API (just as an InDesign plug-in works with InDesign's API).

                              My main point is: I don't know anything about InMath, and their web site doesn't really tell me much about the features of the plug-in, let alone anything about its support for scripting. Without that information, I can only make guesses.

                              This means that the questions you're asking are best answered by the InMath developer. C++ header files alone will not give you what you need to know.

                              Looking at the InMath site, however, I note that they say that they use native InDesign objects. They don't offer a direct download of a demo, but you could try sending me a file with an InMath equation in it (my email is under my user name; send me a message before you send a file). If they don't create an InMath object of some sort, we might be able to get at it. If this is the case, you won't even need to use C++ (you'll be able to use JavaScript or another of the supported languages).

                              Thanks,

                              Ole
                              • 12. Re: how to access indesign cs3 document through VC++
                                Community Member
                                Hi,

                                again i have some doubts, how to use the adobe in design SDK in our VC++ project.

                                i.e., if i use the header file in my project it will give an error
                                "fatal error C1083: Cannot open include file: 'VCPlugInHeaders.h': No such file or directory"

                                if i include the hole sdk header files in my project then again i get a error on the sdk header files,

                                but when i use sdk sample Writefishprice plugin project, they access the indesign SDK header files, but not included in the project folder, how they do this?

                                please reply ASAP

                                regards,
                                ram
                                • 13. Re: how to access indesign cs3 document through VC++
                                  Community Member
                                  Hi ram,

                                  Have you tried asking this in the InDesign SDK forum?

                                  Thanks,

                                  Ole
                                  • 15. Re: how to access indesign cs3 document through VC++
                                    Community Member

                                    Hi,

                                     

                                    Can anyone please help me to access InMath styles in InDesign SDK using VC++ Programming.

                                     

                                    Thanks

                                    Saravana

                                    • 16. Re: how to access indesign cs3 document through VC++
                                      Community Member

                                      Hi,

                                       

                                      Can anyone please help me to access InMath styles in InDesign SDK using VC++ Programming.

                                       

                                      Thanks

                                      Saravana

                                      • 17. Re: how to access indesign cs3 document through VC++
                                        Bill joy Community Member

                                        Hi Bo_Peters

                                         

                                        I want to ask you that How create Indesign application using vc++ ?

                                         

                                        I am able to develop application in C# using COM and generate Interop.Indesign.dll using InDesign

                                         

                                        Using This code i am sucessfully create Indesign instance

                                        Type type = Type.GetTypeFromProgID("InDesign.Application");

                                        InDesign._Application application = (InDesign._Application)Activator.CreateInstance(type);

                                         

                                        I am not understand how use COM with vc++ or there is another method to create Indesign instance using vc++.

                                        If i use the steps that You told

                                         

                                        However it is possible to use VC++ to control InDesign via the COM object.

                                        Here is what you should do

                                        1) Make a new VC++ project (MFC, MFC Application

                                        2) In Wizard dialog select Dialog Based and leave everything else unchanged (simply press Next

                                        3) You now have a simple empty dialog with 2 buttons

                                        4) Double-click the OK button

                                        5) Insert the following code (before OnOK

                                        // COM support required for this

                                        //  Call CoInitialize() to initialize the COM library on the current thread

                                         

                                        if(::CoInitialize(NULL) != S_OK) return

                                         

                                        // Create instance of InDesign Application

                                         

                                        InDesign::_ApplicationPtr app

                                         

                                         

                                         

                                        Then it give error 'InDesign ' : is not a class or namespace name

                                         

                                        Thanks