2017-02-09 2 views
-1

Comment imprimer plusieurs pages à l'aide du canevas d'impression. Avec lineto et textout pour produire la sortie sur la toile? La toile fonctionne bien sur une seule page. Ceci utilise l'impression normale pour la première page. Puis utilisé copyrect à la toile de l'imprimante et a publié une nouvelle page, mais les pages suivantes sont vides. J'ai vu dans une question ils parlaient d'un PrintPage je n'ai pas vu une fonction ou une méthode comme ceci avec Lazarus. Voici un code que je ne sais pas si c'est utile.Impression de plusieurs pages avec des fonctions de canevas LineTo et Textout

  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; 
+0

Créez un MCVE qui imprime un seul mot de texte, lance une nouvelle page et recommence. Nous ne voulons pas patauger tout ce code. Simplifier. –

Répondre

0

Dans Lazarus, la classe TPrinter possède une méthode appelée NewPage. Dans Lazarus, cliquez sur une déclaration TPrinter pour voir toutes les méthodes disponibles dans le code source.

+0

J'ai obtenu le MCVE à travailler en dessinant quatre rectangles sur la carte de bits. J'ai mis un dessin à l'intérieur des rectangles tels que des lignes, des carrés et des triangles. Ensuite, j'ai été en mesure de dessiner chaque rectangle sur une page séparée avec un copyrect sur la toile de l'imprimante en publiant une nouvelle page après la première page. J'ai changé le programme original et découvre que je crée et lance le bitmap pour définir la hauteur et la largeur de la toile. Je l'ai maintenant imprimant un rectangle noir sur chaque page. Je vais devoir tester le changement des pinceaux et/ou des stylos. Mais sachez que j'ai créé un nouveau problème quand il crée une image. suite ... –

+0

L'image imprimable est 5 fois la taille de l'image originale. Si ça devient très gros, j'obtiens des erreurs # 203. Merci pour votre soutien juus et David Heffernan –