Description link
Use pdf.js plug and LODOP control implements front-end browser silent print PDF file
lodop official website address: http://www.lodop.net/download.html
Click to download the file, there are manual
I was in vue project
Click on the official website address, download it, then there will be a file after decompression,
There are CLodop_Setup_for_Win32NT.exe, install_lodop32.exe, install_lodop64.exe
1, I installed directly CLodop_Setup_for_Win32NT.exe
2, the introduction of project files LodopFuncs.js
Incorporated in the head or the body
<script src="static/LodopFuncs.js"></script> <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed> </object>
3, page
template:
<div id="printarea" v-html="bb" v-show="false"></div> <el-button @click="print()">打印</el-button>
print () method:
Print () { // print initialize var LODOP = getLodop (); LODOP.PRINT_INIT ( "Print the label" ); // set the paper size LODOP.SET_PRINT_PAGESIZE (0,2100,2970, "article tag" ); // Set font LODOP.SET_PRINT_STYLE ( "the FontSize", 16 ); // set bold LODOP.SET_PRINT_STYLE ( "Bold", 1 ); // increase hypertext item LODOP.ADD_PRINT_HTM ( "5mm", "5mm ", 2100, 2970, document.getElementById ( "printArea" ) .innerHTML); // Print preview LODOP.PREVIEW (); // direct printing // LODOP.PRINT (); },
Direct print preview and you can choose one, and then install the printer, you can print! ! ! !
lodop design url address: http://test.kerunsoft.cn/lodop_print/
Parameter Description:
SET_PRINT_PAGESIZE(intOrient,intPageWidth,intPageHeight,strPageName);
Definition:
intOrient: paper type and orientation
is portrait 1 ---, fixed paper;
is 2 --- landscape printing, the sheet is fixed;
is 3 --- portrait, fixed width, print height by the highly adaptive;
0 (or other) ---- printing direction selected by the operator or by the own default printer.
intPageWidth:
paper width, 0.1mm unit 45 such as the parameter value, then 4.5mm, metering accuracy is 0.1mm.
intPageHeight:
fixed paper sheet of this parameter is high; when the parameter is highly adaptive high blank paper base, the paper width of the same units of measurement.
strPageName:
paper name, must be equal to zero when this parameter is valid intPageWidth, have the following options:
Letter, LetterSmall, Tabloid, Ledger, Legal, the Statement, Executive,
A3, A4, A4Small, A5, B4, B5, the Folio, in Quarto, qr10X14, qr11X17, Note,
Env9, Env10, Env11, Env12, Env14, Sheet, DSheet, ESheet