我有一个大型数据集,我必须为其生成 CSV 和 PDF。对于 CSV,我使用本指南:https : //docs.djangoproject.com/en/3.1/howto/outputting-csv/
import csv
from django.http import StreamingHttpResponse
class Echo:
"""An object that implements just the write method of the file-like
interface.
"""
def write(self, value):
"""Write the value by returning it, instead of storing in a buffer."""
return value
def some_streaming_csv_view(request):
"""A view that streams a large CSV file."""
# Generate a sequence of rows. The range is based on the maximum number of
# rows that can be handled by a single …Run Code Online (Sandbox Code Playgroud) 好吧,我想使用pdf.js将html5中的现有pdf文件合并,并从中生成单个pdf
这可能,我该怎么做?
我从要打印的服务器上收到了base64 pdf。
我一直在尝试以下方法:
$.ajax({
type: "POST",
url: url,
data: blahblahblah,
success: function(data) {
var printWindow = window.open( "data:application/pdf;base64, " + data );
printWindow.print();
}
});
Run Code Online (Sandbox Code Playgroud)
遗憾的是,这在Chrome中不起作用。我收到以下错误:
SecurityError:阻止源为“ xxx”的帧访问源为“ null”的帧。请求访问的帧的协议为“ http”,正在访问的帧的协议为“数据”。协议必须匹配。
有关如何解决此问题的建议?