The task is to demonstrate the creation of a series of 1 point wide vertical pinstripes with a sufficient number of pinstripes to span the entire width of the printed page (except for the last pinstripe). The pinstripes should alternate one point white, one point black. (Where the printer does not support producing graphics in terms of points, pixels may be substituted in this task.)

After the first inch of printing, we switch to a wider 2 point wide vertical pinstripe pattern. alternating two points white, two points black. We then switch to 3 points wide for the next inch, and then 4 points wide, etc. This trend continues for the entire length of the page (or for 12 inches of run length in the case of a printer using continuous roll stationery). After printing the test pattern the page is ejected (or the test pattern is rolled clear of the printer enclosure, in the case of continuous roll printers).

Note that it is an acceptable solution to use the smallest marks that the language provides, rather than working at native printer resolution, where this is not achievable from within the language.

Optionally, on systems where the printer resolution cannot be determined, it is permissible to prompt the user for printer resolution, and to calculate point size based on user input, enabling fractional point sizes to be used.

with Ada.Text_IO;
 
with PDF_Out;
 
procedure Pinstripe_Printer
is
   use PDF_Out;
 
   package Point_IO
   is new Ada.Text_Io.Float_IO (Real);
 
   procedure Pinstripe (Doc          : in out Pdf_Out_File;
                        Line_Width   : Real;
                        Line_Height  : Real;
                        Screen_Width : Real;
                        Y            : Real)
   is
      Count  : constant Natural
        := Natural (Real'Floor (Screen_Width / (2.0 * Line_Width)));
      Corner      : constant Point := (Doc.Left_Margin, Doc.Bottom_Margin);
      Corner_Box  : constant Point := Corner     + (10.0, 10.0);
      Corner_Text : constant Point := Corner_Box + (10.0, 10.0);
      Light_Gray  : constant Color_Type := (0.9, 0.9, 0.9);
      Image : String (1 .. 4);
   begin
      --  Pinstripes
      Doc.Color (Black);
      for A in 0 .. Count loop
         Doc.Draw (What => Corner +
                     Rectangle'(X_Min  => 2.0 * Real (A) * Line_Width,
                                Y_Min  => Y,
                                Width  => Line_Width,
                                Height => Line_Height),
                   Rendering => Fill);
      end loop;
 
      --  Box
      Doc.Stroking_Color (Black);
      Doc.Color (Light_Gray);
      Doc.Line_Width (3.0);
      Doc.Draw (What => Corner_Box + (0.0, Y, 120.0, 26.0),
                Rendering => Fill_Then_Stroke);
      --  Text
      Doc.Color (Black);
      Doc.Text_Rendering_Mode (Fill);
      Point_Io.Put (Image, Line_Width, Aft => 1, Exp => 0);
      Doc.Put_XY (Corner_Text.X, Corner_Text.Y + Y,
                  Image & " point pinstripe");
   end Pinstripe;
 
   Doc : PDF_Out_File;
begin
   Doc.Create ("pinstripe.pdf");
   Doc.Page_Setup (A4_Portrait);
   Doc.Margins (Margins_Type'(Left   => Cm_2_5,
                              others => One_cm));
   declare
      Width  : constant Real
        := A4_Portrait.Width - Doc.Left_Margin - Doc.Right_Margin;
      Height : constant Real
        := A4_Portrait.Height - Doc.Top_Margin - Doc.Bottom_Margin;
   begin
      Pinstripe (Doc, 1.0, One_Inch, Width, Height - 1.0 * One_Inch);
      Pinstripe (Doc, 2.0, One_Inch, Width, Height - 2.0 * One_Inch);
      Pinstripe (Doc, 3.0, One_Inch, Width, Height - 3.0 * One_Inch);
      Pinstripe (Doc, 4.0, One_inch, Width, Height - 4.0 * One_Inch);
      Pinstripe (Doc, 5.0, One_Inch, Width, Height - 5.0 * One_Inch);
      Pinstripe (Doc, 6.0, One_Inch, Width, Height - 6.0 * One_Inch);
      Pinstripe (Doc, 7.0, One_Inch, Width, Height - 7.0 * One_Inch);
      Pinstripe (Doc, 8.0, One_Inch, Width, Height - 8.0 * One_Inch);
      Pinstripe (Doc, 9.0, One_Inch, Width, Height - 9.0 * One_Inch);
      Pinstripe (Doc, 10.0, One_Inch, Width, Height - 10.0 * One_Inch);
      Pinstripe (Doc, 11.0, One_Inch, Width, Height - 11.0 * One_Inch);
   end;
   Doc.Close;
end Pinstripe_Printer;