在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:brcontainer/html2canvas-php-proxy开源软件地址:https://github.com/brcontainer/html2canvas-php-proxy开源编程语言:PHP 100.0%开源软件介绍:html2canvas-php-proxyPHP Proxy html2canvasThis script allows you to use html2canvas.js with different servers, ports and protocols (http, https),
preventing to occur "tainted" when exporting the Others scripting languageYou do not use PHP, but need html2canvas working with proxy, see other proxies:
Problems and solutionsWhen adding an image that belongs to another domain in
If using Google Maps (or google maps static) you can get this error in console:
You need get a API Key in: https://developers.google.com/maps/documentation/javascript/get-api-key If get this error:
Means that you are not using an HTTP server, html2canvas does not work over the "file:///" protocol, use Apache, Nginx or IIS with PHP for work. FollowI ask you to follow me or "star" my repository to track updates Run script in Cross-domain (data URI scheme)(See details: #9)
In some cases you may want to use this html2canvasproxy.php on a specific server, but the "html2canvas.js" and another server, this would cause problems in your project with the security causing failures in execution. In order to use security just set in the html2canvasproxy.php: Enable data uri scheme for use proxy for all servers:
Disable data uri scheme:
Setup
Usage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>html2canvas php proxy</title>
<script src="html2canvas.js"></script>
<script>
//<![CDATA[
(function() {
window.onload = function(){
html2canvas(document.body, {
"logging": true, //Enable log (use Web Console for get Errors and Warnings)
"proxy": "html2canvasproxy.php",
"onrendered": function (canvas) {
var img = new Image();
img.onload = function() {
img.onload = null;
document.body.appendChild(img);
};
img.onerror = function() {
img.onerror = null;
if(window.console.log) {
window.console.log("Not loaded image from canvas.toDataURL");
} else {
alert("Not loaded image from canvas.toDataURL");
}
};
img.src = canvas.toDataURL("image/png");
}
});
};
})();
//]]>
</script>
</head>
<body>
<p>
<img alt="google maps static" src="http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=800x600&maptype=roadmap&sensor=false">
</p>
</body>
</html> Using Web ConsoleIf you have any problems with the script recommend to analyze the log use the Web Console from your browser:
Get NetWork results:
An alternative is to diagnose problems accessing the link directly:
Replace
ChangelogChangelog moved to https://github.com/brcontainer/html2canvas-php-proxy/blob/master/CHANGELOG.md Next versionsDetails of future versions are being studied, in other words, can happen as can be forsaken ideas. The ideas here are not ready or are not public in the main script, are only suggestions. You can offer suggestions on issues.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论