Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render online picture fail #397

Closed
ychbcdq opened this issue Jun 12, 2014 · 11 comments
Closed

render online picture fail #397

ychbcdq opened this issue Jun 12, 2014 · 11 comments

Comments

@ychbcdq
Copy link

ychbcdq commented Jun 12, 2014

when the image src like that (./imges/1.jpg) is location picture is work,but src like (https://s.yimg.com/hg/pimg1/7d/58/p087944500151-item-2242xf1x0550x0550-m.jpg) is online picture is not work.Render online picture fail.

@brcontainer
Copy link
Contributor

Please before posting so much, read README first: https://github.com/niklasvh/html2canvas#how-does-it-work

@ychbcdq
Copy link
Author

ychbcdq commented Jun 13, 2014

Thanks for your help.I have dete the email because it‘s email style at sixes and sevens.Not look well.I will go to have look.

@ychbcdq
Copy link
Author

ychbcdq commented Jun 13, 2014

Hello,brcontainer,I have read README first: https://github.com/niklasvh/html2canvas#how-does-it-work,and understand i must use a proxy .But i just a html file and use html2canvas.js to capture,how can use the proxy? I'm a newbie also a student at school, study web design,hope more detailed, very grateful for your help.

@brcontainer
Copy link
Contributor

This actually already been discussed many times, please search before. Everything comes'll try to help you. What language / platform server you use?

php, asp.net, asp Classic, Python, CGI?

See proxies list: https://github.com/niklasvh/html2canvas/wiki/Proxies

@ychbcdq
Copy link
Author

ychbcdq commented Jun 13, 2014

I have see proxies list :https://github.com/niklasvh/html2canvas/wiki/Proxies,Because i see also many server, I just want to write a html capture whatever web i input the web address.I guess i need juge what server type and then handler each other,no matter so much.For example , i use php,how can i use?I have see that;
(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");
}
});
};
})();

but i don't know where put the html2canvasproxy.php in?Tell me please,thank you!

@brcontainer
Copy link
Contributor

The doubt is not a how to use the proxy, but how to create an application that captures sites other sites.

but i don't know where put the html2canvasproxy.php in?Tell me please,thank you!

You have some knowledge of PHP? Put in the same folder as your page that executes the process.

@ychbcdq
Copy link
Author

ychbcdq commented Jun 15, 2014

I have only a little knowledge of php,i just learn right now.I put the html2canvasproxy.php at same folder as my index.html file.

1
In the exprot5.htm file ,i write a javaScript and add that function.
(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");
}
});
};
})();
However,i have a problem like that
4

Do i have some other things be lost,or I was wrong to write like that ,or i must add something in the server?Sorry to trouble you,hope me please.

@brcontainer
Copy link
Contributor

Your problem has nothing to do with the proxy or html2canvas,
the problem is that you want to use server language in a "file protocol".

Proxies only work on servers, consider first about SERVER-SIDE.

Read: http://stackoverflow.com/a/23038466/1518921 (ignore the part that speak ajax and sjax)

@alokroutray
Copy link

I am working in my server. But online images are not working with html2canvas. Please help me. Thank You.

@brcontainer
Copy link
Contributor

@alokroutray put an example in fiddle.

@NikhilRadadiya
Copy link

@brcontainer I'm using html2canvas in angular2 and images are hosted in different server, I don't know what they are using server side, how can I get images from different server in html2canvas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants