I tried to autofill a pdf form but it won't let me draw over the pdf. So I created an image of the form and filled it by using the drawstring method. The problem is that even though the print review shows the document correctly when I try to print it I get an enlarged document which is bigger than the paper size. I can't imagine why. Here is my code:
private void buttonPrint_Click(object sender, EventArgs e)
{
Image img = panelForm.BackgroundImage;
printDocumentForm.DefaultPageSettings.PaperSize = new PaperSize("A4", img.Width, img.Height);
printPreviewForm.Document = printDocumentForm;
printPreviewForm.ShowDialog();
}
private void printDocumentForm_PrintPage(object sender, PrintPageEventArgs e)
{
Image img = panelForm.BackgroundImage;
Image copy = (Image) img.Clone();
// I've added some drawstring methods here to fill the blanks
// but I removed them in this example to save some space
e.Graphics.DrawImage(copy, new Point(0, 0));
}
The preview window shows the correct document with the blanks filled. But when I push the print button on the preview window I get the enlarged document... edit: I should probably add that when I open the .bmp file with Paint, I can print the image correctly. The same image appears bigger and blurred in my project without any obvious reason. Why does the printer stretch my image? And why does the preview window show the correct size of the image?