Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Multipage PDF Import using IDS API

Return to Member Forum

  • Author
    Posts
    • #57600
      Anonymous
      Inactive

      When I run the following C#.net code, I end up with an in design document with blank gray pages. Any ideas of what I could be doing wrong? I am using a trial version of IndesignServer CS5.

      string iddFilePath = @”c:test.indd”;

      string pdfFilePath = @”c:test.pdf”;

      var myApp = (InDesignServer.Application)(System.Runtime.InteropServices.Marshal.BindToMoniker(configName));

      var myDoc = myApp.Documents.Add();

      var myPage = (InDesignServer.Page)(myDoc.Pages.FirstItem());

      myApp.PDFPlacePreferences.PDFCrop = idPDFCrop.idCropMedia;

      int counter = 1;
      int firstPage = -1;
      while (true)
      {
      if (counter > 1)
      myDoc.Pages.Add();

      myApp.PDFPlacePreferences.PageNumber = counter;

      var pdfPage = myDoc.Pages[-1].Place(pdfFilePath, new int[] { 0, 0 });
      pdfPage = pdfPage.Item[1];

      if (counter == 1)
      {
      firstPage = pdfPage.PDFAttributes.PageNumber;
      }
      else if (pdfPage.PDFAttributes.PageNumber == firstPage)
      {
      myDoc.Pages[-1].Delete();
      break;
      }

      counter++;
      }
      myDoc = (InDesignServer.Document)(myDoc.Save(iddFilePath, false, string.Empty, false));
      myDoc.Close(InDesignServer.idSaveOptions.idNo,iddFilePath, string.Empty, false);

    • #57617
      Anonymous
      Inactive

      If I create an Indesign document using the client object in this manner, it works:

      System.Type type = System.Type.GetTypeFromProgID(“InDesign.Application.CS5″, true);
      dynamic inDesignClient = System.Activator.CreateInstance(type, true);

      var myDoc = (InDesignServer.Document)inDesignClient.Documents.Add();

      // import pdf into doc …

      But if I use the server object, then the entire document is gray:

      System.Type type = System.Type.GetTypeFromProgID(“InDesignServer.Application.CS5″, true);
      dynamic inDesignClient = System.Activator.CreateInstance(type, true);

      var myDoc = (InDesignServer.Document)inDesignClient.Documents.Add();

      // import pdf into doc …

      The problem is, I want to do it through the server, not the client.

      Any thoughts?

    • #57635
      Anonymous
      Inactive

      I have the same problem if I use a SOAP call to the server to run the script

      Code call to soap service:

      IDS.ServicePortTypeClient client = new ServicePortTypeClient();
      string errorString;
      IDS.Data scriptResult;
      IDS.RunScriptParameters runScriptParameters = new RunScriptParameters
      {
      scriptLanguage = “visual basic”,
      scriptFile =
      @”C:placemultipagepdf.vbs”
      };

      int result = client.RunScript(runScriptParameters, out errorString, out scriptResult);

      and here is the script

      Rem PlaceMultipagePDF.vbs
      Rem An InDesignServer CS5 script
      Rem Places all of the pages of a multi-page PDF.

      Function main()
      Set myInDesign = CreateObject(“InDesignServer.Application.CS5”)
      myFileName = “C:UserstdycavinuDesktopDevelopmentDocumentsPNI AccountOrder API Guide.doc.pdf”

      myNewDocument = True
      Set myDocument = myInDesign.Documents.Add
      Set myPage = myDocument.Pages.Item(1)
      myPlacePDF myInDesign, myDocument, myPage, myFileName
      myInDesign.Documents.Item(1).Save(myFileName & “.indd”)
      End function

      Function myPlacePDF(myInDesign, myDocument, myPage, myFileName)
      Rem idPDFCrop.idCropMedia = 1131573325
      myInDesign.PDFPlacePreferences.PDFCrop = 1131573325
      myCounter = 1
      myBreak = False
      Do While myBreak = False
      If myCounter > 1 Then
      myDocument.Pages.Add
      End If
      myInDesign.PDFPlacePreferences.PageNumber = myCounter
      Set myPDFPage = myDocument.Pages.Item(-1).Place(myFileName, Array(0, 0))
      Set myPDFPage = myPDFPage.Item(1)
      If myCounter = 1 Then
      myFirstPage = myPDFPage.PDFAttributes.PageNumber
      Else
      If myPDFPage.PDFAttributes.PageNumber = myFirstPage Then
      myDocument.Pages.Item(-1).Delete
      myBreak = True
      End If
      End If
      myCounter = myCounter + 1
      Loop
      End Function

Viewing 2 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads