Printing over a scan image

Niel Michael Bantilan 1 Reputation point

Hi! Good Day Everyone
I'm not really a hardcore developer, so I have been hoping somebody could help me out on my simple tool that I am trying to create.
So it's like this We have this pre made scholarship vouchers that I need to fill out some details like names, address etc.
I wanted to create a simple tool where I will just input the details and it will print the details to the corresponding fields
I tried using the following codes and hoping to hit the mark where I need those details but I this is not the best way. Hoping somebody can guide me . Thank You.

using (Font font1 = new Font("Arial", 24, FontStyle.Bold, GraphicsUnit.Pixel))
PointF pointf1 = new PointF(30, 1000);
e.Graphics.DrawString(textBox1.Text, font1, Brushes.Blue, pointf1);


Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,470 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 23,661 Reputation points Microsoft Vendor

    @Niel Michael Bantilan , If you want to fill the details to the correspond fields into the pdf file, it will be better for you to create a pdf file that contains the text fields.

    The following link shows that how to use itextsharp to create a TextField on an existing PDF.

    Using iTextSharp to create a TextField on an existing PDF

    After creating the pdf, you could try the following code to get fields and set the field's value.


    private void button1_Click(object sender, EventArgs e)  
            private void ListFieldNames()  
                string pdfTemplate = @"D:\ExampleWithFileds.pdf";   
                this.Text += " - " + pdfTemplate;  
                PdfReader pdfReader = new PdfReader(pdfTemplate);  
                StringBuilder sb = new StringBuilder();  
                foreach (var de in pdfReader.AcroFields.Fields)  
                    sb.Append(de.Key.ToString() + Environment.NewLine);  
                richTextBox1.Text = sb.ToString();  
            private void FillForm()  
                string pdfTemplate = @"D:\ExampleWithFileds.pdf";  
                string newFile = @"D:\ExampleWithFileds111.pdf"; ;  
                PdfReader pdfReader = new PdfReader(pdfTemplate);  
                PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));  
                AcroFields pdfFormFields = pdfStamper.AcroFields;   
                pdfFormFields.SetField("Given Name Text Box", "jack");  
                pdfFormFields.SetField("Family Name Text Box", "father");  
                pdfFormFields.SetField("Address 1 Text Box", "home");  
                pdfFormFields.SetField("House nr Text Box", "house");  
                pdfStamper.FormFlattening = false;  

    Note: Please install nuget-package iTextSharp to use the above code.



    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments