printing - Format Print Document in C# -


I am quite new to c # and need some help in creating a document for printing.

I have already been able to talk to the printer through this code:

  Private Zero Print (String Printer) {PrintDocument PrintDoc = new PrintDocument (); PrintDoc.PrinterSettings.PrinterName = Printer; PrintDoc.PrintPage + = New PrintPage event handler (printpage); PrintDoc.Print (); } Zero printpase (Object Sender, PrintPage Event Eg) e.Graphics.DrawLine (New Pen (Color. Black), New Point (0, 0), New Point (100, 100)); E.Graphics.DrawString ("Hello World", New Font ("Times New Roman", 12), New Solidbrush (Color Black), New Point (45, 45)); }   

Who print my string "Hello World" is obviously the print code of the code which I found on the net. Sadly, I could not find any way for

a) Set the size of the paper format that is printed on (this is the 138 mm x 99 mm landscape format)

b) Tell the printer where to print my texts properly.

This paper is a PRINTMENT form and I have to write my own text in the specific field.

I therefore have my own printed document such as:

   & Lt; Text & gt; Textfield 1 & lt; / Text & gt; & Lt; / Field 1 & gt; & Lt; Field2 & gt; ....   

I could not find information on how to do this. So if someone can tell me how to do this or have a good tutorial, then I am very thankful

to set the paper size

  printDocument.DefaultPageSettings.PaperSize = new paper size ("custom name", width, height); PrintDocument.DefaultPageSettings.Landscape = true;   

Width and height is in the one hundredth of a century

See the tutorial in the SO question for print text on pre-printed paper.

To avoid paper wastage during your experiment, scan the preprint paper as an image and set it as a background in PrintPageHanlder while previewing.

  void printDocument_PrintPage (Object Sender, PrintPageEventArgs e) {if (printDocument.PrintController.IsPreview) {Image Image = Image.FromFile ("Scanned ImagePath"); E.Graphics.DrawImage (Image, 0,0)} // After printing the background, print the other text here    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -