ToolFk is a free test kit that programmers use online. ToolFk focuses on the tools that programmers use every day. You don’t need to install any software, just paste the content and press the execute button to get the results you want. ToolFk also supports BarCode BarCode generation online, QueryList collector, PHP code running online, PHP obfuscation, encryption, decryption, Python code online running, JavaScript online running, YAML Formatting Tool, HTTP simulation query tool, HTML online toolbox, JavaScript online toolbox, CSS online toolbox, JSON online toolbox, Unixtime timestamp conversion, Base64/URL/N Ative2Ascii conversion, CSV conversion toolbox, XML online toolbox, WebSocket online tool, Markdown online toolbox, Htaccess2nginx Transition, hexadecimal conversion online, online encryption tool box, pseudo original tools online, online APK decompiling, online web page screenshots tools, online random password generation, online generated qr code Qrcode, online Crontab expression, online short url generation, on-line calculator tool, commonly used Linux command daquan, text comparison tool, in the online Line mind mapping tool, online database design tool, free CDN acceleration service, online stress testing tool, map picking coordinate tool, online SQL conversion tool. Such as more than 20 daily programmer development tools, is a very comprehensive programmer toolbox site.
Site name: ToolFk Site Link: www.toolfk.com/ Tool link: www.toolfk.com/tool-conver…
The code of teaching
Support Online PDF to PNG, PDF to JPEG, PDF to WEBP, PDF to TXT – toolfk programmer tools online network] dependent on https://xxlllq.github.io/pdf2img/
STEP 1
STEP 2
The core code is as follows
<script>
$("#export").attr("disabled"."disabled");
var pdfFile;
var txtArr =[];
$('#pdf').change(function() {
var load_index = layer.load();
var pdfFileURL = $('#pdf').val();
if(pdfFileURL) {
$("#imgDiv").empty();
var files = $('#pdf').prop('files');
var fileSize = files[0].size;
var mb;
if(fileSize) {
mb = fileSize / 1048576;
}
$("#export").removeAttr("disabled"."disabled");
$("#pdfName").text(files[0].name).attr("title",files[0].name);
$("#sizeText").text(mb.toFixed(2) + "Mb"); */ var reader = new FileReader(); reader.readAsArrayBuffer(files[0]); var load_inner = layer.load(); reader.onload =function(e) {
var typedarray = new Uint8Array(this.result);
PDFJS.getDocument(typedarray).then(function(pdf) {
$("#imgDiv").css("border"."0");
if(pdf) {
var pageNum = pdf.numPages;
$("#pagesText").text(pageNum);
for(var i = 1; i <= pageNum; i++) {
var canvas = document.createElement('canvas');
canvas.id = "pageNum" + i;
$("#imgDiv").append(canvas);
var context = canvas.getContext('2d');
openPage(pdf, i, context);
}
}
layer.close(load_inner);
});
};
}
layer.close(load_index);
});
functionwt(wmContext,origCanvas){ wmContext.save(); WmContext. GlobalAlpha = 0.5; wmContext.textBaseline ='middle';
wmContext.textAlign = 'center';
wmContext.font = "18px Comic Sans MS" ;
wmContext.fillStyle = "red";
wmContext.rotate(180*Math.PI/180);
wmContext.fillText("WaterMark Demo", 200, 60); wmContext.restore(); }function openPage(pdfFile, pageNumber, context) {
var scale = 2;
pdfFile.getPage(pageNumber).then(function(page) {
page.getTextContent().then((textContent) => {
let pageText = [];
textContent.items.forEach((textItem) => {
pageText.push(textItem.str);
});
pageText.join(' ');
txtArr[pageNumber] = pageText;
});
viewport = page.getViewport(scale);
var canvas = context.canvas;
canvas.width = viewport.width;
canvas.height = viewport.height;
canvas.style.width = "96%";
canvas.style.height = "100%";
canvas.className = 'c_class';
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
};
function exportType(images,ext,url_ext){
$("canvas").each(function(index, ele) {
var canvas = document.getElementById("pageNum" + (index + 1));
images.file("image-" + (index + 1) + ext, dataURLtoBlob(canvas.toDataURL(url_ext, 1.0)), {
base64: true
});
});
}
$("#export").click(function() {
var modules = $("#modules");
var pdfFileURL = $('#pdf').val();
if(! pdfFileURL){ layer.msg("@lang('toolfk.lang_convert_pdf_upload').");
return false;
}
var module_val = modules.val();
if(! module_val){ layer.msg("@lang('toolfk.lang_convert_pdf_convert').");
return false;
}
var zip = new JSZip();
var images = zip.folder("toolfk-images");
if(module_val == "png") {exportType(images,".png"."image/png");
}else if(module_val == "jpeg") {exportType(images,".jpeg"."image/jpeg");
}else if(module_val == "webp") {exportType(images,".webp"."image/webp");
}else if(module_val == "txt"){
var fullTxt = "";
$.each(txtArr,function(index,ele){
if(typeof(ele) ! ="undefined"){ fullTxt+=ele; }}); images.file($("#pdfName").text() + ".txt".""+fullTxt);
}else{
layer.msg("@lang('toolfk.lang_convert_pdf_convert').");
return false;
}
zip.generateAsync({
type: "blob"
}).then(function(content) {
saveAs(content, "toolfk_com_pdf_convert.zip");
});
});
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(', '), mime = arr[0].match(/:(.*?) ; /)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);while(n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {
type: mime
});
}
</script>Copy the code
Three reasons it’s worth a try:
-
Integrate a variety of development test tools commonly used in programmer development.
-
Simple and beautiful atmosphere of the website page
-
Support online formatting execution code, APK online decompilation, online high-strength password generation, online web page screenshots and more than 20 tool services
-
Also recommend its sister network www.videofk.com video download toolbox
This paper links: www.hihubs.com/article/400