使用画布功能LineTo和Textout

时间:2017-02-09 07:26:28

标签: canvas printing lazarus

如何使用打印画布打印多个页面。使用lineto和textout在画布上生成输出?画布在单个页面上工作正常。这是使用第一页的正常打印。然后使用copyrect到打印机画布并发布新页面,但后续页面为空白。我在一个问题中看到他们正在谈论一个PrintPage,我没有看到Lazarus这样的功能或方法。这是一些我不知道它是否有用的代码。

          kBracketTree: with TestTableForSpeciesData, Printer.Canvas do
      begin
        intCPLngth := Origin.ttoBracket.Height * 5;
        intCPWdth := Origin.ttoBracket.Width * 5;
        if imgPrintView.Canvas = nil then
          imgPrintView.Canvas.Create;
        imgPrintView.Height := intCPLngth; // * 6 div 5;
        imgPrintView.Width := intCPWdth; // * 6 div 5;
        intVPages := intCPLngth div intHeight + 1;
        intHPages := intCPWdth div intWidth + 1;
        DrawScale(dblScale);
        DrawBracket(HomeVrtcl);
        DrawBracketLabel(Species[NodeCount].VrtclPosition, Species[NodeCount].EndSegment);
        DrawBracketLabel(Species[NodeCount - 1].VrtclPosition, Species[NodeCount - 1].EndSegment);
        intNdLvl := 1;
        while boolMoreNodeLevels(intNdLvl) do
        begin
          for inx := 0 to NodeCount - 2 do
            if Species[inx].NodeLevel = intNdLvl then
              DrawBracketLabel(Species[inx].VrtclPosition, Species[inx].EndSegment);
          inc(intNdLvl);
        end;
        if boolBootStrap then
          for inx := SpeciesCount to NodeCount do
            DrawBootStrapLabel(Species[inx].VrtclPosition, BSPercent[inx - SpeciesCount], 5, 5, 55);
        if (intVPages > 1) or (intHPages > 1) then
        begin
          if intVPages > 1 then
            if intHPages = 1 then
            begin
              intVStart := 2;
              intHStart := 1;
            end
            else
            begin
              intVStart := 1;
              intHStart := 2;
            end
          else
          begin
            intVStart := 1;
            intHStart := 2;
          end;
          for iny := intVStart to intVPages do
          begin
            Pen.Color := clBlack;
            Brush.Style := bsSolid;
            Brush.Color := clWhite;
            Clear;
            with rctPrnt do
            begin
              Left := 0;
              Top := 0;
              if intCPLngth > intHeight * iny then
                Bottom := intHeight - 1
              else
                Bottom := intCPLngth - intHeight * (iny - 1) - 1;
            end;
            with rctSlctd do
            begin
              Top := intHeight * (iny - 1);
              if intCPLngth > intHeight * iny then
                Bottom := intHeight * iny - 1
              else
                Bottom := intCPLngth;
            end;
            for inx := intHStart to intHPages do
            begin
              NewPage;
              with rctPrnt do
                if intCPWdth > intWidth * inx then
                  Right := intWidth - 1
                else
                  Right := intCPWdth - intWidth * (inx - 1) - 1;
              with rctSlctd do
              begin
                Left := intWidth * (inx - 1);
                if intCPWdth > intWidth * inx then
                  Right := intWidth * inx - 1
                else
                  Right := intCPWdth - 1;
              end;
              Canvas.Rectangle(0, 0, intWidth - 1, intHeight - 1);
              Canvas.CopyRect(rctPrnt, imgPrintView.Canvas, rctSlctd);
              Canvas.Refresh;
            end;
            intHStart := 1;
          end;
        end;

1 个答案:

答案 0 :(得分:0)

在Lazarus中,TPrinter类有一个名为NewPage的方法。在Lazarus中,按住Ctrl键单击TPrinter声明以查看源代码中可用的所有方法。