我想在下载到桌面时看到图像。我可以将div转换为图像与狗的图像似乎无法下载带有狗图像的图像。为什么会这样?请有人帮我找到解决方案,这是一个实时视图http://torcdesign.com/banana/
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\report\controllers\main.py", line 96, in report_download
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\http.py", line 514, in response_wrap
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\report\controllers\main.py", line 45, in report_routes
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\report\models\report.py", line 181, in get_pdf
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\report\models\report.py", line 147, in get_html
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\report\models\report.py", line 123, in render
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\web_editor\models\ir_ui_view.py", line 29, in render
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_ui_view.py", line 1081, in render
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 254, in render
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 297, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 295, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 448, in render_tag_call
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 295, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 426, in render_tag_foreach
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 295, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 459, in render_tag_call
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\.\openerp\api.py", line 250, in wrapper
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 254, in render
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 297, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 295, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 448, in render_tag_call
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 297, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 297, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 297, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 325, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 320, in render_element
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 295, in render_node
File "C:\Program Files (x86)\Odoo 9.0-20161116\server\openerp\addons\base\ir\ir_qweb.py", line 503, in render_tag_field
QWebException: 'NoneType' object has no attribute '_fields'
ap_object_amount_text
$(document).ready(function() {
$('#imajes').change(function() {
$('.subselector').hide();
$('.smallimages').hide();
$('#' + $(this).val()).show();
});
$('.smallimages').hide();
var id = $(this).attr('id');
var val = $(this).val();
$('#dog').on('change', function() {
$("#bulldogimges").css('display', (this.value == 'bulldog') ? 'block' : 'none');
$("#huntingdogimges").css('display', (this.value == 'huntingdog') ? 'block' : 'none');
$("#germandogimges").css('display', (this.value == 'policedog') ? 'block' : 'none');
});
$('img').on('click', function() {
$('#fotos').append('<div class="imgdrag"><img class="modal-content" src="' + $(this).attr('src')+ '"/></div>'); $('.imgdrag').draggable();
$('#fotos').droppable();
$('.modal-content').resizable();
});
});
var download = document.getElementById("download"),
result = document.getElementById("previewImage");
function renderContent() {
html2canvas(document.getElementById("firstshirt"), {
allowTaint: true
}).then(function(canvas) {
result.appendChild(canvas);
download.style.display = "inline"; download.href = result.children[0].toDataURL();
});
}
function downloadImage() {
}
document.getElementById("btn-Preview-Image").onclick = renderContent;
download.onclick = downloadImage
答案 0 :(得分:1)
您可以查看更新的代码:
我更新了下载图片按钮代码。
$(document).ready(function() {
$('#imajes').change(function() {
$('.subselector').hide();
$('.smallimages').hide();
$('#' + $(this).val()).show();
});
$('.smallimages').hide();
var id = $(this).attr('id');
var val = $(this).val();
$('#dog').on('change', function() {
$("#bulldogimges").css('display', (this.value == 'bulldog') ? 'block' : 'none');
$("#huntingdogimges").css('display', (this.value == 'huntingdog') ? 'block' : 'none');
$("#germandogimges").css('display', (this.value == 'policedog') ? 'block' : 'none');
});
$('img').on('click', function() {
$('#fotos').append('<div class="imgdrag"><img class="modal-content" src="' + $(this).attr('src')+ '"/></div>'); $('.imgdrag').draggable();
$('#fotos').droppable();
$('.modal-content').resizable();
$(".download").attr("href",$(this).attr('src'));
$(".download").show();
});
});
var download = document.getElementById("download"),
result = document.getElementById("previewImage");
function renderContent() {
html2canvas(document.getElementById("firstshirt"), {
allowTaint: true
}).then(function(canvas) {
result.appendChild(canvas);
download.style.display = "inline"; download.href = result.children[0].toDataURL();
});
}
function downloadImage() {
}
document.getElementById("btn-Preview-Image").onclick = renderContent;
download.onclick = downloadImage
.container {background-color: transparent;
width: 300px;
height: 300px;
border: 2px solid red;
position: relative;
overflow: hidden;
/* Will stretch to specified width/height */
background-size: 490px 500px;
background-repeat: no-repeat;
}
.download{
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.min.js"></script>
<script src="https://hongru.github.io/proj/canvas2image/canvas2image.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script><script src="//cdnjs.cloudflare.com/ajax/libs/knockout/2.3.0/knockout-min.js"></script>
<link rel="stylesheet"
href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<link href='https://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.js"></script>
<script src="https://files.codepedia.info/uploads/iScripts/html2canvas.js"></script>
<select id="imajes">
<option value="">Choose Image</option>
<option value="dog">Dog</option>
</select>
<select id="dog" name="subselector" class="subselector" style="display:none">
<option value="">Choose an item</option>
<option value="bulldog">Bulldog</option>
<option value="huntingdog">Hunting Dog</option>
<option value="policedog">German Shepherd</option>
</select>
<div id="firstshirt" class="container" style="float:left;"><div id="fotos" ><img class="modal-content" id="imgdisplay" /></div></div>
<input id="btn-Preview-Image" type="button" value="Preview"/><a class="download" id="download" download="my_image.png" href="#">Download image</a>
<h3>result:</h3>
<div> <div id="previewImage">
</div><a id="download" class="download" download="my_image.png" href="#">Download image</a></div>
<div style='display:none;' id="bulldogimges" class="smallimages">
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/pT78gE6pc.gif">
<img src="https://torcdesign.com/clipart/pT78gE6pc.gif" alt="Smiley face" width="55" height="55">
</div>
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/LiKkRqkeT.gif">
<img src="https://torcdesign.com/clipart/LiKkRqkeT.gif" alt="Smiley face" width="55" height="55">
</div>
<div class="imgcontainerss" data-image="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif">
<img src="https://torcdesign.com/clipart/free-bulldog-clipart-031350.gif" alt="Smiley face" width="55" height="55">
</div>
</div>