##### Example 3: TestDesignEditInvoice.java

TestDesignEditInvoice.java in `<insatll_root>\help\samples\APIDesign` shows how to modify a report using the methods of the Design API. It demonstrates how to change the image in the report TestInvoice.cls.

Here is an explanation of how TestDesignEditInvoice.java works with the methods provided by the Design 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, -1)[0];`

  This allows the handle of the object to be modified.

- Changing the property value

      // change the image "coffee.gif" to "CoffeeLogo.gif"
      desg.set(handle, "PictureName", "CoffeeLogo.gif");
      // change the image position
      desg.set(handle, "X", 4.67f);
      // change the image width and height
      desg.set(handle, "Width", 1.70f);
      desg.set(handle, "Height", 0.81f);

- 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, log4j-1.2.8.jar and JREngine.jar with their path into the class path.

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

  `C:\JReport\Designer\help\samples\APIDesign>javac -classpath "C:\JReport\Designer\lib\report.jar;C:\JReport\Designer\lib\sac.jar;C:\JReport\Designer\lib\JREngine.jar;C:\JReport\Designer\lib\log4j-1.2.8.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\samples\APIDesign>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 -catalog=JinfonetGourmetJava.cat -report=TestInvoice.cls`

  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\samples\APIDesign>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 -path=C:\JReport\Designer\Demo\Reports\TutorialReports -catalog=JinfonetGourmetJava.cat -report=TestInvoice.cls -log=C:\JReport\Designer\logs\design.log`

  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\samples\APiDesign` (location of the sample programs). After running the program, you will find a modified file TestInvoice.cls in `C:\JReport\Designer\Demo\Reports\TutorialReports`.