[InDesign C# Script] Problem with textframe.place(imageName)

Hi everyboy !
I am beginning with the InDesign Scripting in C#, and the documentation is very poor. I have a problem and I can't find the solution.
I have to place an image into a textframe on my document's page.
I create my textframe without any problem :
           myDocument.Layers.Add();
        InDesign.Layer lastLayer = (InDesign.Layer) myDocument.Layers[myDocument.Layers.Count];
        InDesign.TextFrame myPicture = myPage.TextFrames.Add(lastLayer, InDesign.idLocationOptions.idUnknown, myPage);
        myPicture.GeometricBounds = new string[4] { myY, myX, myY2, myX2 };
Then I try to place my Image, but I can't find which type of object is returned by .Place méthode :
First try :
InDesign.Graphics myGraphic =  (InDesign.Graphic) myPicture.Place(pathName, false);
And I have got this error :
{System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.Graphics'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{C85A4AB3-9492-4C40-8A7B-F8305706C8B8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
   at Service.createPhotograph(XmlNode photo, Page myPage) in c:\Documents and Settings\melaniep\My Documents\Visual Studio 2005\WebSites\WebSite6\App_Code\Service.cs:line 204}
And I saw this tutorial in javascript for placing images  at http://www.adobe.com/devnet/indesign/pdfs/indesigncs4_scriptingtutorial.pdf
//Display a standard open file dialog box to select a graphic file.
var myGraphicFile = File.openDialog("Choose a graphic file");
//If a graphic file was selected, and if you didn't press Cancel,
//place the graphic file on the page.
if((myGraphicFile != "")&&(myGraphicFile != null)){
var myGraphic = myDocument.pages.item(0).place(myGraphicFile);
//Since you can place multiple graphics at once, the place method
//returns an array. To get the graphic you placed, get the first
//item in the array (JavaScript arrays start with item 0).
myGraphic = myGraphic[0];
So I tried :
InDesign.Graphics myGraphics =  (InDesign.Graphics) myPicture.Place(pathName, false);
            InDesign.Graphic myGraphic = (InDesign.Graphic) myGraphics[0];
But I have got the same error.
Someone have an idea? I am really lost, and I don't know what to do :'(
Another little question.
My picture is smaller than my textFrame.
And I want my picture fits to the texframe.
MyGraphic.HorizontalScale = widthOfTextFrame
MyGraphic.VerticalScale = heightOfTextFrame
Does it works? Or Am I in the wrong way?
Thank you very much (and sorry for my bad english, I am french )

Are you also beginning with C# ? Then please reconsider, and follow tried paths with JavaScript - plenty more support around here. You could at least write a draft of your program, and only if it works move it to C#.
To get further on your issue, I'd follow the idea outlined here:
http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx
If that does not work, I'm sorry - last time I used C# is years ago, and targeting some pocket PC. No InDesign involved.
Dirk

Similar Messages

  • Scripting Problem with the Default SplitStory.vbs Schript. Windows Scripting Error No. 429, ActiveX-Component cannot create object: 'InDesign.Application", Engine: Default File: C:\Program Files (x86)\Adobe\Adobe InDesign CS6\Scripts\Scripts Panel\Samples

    On another PC it works. I can't find any difference in the script line 15. I could run the Script 1 time and the 2nd time it Show this error
    Set myInDesign = CreateObject("InDesign.Application")
    Rem Set the user interaction level to allow the display of dialog boxes and alerts.

    Hi
    delete the tbl file so it regenerates see Re: InDesign CS6 scripts don't work on CC anymore
    HTH
    Trevor

  • InDesign CS5 causing problems with InCopy assignment file but not content files

    I'm having a strange InDesign/InCopy CS5 issue (Mac OSX 10.6.6; all system & Adobe updates are current).  In my InDesign doc I have one assignment file containing two content files. All of the InCopy pieces work fine in InDesign (i.e., I can check out/in, edit, etc.).  When I go to open the assignment file in InCopy, InCopy starts to open  it but then crashes. If I try to open each content file directly in  InCopy, no problem. I've tried deleting and recreating new assignments  in InDesign, but they all have the same result in InCopy.
    I think this actually is a problem with the InDesign file because if I export the InDesign file to IDML, then try to open the IDML file, InDesign crashes! I've trashed my InDesign preferences, made sure all cross-references are up to date, etc. Anybody have any ideas what else to look for in my InDesign file that might cause this problem?
    Thanks!
    Andrea

    Thanks John!
    1) Here are the first 10-ish lines from the crash report that is generated when I try to open the IDML file:
    Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
    0   ???                               0xa0c266f0 _XHNDL_trapback_instruction + 0
    1   com.adobe.InDesign.Indexing       0x20778192 GetPlugIn + 341394
    2   com.adobe.InDesign.Indexing       0x20779009 GetPlugIn + 345097
    3   PublicLib.dylib                   0x0129228b CScriptProvider::AccessProperties(IScriptRequestData*, IScript*) + 571
    4   com.adobe.InDesign.Scripting      0x1f4befe8 GetPlugIn + 166440
    5   com.adobe.InDesign.Scripting      0x1f4c2e31 GetPlugIn + 182385
    6   com.adobe.InDesign.INXCore        0x20641444 GetPlugIn + 45220
    7   PublicLib.dylib                   0x0142c9e8 CScriptDOMElement::GetMultipleAttributes(K2Vector<IDType<ScriptID_tag>, K2Allocator<IDType<ScriptID_tag> > > const&, adobe::version_1::vector<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > >&) + 280
    8   PublicLib.dylib                   0x0142bd38 CScriptDOMElement::InsertProperties(adobe::version_1::vector<KeyValuePair<IDType<ScriptID _tag>, ScriptData>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, ScriptData> > >&, adobe::version_1::vector<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&, short, short) + 1336
    9   PublicLib.dylib                   0x0142beab CScriptDOMElement::SetSimpleAttributes(adobe::version_1::vector<KeyValuePair<IDType<Scrip tID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&, short) + 91
    10  PublicLib.dylib                   0x0142c0d3 CScriptDOMElement::SetAttributes(adobe::version_1::vector<KeyValuePair<IDType<ScriptID_ta g>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&) + 51
    11  PublicLib.dylib                   0x0142a2ea CScriptDOMElement::SetAttribute(IDType<ScriptID_tag>, DOMAttributeValue const&) + 202
    2) That works. Moved all pages (frame threading was preserved) to a new doc, exported to IDML, opened new IDML file just fine. Woo hoo! One of my editors won't be pleased that all of the tracked changes have disappeared, but at least the file functions now
    Wish I knew what caused the problem in the first place so we could (hopefully) prevent this from happening again. Any ideas?
    Thanks again for your help!
    Cheers,
    Andrea

  • Problems with decimal places and formatting

    Hi , we are having problems with an add on running on different localization companies. Decimal places separatd by "," differ from other localizations. We dont know if this is a SQL collation setting or somethng related to code or requirements to run add ons on different servers and languages.
    Any ideas??
    Thanks

    Hello
    Follow up with this thread:
    [Re: How to get the numeric value of DocTotal from UI API]
    Regards,
    J.

  • Chaining 2 Ecatt Scripts Problem with Parameter

    Hi,
    I'm trying to chain two scripts VA01 and VA02 using a new script via REF command.
    The result of VA01 (Sales Order number) is being passed as export parameter to VA02 but in the replay I can see it go into VA02 but subsequently being replaced with the default value from the VA02 script i.e. the value used when recording this script in the first place. The script then fails.
    Any help thanks

    Venkat,
    Thanks for the reply but still no joy with your suggestions
    In VA01 I have export parameter E_SALES
    In VA02 I have import parameter I_SALES
    In the 3rd linked script I have local parameter V_SALES
    I pass E_SALES value to V_SALES and then V_SALES to I_SALES in the 3rd linked script
    The value of I_SALES in VA02 does not come from the linked script as it should do. In the replay I can see the correct value go into VA02 but then overwritten with the value of parameter I_SALES in VA02 script.
    any other ideas?
    thanks

  • [ePub / Indesign 5.5] Problem with conversion to epub

    Hi everybody!
    I need some help with my job. I was converting Indesign files (ID cs5.5) to epub. So I found a problem with this message:
    I verified that the problem is in one of items that it not showed, but the style is equal another all items that is showed, I mean, all the other items with the same style is showed, see:
    I work in Mac with OSX 10.6.8.
    It's a mystery to me, cause the ohters books don't make this problem.
    I'll appreciate any help.
    Wagner

    Well, I probably answer myself.
    First, I reset the [Basic Paragraph],
    - Set the style that I applied in the text, like "Title chapter" with Based on: basic paragraph with the changes.
    - And then, set the TOC style with Based on: basic paragraph too with the changes.
    For one book this resolved, for another one it needs create another style Based on: [Basic paragraph], changes that I need, apply and change the table of contents style with whis one and, woks fine.
    The reason, I'll still waiting for the reason.
    Wagner

  • Scripting problems with upgraded project file

    Hello,
    I hope someone can offer a bit of help on this one. I have a v3 project file that I upgrade to v4. I decided to add a "return to menu" script to this project file. 3 scripts to set GPRM 0 mov to 0,1,2 for three different menus. And a final Jump script to Jump to Menu 1 if GPRM 0=0, Jump to Menu 2 if GPRM 0=1, Jump to Menu 3 if GPRM 0=2.
    This doesn't work - won't work in simulator nor on a build. I suspect that the culprit is the upgraded project file. I made a new v4 project file and replicated these same exact scripts and behold! It works!
    So I figured out that it's the upgrade project file that is the reason why these scripts won't work! Very disappointing.
    But now, what can I do short of rebuilding this project all the way from scratch?!?
    It's too bad you can't open 2 projects and copy and paste from one into another.
    Using DVDSP 4.0.3
    Dual 2 ghz G5   Mac OS X (10.4.5)  

    If you'd like to strip out the project assets (video and audio) and use .pict images as place holders instead, then send me the file (with the place holders), I'll happily take a look at it for you. It should be working fine, and I suspect there is something small we have both overlooked.
    There are no real issues with projects from v3 going on to v4 where scripting is concerned - the scripts are identical. There will be something else going on here...
    Just to be sure your scripts are:
    mov GPRM1, 0
    Jump MainMenu // your actual menu name is here
    then
    mov GPRM1, 1
    Jump SceneSelection1 // again, your actual menu name is in here
    and
    mov GPRM1, 2
    Jump SceneSelection2 // and again for the menu name
    Then your final script reads:
    Jump MainMenu If(GPRM1 = 0)
    Jump SceneSelection1 If (GPRM1 = 1)
    Jump SceneSelection2 If(GPRM1 = 2)
    The first script is the start up item for the disc, the second and third scripts are set as targets for buttons on the main menu (which means the script is run before the footage plays) - the last script is set as the menu call and end jump for the track.
    You are sure that you are correctly re-setting the GPRM each time you move between menus?
    If this simple scripting system isn't working then there is going to be a reason for it besides the upgrade... send me the file, I'll have a look. Alternatively, have a look here for downloadable stuff, and find the zip archive called 'Chi-Ho Lee', which is a simplified PAL version of how I think you should have this set up.

  • TOC/Script problem with Netscape

    I am using RoboHelp (webhelp) 5.5.
    I am facing two problem with netscape browser.
    1. loading the page itself take long time and show a message
    that script on this page is causing mozilla to run slowly.
    2. in the TOC when i click the TOC BOOK the content of the
    page inside that book is opened in new tab page in the same browser
    instant

    Hello Robo_Rajesh,
    Welcome to the forum.
    As a start point, I would suggest you check the following on
    Peter Grainge's web site for an explanation.
    Click
    here.
    Hope this helps.
    Brian

  • VB Script Problems with Windows Vista Ultimate

    I have iTunes 7.0.2.16 and when i try to update it i keep getting a message that says:
    "iTunes could not be installed becasue visual basic script (VB Script) is not installed or has been disabled. make sure VB Script is installed, turn off script blocking in anti-virus and personal firewall software, re-register VB Script, then install iTunes."
    I even get this message when i try to unistall iTunes. I completly uninstalled my antivirus software and removed all firewalls, but i wasnt able to fix the problem.
    I visited the iTunes and QuickTime for Windows cannot be installed without Visual Base Script (VBScript) section for help, however, it was unable to solve my problem.
    I currently have Windows Vista Ultimate and have been looking for a fix for a while now...any help would be greatly appreciated...
    thanks
      Other OS   Windows Vista Ultimate
      Other OS   Windows Vista Ultimate
      Other OS   Windows Vista Ultimate

    Hey rrijeka,
    Unfortunately, Vista is currently not compatible with iTunes.
    This article: http://docs.info.apple.com/article.html?artnum=305042 will tell you more about the iTunes and windows Vista compatability. The article will also be updated when itunes and Vista are compatible.
    Jason

  • InDesign CS2 has problems with multiple hard drives

    I have a mac pro that has two external hard drives attached to it. One is connected through usb and the other firewire. When ever I try to open an inDesign file on the hard drive that mounted second I get an error message. However I the hard drive that mounted first works just fine.
    The error message is: "Cannot open the document xxx. You may not have permission or the document may be open already. For multi-user access, close the file and then lock it using the File > Get Info command in the Finder."
    Any help would be greatly appreciated.

    I've not had any such problem. It's been a while since I used CS2, but I definitely used it on computers with more than one disk attached. I don't think I had a mix of FireWire and USB drives though.
    Dave

  • BAPI_ACC_INVOICE_RECEIPT_POST problem with Business place

    Hi Experts,
    I'm using the the BAPI  "BAPI_ACC_INVOICE_RECEIPT_POST" for the F-43 posting, it's working fine. But I have a little problem here, Even though I pass the correct values to the fields "Valuation type" and "Business place" in the posted document I could see only "?".
    Could you please some one help me in finding what might be the problem.
    Thanks
    Nivash

    hi
    hope it will help you.
    <REMOVED BY MODERATOR>
    BAPI_ACC_GL_POSTING_CHECK
    CALL FUNCTION 'BAPI_ACC_GL_POSTING_CHECK'
    EXPORTING
    documentheader = w_documentheader
    TABLES
    accountgl = it_accountgl
    currencyamount = it_currencyamount
    return = it_return.
    Populate the corresponding tables with the data you have.
    For the Date do convert it.
    PERFORM convert_date USING it_header-bldat
    CHANGING w_documentheader-doc_date.
    w_documentheader-comp_code = 'z998'
    w_documentheader-doc_type = 'SA'
    "and fill the respective tables this way .
    <b>
    BAPI_ACC_GL_POSTING_POST
    </b>
    call function 'BAPI_ACC_GL_POSTING_POST'
    exporting
    documentheader = doc_header
    IMPORTING
    OBJ_TYPE = l_objtype
    * OBJ_KEY =
    * OBJ_SYS =
    tables
    accountgl = t_accountgl
    currencyamount = t_curramt
    return = t_return
    * EXTENSION1 =
    Edited by: Alvaro Tejada Galindo on Feb 7, 2008 9:51 AM

  • InDesign Transparency Effects - Problems with Image Quality and File Size

    Hello,
    We are experiencing new problems exporting InDesign files to PDF.
    To summarize, though our largest workflow is to create files for offset printing, we also deliver our work to PDF for mounting on a website so our clients can download directly from the web. Our new problem is Transparency Effects, and creating a PDF that will both have a high quality (or resolution), and be a small file size.
    We are working with multiple page documents (24 to 48 pages), and would very much like to work with InDesign Transparency Effects. However, after spending much time testing a variety of PDF types, we are finding there is a radical difference between quality and file size. I was curious if anyone has had these problems, and if there is a simple answer. InDesign is an incredible program that allows us to design on the fly with Transparency Effects, but, if we are going to experience these problems, we will have to eliminate these wonderful tools.
    Can you help me or lead me to information online that will help.
    Thank you,
    Lain

    Please don't post in multiple forums. Your question has nothing to do with the PDF language and specifications, but rather PDF workflow or InDesign. I've responded to your other posting and am closing this thread.
    - Dov

  • Scripting problems with pipes!

    Hi Boardies!
    I'm working on a script to automatically generate PKGBUILDs for my custom kernels (For my 3 systems I need 3 custom kernel packages).
    Each PKGBUILD needs the md5 checksum block, which I can generate with "makepkg -c > PKGBUILD".
    Here is the problem
    This command writes the checksums at the end of the PKGBUILD file. This isn't a clean solution. The checksums should wrote before the "build()" function.
    Because of that I need a trickly bash command, which search (grep maybe?) the "build() "-line and writes the md5-checksum block before that line.
    I tested around with egrep, but I can't isolate the line-number of "build()" and I don't know how to paste the md5-checksums be at the position (line - 1)!
    I hope somebody can help me. Thanks for your answers
    Best regards,
    Flasher

    A simple perl script would be appropriate.  The easiest way to approach this problem (actual perl programmers feel free to correct me) is to do the following:
    iterate over the file, pulling each line into a string appended to an array
    iterate over the array, printing each line.  If build() is matched, print md5sum, then the line.
    write the corrected file to stdout
    Here's one I called test.pl
    #!/usr/bin/perl
    #Add MD5SUM to file
    #Read from stdin into @file
    while (<>) {
    chomp;
    push(@file, $_);
    foreach my $a (@file) {
    if ($a =~ /build\(\)/) {
    print "MD5SUM\n";
    print "$a\n";
    Then the following command:
    cat PKGBUILD | ./test.pl > temp
    mv temp PKGBUILD
    Produces an identical PKGBUILD with the word MD5SUM printed on the line above build().

  • Script problem with CC 2014

    hi,
    i have a problem i try to put a new screen. Freebies — Mt. Mograph from there but when i download the file on os i have to change the jsxbin in jsx to see  the icon jsx, then i put the script in ui scrpt panel but nothing happen i dont see it when i'm opening my AE ?
    what's wrong with it??

    Just to be clear.
    If you put jsxbin script to Scripts folder or to Scripts -> ScriptUI Panels it runs OK both from File->Scripts and Window - > "script name".jsxbin.
    However, if you do File -> Scripts -> Run Script File.... AE does not recognize jsxbin file and shows it greyd out. For that I have to rename those jsxbin files to jsx.

  • Live ID sign in problem after script problem with ...

    I am again having to sign in to WLM Live ID after each reboot.
    I first came across this problem when the Yahoo Toolbar was upgraded. See thread:
    http://community.bt.com/t5/BB-Speed-Connection-Issues/BT-Toolbar-installer-ongoing-problem-STILL-ONG...
    The script error "fix" has again changed the HKEY_USERS registry entry!
    I really am at a loss to understand why BT can't get its head around this.
    [HKEY_USERS\S-1-5-21-796845957-926492609-725345543-1003\Software\Microsoft\Windows\CurrentVersion\Exp lorer\User Shell Folders]
    AppData = %AppData%
    The problem here is AppData should actually be the following
    AppData = %USERPROFILE%\Application Data
    So when MSN or other apps that use that registry key go to save their data it gets lost.
    So the solution is simple, run regedit and go to
    [HKEY_USERS\S-1-5-21-796845957-926492609-725345543-1003\Software\Microsoft\Windows\CurrentVersion\Exp lorer\User Shell Folders]
    and modify/set the value AppData to a data value of %USERPROFILE%\Application Data

    I just had a look at the relevant forum http://forums.adobe.com/community/labs/widgetbrowser?view=discussions&start=0; but no help there either.
    To give you an idea, I was having the same problem, I could not log in. Despite that, I did have the most up to date widget in my browser, the one that dates back to 01/13/2012. Since then, no more widgets have been added.
    Along with ADDT and Spry I guess that the widget browser has become the next casualty.
    You can still use the browser, just be careful in the knowledge that the newest widget is already one year old.

Maybe you are looking for