Jump to content

Impressão/Imprimir (print) Form


Recommended Posts

Posted

Boas,

Tenho um projecto cujo o objectivo é preencher uns dados em textboxes com o objectivo de os imprimir .

O problema é que a impressão fica com má qualidade, as letras veem se  mal não sei do que poderá ser .

Agradecia ajuda .

Imagem form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Data.Common;
using System.Configuration;
using System.Data.SqlClient;


using System.Drawing.Printing;



namespace AJ
{
    public partial class registo : Form
    {


        Bitmap bitmap;

      
 
        public registo()
        {
            InitializeComponent();


        }

        private void registo_Load(object sender, EventArgs e)
        {
         
        }

        private void btnSair_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void printDocument1_PrintPage_2(object sender, PrintPageEventArgs e)
        {

            e.Graphics.DrawImage(bitmap, 0, 0);
            

            // e.PageSettings.PrinterResolution.X = 300;
            //e.PageSettings.PrinterResolution.Y = 300;

        }

        private void button1_Click(object sender, EventArgs e)
        {


      

            try
            {


                if (Nome.Text == string.Empty || Morada.Text == string.Empty || telefone.Text == string.Empty || Marca.Text == string.Empty || Modelo.Text == string.Empty || Matricula.Text == string.Empty || Km.Text == string.Empty || Comb.Text == string.Empty)
                {
                    MessageBox.Show("Preencha todos os parametros, Apenas Obs. é opcional");

                }
                else
                {

                   

                    //Add a Panel control.
                    Panel panel = new Panel();
                        this.Controls.Add(panel);

                        //Create a Bitmap of size same as that of the Form.
                        Graphics grp = panel.CreateGraphics();
                        Size groupzize = groupBox4.ClientSize;
                        
                        bitmap = new Bitmap(groupBox4.Width, groupBox4.Height, grp);
                        grp = Graphics.FromImage(bitmap);

                        //Copy screen area that that the Panel covers.
                        Point panelLocation = PointToScreen(groupBox4.Location);
                        grp.CopyFromScreen(panelLocation.X, panelLocation.Y, 0, 0, groupzize);

                        //Show the Print Preview Dialog.
                        printPreviewDialog1.Document = printDocument1;
                        printPreviewDialog1.PrintPreviewControl.Zoom = 1;
                        printPreviewDialog1.ShowDialog();
               


                    Nome.Text = string.Empty;
                    Morada.Text = string.Empty;
                    telefone.Text = string.Empty;
                    Marca.Text = string.Empty;
                    Modelo.Text = string.Empty;
                    Matricula.Text = string.Empty;
                    Km.Text = string.Empty;
                    Comb.Text = string.Empty;
                    Obs.Text = string.Empty;

    
               


                }
            }
            catch (Exception )
            {
                MessageBox.Show("Algo está errado! \nVerifique se os campos telefone e/ou Quilometros tem numeros inseridos ", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            

        }

        private void Voltar_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.Show();
            this.Hide();
        }
  }
}
Posted

Experimenta mandar imprimir para PDF em vez de imprimires mesmo para a impressora (uso esse truque para poupar papel e caminhadas até à impressora :D).

Já viste as definições da impressora? Experimenta alterar a qualidade da impressão.

10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."

 

Posted

Mas eu não nem imprimo logo, eu tenho para mostrar uma pré-visualização e so depois nesse painel de pré-visualização é que mando imprimir, mas nesse painel parece estar tudo bem 
para mexer na resolução será algo deste genero " e.PageSettings.PrinterResolution.X = 300; " ??

Qual a melhor resolução ?

 

Obrigado 

Posted

Quanto maior o número, melhor a resolução. Tens de ver na documentação como melhorar a resolução, não sei de cor.

10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.