Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: Choclito en 7 Noviembre 2009, 00:36 am



Título: impresion
Publicado por: Choclito en 7 Noviembre 2009, 00:36 am
hola ah todos saben tengo aca un duda quiero ingresar el ancho y el alto de la impresion mediante 2 TEXTBOX aca esta mi codgo solo quiero aumentar como hago para darle ancho y alto ah la impresion.

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

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public OpenFileDialog ofdImagen = new OpenFileDialog();
        public Form1()
        {
            InitializeComponent();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            ofdImagen.Filter = "Ficheros BMP|*.bmp" +
                "|Ficheros documento |*.doc" +
                "|Ficheros JPG|*.jpg" +
                "|Ficheros PNG |*.png" +
                "|Ficheros EXIF|*.exif" +
                "|Ficheros TIFF|*.tiff" +
                "|Abrir Todos los Archivos|*.*";
            pictureBox1.ImageLocation = (ofdImagen.ShowDialog() == DialogResult.OK) ? ofdImagen.FileName : null;
        }
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawString("MI VISTA PREVIA", new Font(txttexto.Font.FontFamily, txttexto.SelectionFont.Size), Brushes.Black, 250, 50);
            e.Graphics.DrawString(txttexto.Text, new Font(txttexto.Font.FontFamily, txttexto.SelectionFont.Size), Brushes.Black, 0, 100);
            e.Graphics.DrawImage(pictureBox1.Image, 400, 100, 435, 435);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            printDocument1.PrinterSettings = printDialog1.PrinterSettings;
            printPreviewDialog1.Document = printDocument1;           
            printPreviewDialog1.ShowDialog();           
        }
    }
}


Título: Re: impresion
Publicado por: MANULOMM en 9 Noviembre 2009, 17:56 pm
te refieres por ancho a:
la imagen seria aka.
Código
  1. e.Graphics.DrawImage(pictureBox1.Image, 400, 100, 435, 435);
  2.  
uno de esos parametros es.

si es a la hoja seria aqui.
Código
  1. printDocument1.PrinterSettings = printDialog1.PrinterSettings;
  2.  
modifica los printersettings alli le pasas ancho y alto de la hoja personalizada.

Atentamente,

Juan Manuel Lombana
Medellín - Colombia