##### Example 3: TestDesignEditInvoice.java

TestDesignEditInvoice.java shows how to modify a report using the methods of the Designer API. It demonstrates how to change the image in the report invoice1.

Here is an explanation of how TestDesignEditInvoice.java works with the methods provided by the Designer API.

- Creating an instance
  desg = new Designer(path, cat);

  The constructor of Designer has two parameters: path and name. They are respectively path and name of the catalog with which the report will be created.

- Setting log
  desg.setLog(new FileOutputStream(log), "8859_1");

  The output stream log points the path and file in which to write log messages. Parameter "8859_1" is the encoding for the messages.

- Opening an existing report
  report = desg.open(name);

  This method opens an existing report corresponding to the name specified, and returns the handle of the report.

- Getting handles
  handle = desg.getHandles(report, Designer.IMAGE)[0];

  This allows the handle of the object to be modified.

- Changing the property value

      // change the image "coffee.gif" to "sky.gif"
      desg.set(handle, "PictureName", "sky.gif");
      // change the image position
      desg.set(handle, "X", 2.24f);
      // change the image width
      desg.set(handle, "Width", 4.76f);

- Exiting and closing all reports
  desg.exit();
- Compiling and running the sample program
  To compile and run the sample program, you should add report.jar, sac.jar and JREngine.jar with their path into the class path. And it is assumed that TestCatalogAPI.java in `C:\JReport\Designer\help\designer\samples` has been run first to generate a catalog file Tutorial.cat in `C:\JReport\Designer\Demo\Reports\APITutorial`.

  For example, you can use the following command to compile the sample program:

      C:\JReport\Designer\help\designer\samples>javac
      -classpath C:\JReport\Designer\lib\report.jar;C:\JReport\Designer\lib\sac.jar;
      C:\JReport\Designer\lib\JREngine.jar;
      TestDesignEditInvoice.java

  When you run the sample programs, you should provide two or three parameters. If you want to use two parameters, they should be catalog path and catalog name. The command line should be:

      C:\JReport\Designer\help\designer\samples>java -Dreporthome="C:\JReport\Designer"
      -classpath "C:\JReport\Designer\lib\jrengine.jar;C:\JReport\Designer\lib\sac.jar;
      C:\JReport\Designer\lib\report.jar;
      C:\JReport\Designer\lib\log4j-1.2.8.jar;C:\JReport\Designer\lib\hsqldb.jar;"
      TestDesignEditInvoice C:\JReport\Designer\Demo\Reports\APITutorial Tutorial.cat

  If you want to use three parameters, they should be catalog path, catalog name and log file with a full path name. The command line should be:

      C:\JReport\Designer\help\designer\samples>java -Dreporthome="C:\JReport\Designer"
      -classpath "C:\JReport\Designer\lib\jrengine.jar;C:\JReport\Designer\lib\sac.jar;
      C:\JReport\Designer\lib\report.jar;
      C:\JReport\Designer\lib\log4j-1.2.8.jar;C:\JReport\Designer\lib\hsqldb.jar;"
      TestDesignEditInvoice C:\JReport\Designer\Demo\Reports\APITutorial Tutorial.cat
      C:\test\log.txt

  Here, it is assumed that JReport Designer has been installed to `C:\JReport\Designer`, and that the directory that is current when you execute these commands is `C:\JReport\Designer\help\designer\samples` (location of the sample programs). After running the program, you will find a modified file invoice1.cls in `C:\JReport\Designer\Demo\Reports\APITutorial`.