我正在打印文档并尝试更改纸张大小,但它不起作用。
当我添加纸张尺寸时,它会以默认尺寸打印文档。我的纸张尺寸不起作用。
namespace WC_manager
{
public partial class tagprint : Form
{
Zen.Barcode.Code39BarcodeDraw objCode = Zen.Barcode.BarcodeDrawFactory.Code39WithChecksum;
int tagNo = 0;
PrinterSettings ps = new PrinterSettings();
public tagprint()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void printBtn_Click(object sender, EventArgs e)
{
if(tagNo != 0)
{
pictureBox1.Image = objCode.Draw(Convert.ToString(tagNo), 100);
var doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(ProvideContent);
doc.PrinterSettings.PrinterName = "Adobe PDF";
doc.DefaultPageSettings.PaperSize = new PaperSize("Custom",10,10);
doc.Print();
}
else
{
MessageBox.Show("Enter Valid Tag no");
}
}
private void tagTxtFld_TextChanged(object sender, EventArgs e)
{
tagNo = Convert.ToInt32(tagTxtFld.Text);
}
public void ProvideContent(object sender, PrintPageEventArgs e)
{
Graphics graphics = e.Graphics;
Font font = new Font("Courier New", 10);
float fontHeight = font.GetHeight();
graphics.DrawImage(objCode.Draw(Convert.ToString(tagNo), 20), 0, 2, 30, 30);
}
}
}
慕标琳琳
守着一只汪