我已经创建了一个用于pdf生成的C# Azure函数,并且正在使用NReco pdf生成器,但它并不在Aazure上工作。
你能建议一种使它在蔚蓝中运行的方法吗?
我已经通过NReco软件包管理器控制台安装了NuGet Pdf生成器,并收到以下错误:
“拒绝对路径'D:\Program (x86)\SiteExtensions\Functions\1.0.12599\wkhtmltopdf‘的访问。
这是抛出的异常的堆栈跟踪:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
at System.IO.Directory.CreateDirectory(String path)
at NReco.PdfGenerator.HtmlToPdfConverter.EnsureWkHtmlLibs()
at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(WkHtmlInput[] htmlFiles, String inputContent, String coverHtml, String outputPdfFilePath, Stream outputStream)
at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfFromFile(String htmlFilePath, String coverHtml)
at VRProductions.Repository.PdfGenerationRepository.<SendMail>d__1.MoveNext()这是用于生成pdf的代码:
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
var pdfBytes = htmlToPdf.GeneratePdfFromFile(blockBlob.Uri.AbsoluteUri, "");发布于 2019-04-22 06:13:19
如果有任何帮助的话,我可以使用下面的函数code..see生成pdf。Azure函数V1
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace FunctionApp41
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
var pdfBytes = htmlToPdf.GeneratePdfFromFile("<file_path_including_sas_token>", "");
var response = req.CreateResponse(HttpStatusCode.OK);
response.Content = new StreamContent(new MemoryStream(pdfBytes));
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return response;
}
}
}如果您在本地运行此函数,则将生成可视studio..file,并在浏览器中加载pdf或要求保存。
http://localhost:7071/api/Function1https://stackoverflow.com/questions/55789672
复制相似问题