def build_total
      @pdf.move_down(25)

      items = []
      items << ["#{@labels[:subtotal]}:#{build_sublabel_for_total_table(:subtotal)}", @document.subtotal] \
        unless @document.subtotal.empty?
      items << ["#{@labels[:tax]}:#{build_sublabel_for_total_table(:tax)}", @document.tax] \
        unless @document.tax.empty?
      items << ["#{@labels[:tax2]}:#{build_sublabel_for_total_table(:tax2)}", @document.tax2] \
        unless @document.tax2.empty?
      items << ["#{@labels[:tax3]}:#{build_sublabel_for_total_table(:tax3)}", @document.tax3] \
        unless @document.tax3.empty?

      width = [
        "#{@labels[:subtotal]}#{@document.subtotal}".size,
        "#{@labels[:tax]}#{@document.tax}".size,
        "#{@labels[:tax2]}#{@document.tax2}".size,
        "#{@labels[:tax3]}#{@document.tax3}".size
      ].max * 8

      styles = {
        border_width: 0,
        align: {
          0 => :right,
          1 => :left
        }
      }

      @pdf.span(x(width), position: :right) do
        @pdf.table(items, styles) unless items.empty?
      end

      @pdf.move_down(15)

      unless @document.total.empty?
        @pdf.text(
          "#{@labels[:total]}:   #{@document.total}",
          size: 16,
          align: :right,
          style: :bold
        )

        @pdf.move_down(5)

        if used? @labels[:sublabels][:total]
          @pdf.text(
            "#{@labels[:sublabels][:total]}:   #{@document.total}",
            size: 12,
            align: :right
          )
        end
      end
    end
def build_total
      @pdf.move_down(25)

      items = []
      items << ["#{@labels[:subtotal]}:#{build_sublabel_for_total_table(:subtotal)}", @document.subtotal] \
        unless @document.subtotal.empty?
      items << ["#{@labels[:tax]}:#{build_sublabel_for_total_table(:tax)}", @document.tax] \
        unless @document.tax.empty?
      items << ["#{@labels[:tax2]}:#{build_sublabel_for_total_table(:tax2)}", @document.tax2] \
        unless @document.tax2.empty?
      items << ["#{@labels[:tax3]}:#{build_sublabel_for_total_table(:tax3)}", @document.tax3] \
        unless @document.tax3.empty?

      width = [
        "#{@labels[:subtotal]}#{@document.subtotal}".size,
        "#{@labels[:tax]}#{@document.tax}".size,
        "#{@labels[:tax2]}#{@document.tax2}".size,
        "#{@labels[:tax3]}#{@document.tax3}".size
      ].max * 8

      styles = {
        border_width: 0,
        align: {
          0 => :right,
          1 => :left
        }
      }

      @pdf.span(x(width), position: :right) do
        @pdf.table(items, styles) unless items.empty?
      end

      @pdf.move_down(15)

      unless @document.total.empty?
        @pdf.text(
          "#{@labels[:total]}:   #{@document.total}",
          size: 16,
          align: :right,
          style: :bold
        )

        @pdf.move_down(5)

        if used? @labels[:sublabels][:total]
          @pdf.text(
            "#{@labels[:sublabels][:total]}:   #{@document.total}",
            size: 12,
            align: :right
          )
        end
      end
    end
Build the following summary:

   Subtotal: 175
        Tax: 5
      Tax 2: 10
      Tax 3: 20

      Total: $ 200

 The first part is implemented as a table without borders.