![]() |
Pixel zu Height bei Drucker Problem
Moin DP
Mein Problem ist folgendes: Ich hab hier eine Mess Auswertung die ich drucken muss. Nun ist die von einer Werbeagentur optisch designed worden. Nun habe ich hier alle Schriftgrößen in pt angaben. Jetzt steht in der Delphi Hilfe folgendes: Zitat:
Delphi-Quellcode:
Bekomme ich riesen große schriften und nicht die Schriftgröße, die auf der Vorlage der Werbeagentur zu sehen ist.
with Printer.Canvas do
begin Font.Style := [fsbold]; Font.Name := 'Arial'; Font.Height := round(-12 * Font.PixelsPerInch / 72); Pen.Color := blau; Brush.Color:=blau; Font.Color := blau; Brush.Color := clwhite; TextOut(260, -440, 'Messauswertung'); Font.Height := round(-10 * Font.PixelsPerInch / 72); TextOut(260, -500, 'Name: ' + frm_messung.lb_kunde.Caption); end; Nun frage ich mich wo ist das Problem? oder steckt in meinem Coder der Fehler. Wäre über Hilfe sehr dankbar. |
AW: Pixel zu Height bei Drucker Problem
Da fehlt noch ein bisschen Source fürs Drucken rings herum. Kannst du den mit posten? Und warum machst du dir die Arbeit die Höhe auszurechnen anstelle einfach "size" zu setzen wenn damit die Umrechnung von allein erfolgt (bzw. erfolgen soll)?
[Edit] Hast du mal im Debugger geschaut welchen Wert Font.PixelsPerInch bei dir hat? Laut meinem Quelltext kommt der Wert aus einer globalen Variablen so das er nicht mit der wirklichen Auflösung deines Canvas übereinstimmen muss. |
AW: Pixel zu Height bei Drucker Problem
ich weiss das da noch was um drucken ausenrum fehlt beigndoc und soweiter, aber hier der ganze code:
Delphi-Quellcode:
ich habs auch mit size probiert, das gleiche ergebniss
procedure TAuswertung.Btn_PrintClick(Sender: TObject);
var blau, grau, hidunkel, hihell, balken, himessung, praxis: Tcolor; P1, P2, P3: TPoint; Dreieck: Array[0..2] of TPoint; balkenrect: Trect; i, akty: Integer; begin i := 0; blau := RGB2TColor(0,89,156); grau := RGB2TColor(75,75,77); praxis := RGB2TColor(123,124,126); balken := RGB2TColor(188,189,190); himessung := RGB2TColor(240,241,241); hidunkel := RGB2TColor(217,218,219); hihell := RGB2TColor(240,241,241); PrintDialog1.MaxPage:=1; PrintDialog1.FromPage:=1; PrintDialog1.ToPage:= 1; PrintDialog1.Options:=[]; if PrintDialog1.Execute then begin Printer.Title := 'Physiofeedback Messauswertung'; Printer.BeginDoc; SetMapMode(Printer.Canvas.Handle, MM_LOMETRIC); // Printer.Canvas.Font:=Lbl_Name1.Font; // Printer.Canvas.Font.Height := 40; with Printer.Canvas do begin Font.Style := [fsbold]; Font.Name := 'Arial'; Font.Height := 50; Pen.Color := blau; Brush.Color:=blau; P1.X := 220; P1.Y := -450; P2.X := 220; P2.Y := -480; P3.X := 250; P3.Y := -465; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(230, -465, blau, fsborder); Font.Color := blau; Brush.Color := clwhite; TextOut(260, -440, 'Physiofeedback Messauswertung'); Font.Height := 40; TextOut(260, -500, 'Name: ' + frm_messung.lb_kunde.Caption); //Messbildschirm Pen.Color := balken; Brush.Color := balken; balkenrect := Rect(220, -570, 1960, -620); Rectangle(balkenrect); FillRect(balkenrect); Font.Height := 30; Textout(270, Pen.Color := blau; Brush.Color := blau; P1.X := 240; P1.Y := -580; P2.X := 240; P2.Y := -610; P3.X := 255; P3.Y := -595; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -595, blau, fsborder); Pen.Color := himessung; Brush.Color := himessung; balkenrect := Rect(220, -630, 1960, -1350); Rectangle(balkenrect); FillRect(balkenrect); frm_messung.ch_messung.PrintPartial(Rect(Point(640, 1544), Point(4540,3090))); //Messeinstelungen Pen.Color := balken; Brush.Color := balken; balkenrect := Rect(220, -1380, 1960, -1430); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := blau; Brush.Color := blau; P1.X := 240; P1.Y := -1390; P2.X := 240; P2.Y := -1420; P3.X := 255; P3.Y := -1405; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -1405, blau, fsborder); Pen.Color := hidunkel; Brush.Color := hidunkel; balkenrect := Rect(220, -1440, 550, -1680); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := hihell; Brush.Color := hihell; balkenrect := Rect(560, -1440, 1270, -1680); Rectangle(balkenrect); FillRect(balkenrect); balkenrect := Rect(1280, -1440, 1960, -1680); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := balken; Pen.Width := 3; i := 0; akty := -1505; while i < 3 do begin MoveTo(240, akty); LineTo(535, akty); MoveTo(580, akty); LineTo(1240, akty); MoveTo(1290, akty); LineTo(1950, akty); inc(i); akty := akty -60; end; //Messergebnise Pen.Color := balken; Brush.Color := balken; balkenrect := Rect(220, -1700, 1960, -1750); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := blau; Brush.Color := blau; P1.X := 240; P1.Y := -1710; P2.X := 240; P2.Y := -1740; P3.X := 255; P3.Y := -1725; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -1725, blau, fsborder); Pen.Color := hidunkel; Brush.Color := hidunkel; balkenrect := Rect(220, -1760, 550, -2330); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := hihell; Brush.Color := hihell; balkenrect := Rect(560, -1760, 1270, -2330); Rectangle(balkenrect); FillRect(balkenrect); balkenrect := Rect(1280, -1760, 1960, -2330); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := balken; Pen.Width := 3; i := 0; akty := -1810; while i < 7 do begin MoveTo(240, akty); LineTo(535, akty); MoveTo(580, akty); LineTo(1240, akty); MoveTo(1290, akty); LineTo(1950, akty); inc(i); akty := akty -60; end; //Legende Pen.Color := balken; Brush.Color := balken; balkenrect := Rect(220, -2380, 1960, -2430); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := blau; Brush.Color := blau; P1.X := 240; P1.Y := -2390; P2.X := 240; P2.Y := -2420; P3.X := 255; P3.Y := -2405; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -2405, blau, fsborder); Pen.Color := hihell; Brush.Color := hihell; balkenrect := Rect(220, -2440, 1960, -2490); Rectangle(balkenrect); FillRect(balkenrect); //Notizen Pen.Color := balken; Brush.Color := balken; balkenrect := Rect(220, -2540, 1960, -2590); Rectangle(balkenrect); FillRect(balkenrect); Pen.Color := blau; Brush.Color := blau; P1.X := 240; P1.Y := -2550; P2.X := 240; P2.Y := -2580; P3.X := 255; P3.Y := -2565; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -2565, blau, fsborder); Pen.Color := hihell; Brush.Color := hihell; balkenrect := Rect(220, -2600, 1960, -2820); Rectangle(balkenrect); FillRect(balkenrect); P1.X := 240; P1.Y := -2550; P2.X := 240; P2.Y := -2580; P3.X := 255; P3.Y := -2565; Dreieck[0] := P1; Dreieck[1] := P2; Dreieck[2] := P3; Polygon(Dreieck); FloodFill(245, -2565, blau, fsborder); end; Printer.EndDoc; end end; |
AW: Pixel zu Height bei Drucker Problem
Ich habe meinen Eintrag vorhin nochmal editiert. Die Lösung liegt wohl darin das PixelsPerInch von TFont im Create seinen Wert von einer globalen Variablen holt und der Wert bezieht sich auf die Screen-DPI.
Du müsstest also vorher noch die DPI des Canvas ermitteln und diesen Wert nutzen anstelle von TFont.PixelsPerInch [Edit] Wenn du für Mapmode MM_LOENGLISH nutzt, brauchst du auch nicht lange mm<->inch umrechnen. |
AW: Pixel zu Height bei Drucker Problem
ok und wie kann ich die dpi des canvas ermitteln, also in diesemfall vom drucker?
|
AW: Pixel zu Height bei Drucker Problem
so :
Delphi-Quellcode:
Function GetPageWidth: Integer;
Begin Result := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH); End; Function GetPageHeight: Integer; Begin Result := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT); End; Function GetPageOffsetLeft: Integer; Begin Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETX); End; Function GetPageOffsetRight: Integer; Begin Result := GetPageWidth - GetPageOffsetLeft - GetDeviceCaps(Printer.Handle, HORZRES); End; Function GetPageOffsetTop: Integer; Begin Result := GetDeviceCaps(Printer.Handle, PHYSICALOFFSETY); End; Function GetPageOffsetBottom: Integer; Begin Result := GetPageHeight - GetPageOffsetTop - GetDeviceCaps(Printer.Handle, VERTRES); End; Function GetPixelsPerInchX: Integer; Begin Result := GetDeviceCaps(Printer.Handle, LOGPIXELSX); End; Function GetPixelsPerInchY: Integer; Begin Result := GetDeviceCaps(Printer.Handle, LOGPIXELSY); End; Function GetHorzRes: Integer; Begin Result := GetDeviceCaps(Printer.Handle, HorzRes); End; Function GetVertRes: Integer; Begin Result := GetDeviceCaps(Printer.Handle, VertRes); End; Function GetHorzSize: Integer; Begin Result := GetDeviceCaps(Printer.Handle, HorzSize); End; Function GetVertSize: Integer; Begin Result := GetDeviceCaps(Printer.Handle, VertSize); End; |
AW: Pixel zu Height bei Drucker Problem
Danke haut hin
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz