Autor Beitrag
MrKnogge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP, Win 7
Delphi 7 Prof, Delphi 2005 PE, C# (VS 2008)
BeitragVerfasst: Fr 03.06.11 14:34 
Ich habe hier (Gewusst wie: Drucken eines Formulars) folgenden Code-Schnipsel gefunden, mit dessen Hilfe ich ein Formular auf ein Bitmap bekomme:


ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, 
    int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{
    Graphics mygraphics = this.CreateGraphics();
    Size s = this.Size;
    memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
    Graphics memoryGraphics = Graphics.FromImage(memoryImage);
    IntPtr dc1 = mygraphics.GetHdc();
    IntPtr dc2 = memoryGraphics.GetHdc();
    BitBlt(dc2, 00this.ClientRectangle.Width,
        this.ClientRectangle.Height, dc1, 0013369376);
    mygraphics.ReleaseHdc(dc1);
    memoryGraphics.ReleaseHdc(dc2);
}
private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    e.Graphics.DrawImage(memoryImage, 00);
}
private void printButton_Click(System.Object sender, System.EventArgs e)
{
    CaptureScreen();
    printDocument1.Print();
}


Nun wäre meine Frage, ob es auch eine Möglichkeit gibt, das Formular direkt an den (PDF)-Drucker zu senden, damit Schriften als Schriften erhalten bleiben?

Viele Grüße & besten Dank!
Christian

_________________
MfG MrKnogge
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19276
Erhaltene Danke: 1741

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 03.06.11 15:17 
Nur, wenn du das selbst schreibst.

Heißt: Alles selbst zeichnest und an den Drucker schickst. Also die einzelnen Controls, dabei den Textbereich überschreibst und den Text dort ausgibst, ...

Wozu soll das eigentlich dienen? Geht es denn überhaupt um das visuelle Formular inkl. OS-spezifischem Design etc. in C# oder um ein Formular allgemein, dass gedruckt werden soll.
MrKnogge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 76

Win XP, Win 7
Delphi 7 Prof, Delphi 2005 PE, C# (VS 2008)
BeitragVerfasst: Fr 03.06.11 15:56 
Ja, es geht um die Programmoberfläche. Diese hätte ich gerne als Vektorgrafik und idealerweise im PDF die Schrift als Schrift.

Daher war mein Gedanke, ob man sie auch aus Visual Studio heraus drucken könnte. Zur Laufzeit muss man es nicht können.

_________________
MfG MrKnogge