0 Replies Latest reply on Feb 26, 2009 1:13 PM by (JIm_C_Thompson)

    Problem adding image to document

      I am adding a Rectangle to a document and placing a JPEG file. The result opens in InDesign and shows a rectangle that is filled with dark grey. The links palette shows the jpeg file and notes it to be current. If I re-link the graphic it shows correctly. What do I need to do so the image shows after the doc is created?

      private void IndCreateFrame(double xc, double yc, double w, double d, String Layername, String frameType, long frameColCount, String imagePath)
      {
      Rectangle newFrame = null;
      ObjectStyle myObjectStyle = null;
      VariableType strokeType = new VariableType();
      strokeType.asString("Solid");
      Unit strokeWeight = new Unit();
      strokeWeight.asDouble(2.5);

      try
      {
      int oldH = myApp.getViewPreferences().getHorizontalMeasurementUnits();
      int oldV = myApp.getViewPreferences().getVerticalMeasurementUnits();
      myApp.getViewPreferences().setHorizontalMeasurementUnits(com.adobe.ids.enums.kMeasurement UnitsPoints.value);
      myApp.getViewPreferences().setVerticalMeasurementUnits(com.adobe.ids.enums.kMeasurementUn itsPoints.value);

      PDFPlacePreference myPdfPrefs = myApp.getPDFPlacePreferences();
      myPdfPrefs.setPDFCrop(com.adobe.ids.enums.kPDFCropCropMedia.value);

      newFrame = myPage.addRectangle(OptArg.noLayer(),
      OptArg.makeLocationOptionsEnum(kLocationOptionsUnknown.value),
      OptArg.noVariableType());

      newFrame.setContentType(com.adobe.ids.enums.kContentTypeGraphicType.value);
      System.out.println("Place file " + imagePath);

      newFrame.setContentType(com.adobe.ids.enums.kContentTypeGraphicType.value);

      VariableType[] placedItems = newFrame.place(imagePath);

      Graphic[] myGraphics = newFrame.getAllChildGraphics();

      System.err.println("GRAPHIC COUNT - " + myGraphics.length);
      System.out.println("Set frame bounds to " + yc + ", " + xc + ", " + (yc + d) + ", " + (xc + w));
      newFrame.setGeometricBounds(UnitUtils.createDouble(new double[]{
      yc, xc, yc + d, xc + w}));
      boolean needStyle = true;
      try
      {
      myObjectStyle = myDoc.getNamedChildObjectStyle("GraphicFrame");
      if (myObjectStyle != null) needStyle = false;
      }
      catch (IdsException idEx)
      {
      System.err.println("We got an exception looking for the GraphicFrame Object Style.");
      }
      if (needStyle == true)
      {
      myObjectStyle = myDoc.addObjectStyle();
      myObjectStyle.setName("GraphicFrame");
      System.err.println("Current enable stroke value is " + myObjectStyle.getEnableStroke());
      }
      myObjectStyle.setEnableStroke(true);
      myObjectStyle.setStrokeWeight(strokeWeight);
      myObjectStyle.setStrokeType(strokeType);
      try
      {
      newFrame.applyObjectStyle(myObjectStyle, new OptBoolean(false, false), new OptBoolean(false, false));
      }
      catch (Exception ex)
      {
      ex.printStackTrace();
      }
      newFrame.fit(kFitOptionsContentToFrame.value);
      myApp.getViewPreferences().setHorizontalMeasurementUnits(oldH); myApp.getViewPreferences().setVerticalMeasurementUnits(oldV);
      }
      catch (Exception ex)
      {
      ex.printStackTrace();
      }
      }