exampleRectanglesAndImages
   "Show the functionality from the PDFPrinter: This method shows
    the print styles for rectangles and images"
   "PDFPrinter exampleRectanglesAndImages"

   | printer style bgArea |
   printer := Printer startPrintJobNamed: 'RectanglesAndImages.pdf'.
   printer printBlock: [
      | gc device left top styles dash font title image mask depth24Image |
      device := printer graphicsDevice.
      gc := printer graphicsContext.

      "Define the font and style for the sub titles"
      (font := FontDescription new pixelSize: 12)
            family: 'helvetica';
            boldness: 0.5;
            italic: false.
      style := TextAttributes defaultFontQuery: font copy.
      gc
         capStyle: 1;
         joinStyle: 1;
         lineWidth: 2;
         paint: ColorValue black.

      "Print the title line"
      (font := FontDescription new pixelSize: 18)
            family: 'helvetica';
            boldness: 1.0;
            italic: false.
      title := 'PDFPrinter functionality (Rectangles and Images)'.
      (ComposedText
         withText: title
         style: (TextAttributes defaultFontQuery: font copy))
            newGraphicsDevice: device;
            displayOn: gc at: 60 @ 20.

      "Print three rectangles in a row with different file and border styles"
      left := 20.
      top := 50.
      (ComposedText withText: 'Bordered' style: style)
            newGraphicsDevice: device;
            displayOn: gc at: left@top.
      gc paint: ColorValue red.
      gc displayRectangularBorder: (left@(top + 20) extent: 100@50).
      gc paint: ColorValue black.

      left := left + 160.
      (ComposedText withText: 'Filled' style: style)
            newGraphicsDevice: device;
            displayOn: gc at: left@top.
      gc paint: ColorValue red.
      gc displayRectangle: (left@(top + 20) extent: 100@50).
      gc paint: ColorValue black.

      left := left + 160.
      (ComposedText withText: 'Filled and Bordered' style: style)
            newGraphicsDevice: device;
            displayOn: gc at: left@top.
      gc paint: ColorValue red.
      gc displayRectangle: (left@(top + 20) extent: 100@50).
      gc paint: ColorValue darkRed.
      gc displayRectangularBorder: (left@(top + 20) extent: 100@50).
      gc paint: ColorValue black.

      "Print three rectangles in a row with different join styles"
      top := 140.
      left := 20.
      gc lineWidth: 8; capStyle: 1.
      styles := #('Mitter Joint' 'Round Join' 'Bevel Join').
      1 to: 3 do: [:join |
         (ComposedText
            withText: ('Join Style: ' , (styles at: join))
            style: style)
               newGraphicsDevice: device;
               displayOn: gc at: left@top.

         gc joinStyle: join.
         gc paint: ColorValue red.
         gc displayRectangularBorder: ((left + 4)@(top + 24) extent: 100@50).
         gc paint: ColorValue black.
         left := left + 160].

      "Print three rectangles in a row with different dash patterns"
      top := 240.
      left := 20.
      styles := #('1' '3 7' '8 7 2 7').
      dash := (Array
            with: self dashPattern1
            with: self dashPattern37
            with: self dashPattern8727).
      gc capStyle: 1; joinStyle: 1; lineWidth: 1.
      1 to: 3 do: [:index |
         (ComposedText
            withText: ('Dash Pattern: ' , (styles at: index))
            style: style)
               newGraphicsDevice: device;
               displayOn: gc at: left@top.

         gc paint: (dash at: index).
         gc displayRectangularBorder: (left@(top + 20) extent: 100@50).
         gc paint: ColorValue black.
         left := left + 160].

      "This simple statement prints a color image"
      self depth24Image displayOn: gc at: 20@340.

      "Here we print an icon, its mask and the masked icon onto a grey background"
      top := 660.
      left := 30.
      image := ListIconLibrary visualFor: #folder.
      mask := image shape image.
      depth24Image := image figure image convertToPalette: FixedPalette rgb8Bit.

      bgArea := (left - 10)@(top + 20) corner: (gc clippingBounds width - 20)@(top + 60).
      gc paint: ColorValue lightGray.
      gc displayRectangle: bgArea.
      gc paint: ColorValue black.

      (ComposedText withText: 'Image' style: style)
         newGraphicsDevice: device;
         displayOn: gc at: left@top.
      depth24Image displayOn: gc at: left@(top + 30).

      left := left + 160.
      (ComposedText withText: 'Mask' style: style)
         newGraphicsDevice: device;
         displayOn: gc at: left@top.
      mask displayOn: gc at: left@(top + 30).

      left := left + 160.
      (ComposedText withText: 'Opaque Image' style: style)
         newGraphicsDevice: device;
         displayOn: gc at: left@top.
      image displayOn: gc at: left@(top + 30)]