我收到一个byte[]包含PDF的内容.
我需要在浏览器中byte[]显示并显示PDF .我发现了类似的问题 - 如何在MVC中将PDF返回到浏览器?.但是,它在PDF查看器中打开PDF,我也收到错误,说文件无法打开,因为它是" - 不支持的文件类型或因为文件已被损坏".
如何在浏览器中打开PDF?到目前为止,我的代码如下所示 -
public ActionResult DisplayPDF()
{
byte[] byteArray = GetPdfFromDB();
Stream stream = new MemoryStream(byteArray);
stream.Flush();
stream.Position = 0;
return File(stream, "application/pdf", "Labels.pdf");
}
Run Code Online (Sandbox Code Playgroud) 我想从临时表#temptable的完整列表中检索某些用户.查询是这样的:
DECLARE @List varchar(max)
SELECT @List = coalesce(@List + ',','') + '''' + StaffCode + ''''
FROM tblStaffs
SELECT UserName
FROM #temptable
WHERE #temptable.StaffCode IN (@List)
Run Code Online (Sandbox Code Playgroud)
我可以告诉@List格式正确:
'AAA','ABB','BBB','CCC','DDD','MMM'
Run Code Online (Sandbox Code Playgroud)
如果我改变它
WHERE #temptable.StaffCode IN ('AAA','ABB','BBB','CCC','DDD','MMM')
Run Code Online (Sandbox Code Playgroud)
它当然工作正常,那么为什么不IN(@List)?
我需要使用参数@PickedDate从链接服务器检索数据.如果我跳过@A和@B,查询工作正常,但由于缺少单引号,它总是返回错误.请指教,谢谢.
查询:
Declare @OPENQUERY nvarchar(500), @TSQL nvarchar(max), @LinkedServer nvarchar(20), @A varchar(5), @B varchar(5), @PickedDate varchar(8)
Set @PickedDate = '20150501'
Set @A = 'AAA'
Set @B = 'BBB'
Set @LinkedServer = 'LinkedServerName'
Set @OPENQUERY = 'Select * From Openquery('+ @LinkedServer + ','''
Set @TSQL = 'SELECT cases.casenum, user.username, code
From cases
Inner join user
On cases.casenum = user.user_id
Where cases.date_opened > DateAdd(day,1-datepart(dw,Convert(date,' + @PickedDate + ')), Convert(date,' + @PickedDate + '))
And cases.date_opened <= DateAdd(day,8-datepart(dw,Convert(date,' + @PickedDate + ')), Convert(date,' + …Run Code Online (Sandbox Code Playgroud) 我想使用SQL Server作为Django的后端,但我在调试Web项目时得到了这个.'sql_server.pyodbc'不是可用的数据库后端.错误是:没有名为sql_server.pyodbc.base的模块.
Python环境(Python 2.7)与Django(1.7),pyodbc(3.0.10),pywin32(218.3).这是我的settings.py:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'DatabaseName',
'USER': 'user',
'PASSWORD': 'pwd',
'HOST': '127.0.0.1',
'PORT': '',
'OPTIONS': {
'driver': 'SQL Server Native Client 11.0',
'server': 'ServerName',
'MARS_Connection': True,
'dsn': 'MSSQL-PYTHON',
},
}
}
Run Code Online (Sandbox Code Playgroud) 我有一系列来自水质连续监测探头的数据集,日期和时间设置在东部标准时间(EST),因此没有校正夏令时(EDT).在R中,当从MS访问数据库导入数据表时,字段被识别为因子,但是当使用as.POSIXct()进行转换时,2016-03-13上的02:00(24时钟)的日期和时间变为NA.这是由于从EST到EDT的过渡...因此技术上2016-03-13 02:00不存在.
一些创建数据作为示例
test<-data.frame(Date=rep(as.Date("2016-03-13"),120),Hour=rep(seq(0,23,1),5),Min=rep(seq(0,60,15),24))
有没有办法将因子或字符字段转换为POSIXct字段,同时保留EST时区指定?或者有没有办法识别并将正确的日期和时间转换为EST和EDT?
我四处走动,无法得到任何工作.我试图转换为GMT(或UTC)然后转换回EST(tz ="America/New_York").我意识到这是一个持续的问题,使用日期和时间数据的人,特别是在R中的人会喜欢离开EDT.
任何帮助都表示赞赏......我在这个问题上的最终结果.
Using Microsoft SQL Server 2016 (RTM) Standard Edition, I am trying load a JSON into a SQL Server table using a SQL Server Agent Job, and get the following error:
JSON text is not properly formatted. Unexpected character '"' is found at position 508. [SQLSTATE 42000] (Error 13609).
But when I run it as T-SQL it inserts the data with out errors.
DECLARE @return_value int,
@responseText nvarchar(MAX),
@json nvarchar(MAX)
EXEC @return_value = [dbo].[HTTPRequest]
@URI = N'http://flexapi.foresightgps.com/ForesightFlexAPI.ashx',
@methodName = N'post',
@requestBody …Run Code Online (Sandbox Code Playgroud) 我正在使用 jsPDF 将 HTML 转换为 PDF 文件。它工作正常,但我想在页面周围添加边距,以便在内容分成页面时不会剪切文本。但是我没有找到任何方法来为 PDF 文件添加边距。我正在使用以下代码添加文本。请注意,我使用的是新.html()插件, not .addHtml(),已弃用,如他们的文档所示。所以这不是这个问题的重复。
<!DOCTYPE html>
<html lang="en">
<head>
<script src="jsPDF-master/dist/jspdf.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
</head>
<body>
<div id="content">
<label><span>Standard</span></label>
<label><span>Planning item number:</span></label>
</div>
<button onclick="exportPDF()" style="float:right;">Download</button>
<script>
function exportPDF () {
var pdf = new jsPDF('p', 'pt', 'a4');
var margins = {
top: 40, bottom: 60, left: 40, right: 200
};
pdf.html(document.getElementById("content"), {
callback : function (pdf) {
pdf.save("a4.pdf");
}
});
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如何为 PDF …
我想使用jsPDF.html将html页面转换为pdf,我正在使用以下代码:
savePdf () {
var pdf = new jsPDF({unit: 'mm', format: 'a4', orientation: 'portrait' })
pdf.html(document.getElementById('printable-cv'), {
callback: function (pdf) {
pdf.save('cv-a4.pdf');
}
})
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误html2canvas not loaded:我忘了吗?我有html2canvas
“ html2canvas”:“ ^ 1.0.0-alpha.12”
我正在将vuejs与webpack一起使用。
在同一页面中,我当前正在使用带有以下代码的html2pdf:
savePdf0 () {
let opt = {
filename: 'cv.pdf',
enableLinks: true,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 8,
useCORS: true,
width: 310,
letterRendering: true,
},
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
}
html2pdf().set(opt).from(document.getElementById('printable-cv')).save() …Run Code Online (Sandbox Code Playgroud) 如何data:application/pdf;filename=generated.pdf;base64;DATA在 Chrome 71 中使用 javascript 链接打开?
来自控制台的链接成功打开,但不是来自代码 - 不幸的是。
出于安全原因,该代码段不起作用。仅用于代码演示。
我阅读了一些类似的问题,但没有找到答案。
var button = document.getElementById("button");
button.addEventListener("click", generate, false);
function generate() {
var doc = new jsPDF({
orientation: "l",
unit: "mm"
});
doc.text('ACT', 130, 20);
var string = doc.output('datauristring');
console.log(string);
var link = document.createElement('a');
link.href = string;
link.setAttribute('target', '_blank');
document.body.appendChild(link);
link.click();
link.parentNode.removeChild(link);
}Run Code Online (Sandbox Code Playgroud)
<script src="https://unpkg.com/jspdf@1.5.3/dist/jspdf.min.js"></script>
<button id="button">Generate pdf table</button>Run Code Online (Sandbox Code Playgroud)
我正在托管ASP.NET Core 2网站,并收到以下错误消息。
HTTP Error 500.21 - Internal Server Error
Handler "aspNetCore" has a bad module "AspNetCoreModule" in its module list
Run Code Online (Sandbox Code Playgroud)
我的应用程序正在使用nopCommerce 4.00,并且服务器端已经安装了ASP.NET Core组件。
hosting nopcommerce internal-server-error asp.net-core nopcommerce-4.0
sql-server ×4
jspdf ×3
javascript ×2
pdf ×2
asp.net-core ×1
asp.net-mvc ×1
c# ×1
css ×1
date ×1
delimiter ×1
django ×1
dst ×1
dynamic-sql ×1
hosting ×1
html2canvas ×1
html2pdf ×1
json ×1
nopcommerce ×1
openquery ×1
python ×1
r ×1
sql-agent ×1
time ×1
where-in ×1