3 Replies Latest reply on May 17, 2011 8:37 PM by zyberkid

    Network Delay while placing image(PDF File)

    zyberkid

      Hi

      i am using following code for placing PDFs and Texts in single text Frame.

      if the PDF is in local folder then place works perfectly as desired, if the PDF path is a network path , then a overlap is happening .

       

      i'm inserting the text and pdf in this sequence,

       

      place PDF,

      place text1,

      place text2,

      place text3,

      place PDF,

      place text1,

      place text2,

      place text3,

      place PDF,

      place text1,

      place text2,

      place text3,

      place PDF,

      place text1,

      place text2,

      place text3,

      .

      .

      .

      .

      and so on.

       

      at 3rd,4th insertion the overlap is happen.

      actual order after placing all the texts and PDF is like this

      place PDF,

      place text1,

      place text2,

      place text3,

      place PDF,

      place text1,

      place text2,

      place PDF,

      place text3,

      place text1,

      place text2,

      place PDF,

      place text3,

      place text1,

      place text2,

      place PDF,

      place text3,

      ...

       

      is there any possibility, to tell system to wait(sleep will cause more delay) until the it places the content and then move for the next text content.

      or

      is it possible to load the pdf to links and then place pdf from the link?

      sample code:

       

      var tframe = app.documents[0].pages[0].textFrames.add ();
      tframe.geometricBounds = [0,0,"150mm","150mm"];
      var myfile= "C:\\Karthik\\Ellipse.pdf";
      
      //inline.anchoredObjectSettings.anchoredPosition = AnchorPosition.aboveLine;
      for(i=0;i<10;i++)
      {
      // some network path
      myfile= "\\xyz server\\Ellipse.pdf";
                      if (i==0)
                      {
                                      var inline =tframe.insertionPoints[0].place (myfile)[0].parent;
      
                                      }
                      else
                      tframe.insertionPoints[-1].place (myfile)[0].parent;
                      tframe.insertionPoints[-1].contents = "\rSample text\rMore sample text\r";
      
      
      }
      
      
        • 1. Re: Network Delay while placing image(PDF File)
          Haakenlid Level 3
          is there any possibility, to tell system to wait(sleep will cause more delay) until the it places the content and then move for the next text content.

          or

          is it possible to load the pdf to links and then place pdf from the link?

          sample code:

           

          You can make the system sleep by calling $.sleep() like this:

           

          $.sleep(milliseconds)
          

           

          I doubt it will solve your problem, though, because the commands will run in the sequence you program it.

           

          The content might be misplaced because your textframe overflows. Try targeting the story instead when placing.

           

          tframe.parentStory.insertionPoints[-1].place(myfile)

           

          Does that make any difference?

          • 2. Re: Network Delay while placing image(PDF File)
            John Hawkinson Level 5

            I'm also skeptical that this problem is due to the network.

             

            Are you sure?

             

            What's the smallest reproducible test case to get this problem?

            Can you make it happen with just 2 or 3 files?

             

            If you copy those same files locally and try it, it really does not work?

             

            You could try printing out Date.now() between files if your really believe it to be timing related.

            1 person found this helpful
            • 3. Re: Network Delay while placing image(PDF File)
              zyberkid Level 1

              hi john,

               

              actually this thing worked,

              tframe.parentStory.insertionPoints[-1].place(myfile)

               

              there was no problem with network delay. and text overlapped due to the overflow only.

              initially i thought importing the image will run on a separate thread. and so it causes placeing the image at different place.

              i was wrong,

               

              thanks Haakenlid, john for your help.