/// <summary>
        /// Generate lines, boxes, watermark and default text of a single voter card.
        /// </summary>
        /// <param name="page">The page containing the card.</param>
        /// <param name="pdf">The pdf containing the page.</param>
        /// <param name="xO">The horizontal offset of the card in points.</param>
        /// <param name="yO">The vertical offset of the card in points.</param>
        private static void GenerateCard(Page page, PDF pdf, double xO, double yO)
        {
            // Add watermark.
            var font = new Font(pdf, CoreFont.HELVETICA_BOLD);
            font.SetSize(55);
            var t = new TextLine(font, "FAKE VALGKORT");
            var lightBlue = new[] { 0.647, 0.812, 0.957 };
            t.SetColor(lightBlue);
            t.SetPosition(xO + 20 * U, yO + 50 * U);
            t.DrawOn(page);

            // Add 'Afstemningssted' box.
            var b = new Box(xO + 6 * U, yO + 20 * U, 80 * U, 22 * U);
            b.DrawOn(page);

            // Add 'Valgbord' box.
            b = new Box(xO + 6 * U, yO + 44.5 * U, 80 * U, 7 * U);
            b.DrawOn(page);

            // Add 'Vælgernr' box.
            b = new Box(xO + 6 * U, yO + 54 * U, 80 * U, 7 * U);
            b.DrawOn(page);

            // Add 'Afstemningstid' box.
            b = new Box(xO + 6 * U, yO + 63.5 * U, 80 * U, 7 * U);
            b.DrawOn(page);

            // Add lines.
            var l = new Line(xO + 96 * U, yO + 5 * U, xO + 96 * U, yO + 85 * U);
            l.DrawOn(page);
            l = new Line(xO + 96 * U, yO + 25 * U, xO + 205 * U, yO + 25 * U);
            l.DrawOn(page);
            l = new Line(xO + 96 * U, yO + 45 * U, xO + 205 * U, yO + 45 * U);
            l.DrawOn(page);
            l = new Line(xO + 6 * U, yO + 85 * U, xO + 205 * U, yO + 85 * U);
            l.DrawOn(page);

            // Add default text.
            font = new Font(pdf, CoreFont.HELVETICA);
            font.SetSize(7);
            t = new TextLine(font, "Afstemningssted:");
            t.SetPosition(xO + 7 * U, yO + 23 * U);
            t.DrawOn(page);
            t = new TextLine(font, "Vælgernr.:");
            t.SetPosition(xO + 7 * U, yO + 58 * U);
            t.DrawOn(page);
            t = new TextLine(font, "Afstemningstid:");
            t.SetPosition(xO + 7 * U, yO + 68 * U);
            t.DrawOn(page);
            t = new TextLine(font, "Afsender:");
            t.SetPosition(xO + 98 * U, yO + 29 * U);
            t.DrawOn(page);
            t = new TextLine(font, "Modtager:");
            t.SetPosition(xO + 98 * U, yO + 49 * U);
            t.DrawOn(page);

            font = new Font(pdf, CoreFont.HELVETICA);
            font.SetSize(9);
            t = new TextLine(font, "Folketingsvalg");
            t.SetPosition(xO + 7 * U, yO + 10 * U);
            t.DrawOn(page);
            t = new TextLine(font, "20. november 2001");
            t.SetPosition(xO + 7 * U, yO + 14 * U);
            t.DrawOn(page);
            t = new TextLine(font, "Valgbord:");
            t.SetPosition(xO + 7 * U, yO + 49 * U);
            t.DrawOn(page);

            font = new Font(pdf, CoreFont.HELVETICA_OBLIQUE);
            font.SetSize(7);
            t = new TextLine(font, "Medbring kortet ved afstemningen");
            t.SetPosition(xO + 6.5 * U, yO + 18.5 * U);
            t.DrawOn(page);
        }
Exemple #2
0
 /**
  *  Places this line in the specified box at position (0.0f, 0.0f).
  *
  *  @param box the specified box.
  *  @return this Line object.
  */
 public Line PlaceIn(Box box)
 {
     PlaceIn(box, 0.0f, 0.0f);
     return this;
 }
Exemple #3
0
 /**
  *  Places this line in the specified box at position (0.0f, 0.0f).
  *
  *  @param box the specified box.
  *  @return this Line object.
  */
 public Line PlaceIn(Box box)
 {
     PlaceIn(box, 0.0f, 0.0f);
     return(this);
 }
Exemple #4
0
 /**
  *  Places this path in the specified box at position (0.0, 0.0).
  *
  *  @param box the specified box.
  */
 public void PlaceIn(Box box)
 {
     PlaceIn(box, 0.0f, 0.0f);
 }
Exemple #5
0
 /**
  *  Places this text line in the specified box at position (0.0, 0.0).
  *
  *  @param box the specified box.
  *  @return this TextLine.
  */
 public TextLine PlaceIn(Box box)
 {
     PlaceIn(box, 0.0, 0.0);
     return this;
 }
 private void DrawBackground(
     Page page,
     double x,
     double y,
     double cell_w,
     double cell_h)
 {
     page.SetBrushColor(brushColor[0], brushColor[1], brushColor[2]);
     Box box = new Box(x, y, cell_w, cell_h);
     box.SetColor(bgColor);
     box.SetFillShape(true);
     box.DrawOn(page);
 }
Exemple #7
0
 /**
  *  Places this path in the specified box at position (0.0, 0.0).
  *
  *  @param box the specified box.
  */
 public void PlaceIn(Box box)
 {
     PlaceIn(box, 0.0f, 0.0f);
 }
 public void PlaceIn(Box box)
 {
     PlaceIn(box, 0.0, 0.0);
 }
 public void PlaceIn(Box box)
 {
     PlaceIn(box, 0.0, 0.0);
 }
Exemple #10
0
        public float[] DrawOn(Page page)
        {
            if (numberOfRows == 0) {
            return new float[] { x, y };
            }

            float boxHeight = rowHeight*numberOfRows;
            Box box = new Box();
            box.SetLocation(x, y);
            box.SetSize(rowLength, boxHeight);
            box.DrawOn(page);

            float field_y = 0f;
            int row_span = 1;
            float row_y = 0;
            foreach (Field field in fields) {
            if (field.x == 0f) {
                row_y += row_span*rowHeight;
                row_span = field.values.Length;
            }
            field_y = row_y;
            for (int i = 0; i < field.values.Length; i++) {
                Font font = (i == 0) ? f1 : f2;
                float fontSize = (i == 0) ? labelFontSize : valueFontSize;
                int color = (i == 0) ? labelColor : valueColor;
                new TextLine(font, field.values[i])
                        .SetFontSize(fontSize)
                        .SetColor(color)
                        .PlaceIn(box, field.x + f1.GetDescent(), field_y - font.GetDescent())
                        .SetAltDescription((i == 0) ? field.altDescription[i] : (field.altDescription[i] + ","))
                        .SetActualText((i == 0) ? field.actualText[i] : (field.actualText[i] + ","))
                        .DrawOn(page);
                endOfLinePoints.Add(new float[] {
                        field.x + f1.GetDescent() + font.StringWidth(field.values[i]),
                        field_y - font.GetDescent(),
                });
                if (i == (field.values.Length - 1)) {
                    new Line(0f, 0f, rowLength, 0f)
                            .PlaceIn(box, 0f, field_y)
                            .DrawOn(page);
                    if (field.x != 0f) {
                        new Line(0f, -(field.values.Length-1)*rowHeight, 0f, 0f)
                                .PlaceIn(box, field.x, field_y)
                                .DrawOn(page);
                    }
                }
                field_y += rowHeight;
            }
            }

            return new float[] { x + rowLength, y + boxHeight };
        }
 public void PlaceIn(Box box)
 {
     box_x = box.x;
     box_y = box.y;
 }
Exemple #12
0
 public void PlaceIn(
     Box box,
     double x_offset,
     double y_offset)
 {
     this.x = box.x + x_offset;
     this.y = box.y + y_offset;
 }
Exemple #13
0
 /**
  *  Places this box in the another box.
  *
  *  @param box the other box.
  *  @param x_offset the x offset from the top left corner of the box.
  *  @param y_offset the y offset from the top left corner of the box.
  */
 public void PlaceIn(
     Box box,
     float x_offset,
     float y_offset)
 {
     this.x = box.x + x_offset;
     this.y = box.y + y_offset;
 }
Exemple #14
0
 /**
  *  Places this line in the specified box.
  *
  *  @param box the specified box.
  *  @param x_offset the x offset from the top left corner of the box.
  *  @param y_offset the y offset from the top left corner of the box.
  *  @return this Line object.
  */
 public Line PlaceIn(
     Box box,
     double x_offset,
     double y_offset)
 {
     return PlaceIn(box, (float) x_offset, (float) y_offset);
 }
Exemple #15
0
 /**
  *  Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
  *
  *  @param box the specified box.
  *  @param x_offset the x_offset.
  *  @param y_offset the y_offset.
  */
 public void PlaceIn(
     Box box,
     double x_offset,
     double y_offset)
 {
     PlaceIn(box, (float) x_offset, (float) y_offset);
 }
Exemple #16
0
 /**
  *  Places this line in the specified box.
  *
  *  @param box the specified box.
  *  @param x_offset the x offset from the top left corner of the box.
  *  @param y_offset the y offset from the top left corner of the box.
  *  @return this Line object.
  */
 public Line PlaceIn(
     Box box,
     float x_offset,
     float y_offset)
 {
     box_x = box.x + x_offset;
     box_y = box.y + y_offset;
     return this;
 }
Exemple #17
0
 /**
  *  Places the path inside the spacified box at coordinates (x_offset, y_offset) of the top left corner.
  *
  *  @param box the specified box.
  *  @param x_offset the x_offset.
  *  @param y_offset the y_offset.
  */
 public void PlaceIn(
     Box box,
     float x_offset,
     float y_offset)
 {
     box_x = box.x + x_offset;
     box_y = box.y + y_offset;
 }
Exemple #18
0
 public void PlaceIn(
     Box box,
     double x_offset,
     double y_offset)
 {
     box_x = box.x + x_offset;
     box_y = box.y + y_offset;
 }
Exemple #19
0
 /**
  *  Places this text line in the specified box at position (0.0, 0.0).
  *
  *  @param box the specified box.
  *  @return this TextLine.
  */
 public TextLine PlaceIn(Box box)
 {
     PlaceIn(box, 0.0, 0.0);
     return(this);
 }