These days to find the Web Print control, either charge, or free to use only in IE!
I just want to make a simple label paper! Baidu 2 days, see a man said can use PDF, and then started Baidu. Found an article
http://www.jianshu.com/p/d518d0988621 This article code all excerpt to this article, post only for record!
The difference is that the library I imported is ITextSharp.LGPLv2.Core.Fix
Begin
First use Word to make a template file, label printing note the margins, and then save as a PDF file
Two. Then download Adobe Acrobat Pro, select PDF form when creating, and set the corresponding key name
Then there's the code.
Public Fileresult Index () {//Gets the Chinese font, and the third parameter indicates whether to sneak into the font, but it is embedded as long as the encoded font. Basefont Basefont = Basefont.createfont (@ "c:\windows\fonts\simsun.ttc,1", Basefont.identity_h, BaseFont.NOT_ EMBEDDED); Read template file Pdfreader reader = new Pdfreader (@ "C:\Users\kisme\OneDrive\pdfmoban.pdf"); Create a file stream to hold the fill template after the file System.IO.MemoryStream stream = new System.IO.MemoryStream (); Pdfstamper stamp = new Pdfstamper (reader, stream); Set the form font, in the high version is useful, the high version added this sentence will not insert the font, the low version useless//stamp. Acrofields.addsubstitutionfont (Basefont); Acrofields form = stamp. Acrofields; Whether the form text box is locked stamp. Formflattening = true; dictionary<string, string> para = new dictionary<string, string> (); Para. ADD ("username", "national section"); Para. ADD ("Usertel", "133333333"); Para. ADD ("Workservice", "computer does not turn on, may be a power problem, repair before the price (main engine missing side cover, there is important information, can not be re-installed)"); Para. ADD ("Maketime", "December 2017 11st 12:24 "); Para. ADD ("Recvicename", "xxx"); Para. ADD ("Workername", "xxx"); Para. ADD ("Weixinpic", ""); Populate the form with a para (attribute-value) dictionary for the form foreach (keyvaluepair<string, string> parameter in para) { To enter Chinese, set the font of the field; Form. SetFieldProperty (parameter. Key, "Textfont", Basefont, NULL); Set values for fields that need to be assigned values; Form. SetField (parameter. Key, parameter. Value); }//Close IO stream stamp sequentially. Close (); Reader. Close (); Generate file Fileresult Fileresult = new Filecontentresult (stream. ToArray (), "application/pdf"); Fileresult.filedownloadname = "4.pdf"; return fileresult; }
Then Baidu a jquery PDF print script, done!
Use PDF template files in. NET Core to generate PDF files instead of Web Print controls!