Je voudrais convertir une page HTML + CSS en un fichier PDF. J'ai essayé wkhtmltopdf et j'ai un problème car la page à laquelle je veux accéder doit être authentifiée sur le site Web.Comment convertir une page HTML sécurisée (ASP.NET MVC 3) en PDF en utilisant wkhtmltopdf?
La page Je voudrais convertir au format PDF a l'adresse suivante: http: // [SITE]/PDFReport/33
Si je tente d'y accéder sans être authentifié, je suis redirigé vers la connexion page.
Alors, quand je l'utilise wkhtmltopdf, il convertit ma page de connexion au format PDF ...
La méthode anthentication J'utilise sur mon application ASP.NET MVC est SimpleMembership:
[Authorize]
public ActionResult PDFReport(string id)
{
}
J'exécute wkhtmltopdf .exe avec System.Diagnostics.Process:
FileInfo tempFile = new FileInfo(Request.PhysicalApplicationPath + "\\bin\\test.pdf");
StringBuilder argument = new StringBuilder();
argument.Append(" --disable-smart-shrinking");
argument.Append(" --no-pdf-compression");
argument.Append(" " + "http://[WEBSITE]/PDFReport/33");
argument.Append(" " + tempFile.FullName);
// to call the exe to convert
using (Process p = new System.Diagnostics.Process())
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = Request.PhysicalApplicationPath + "\\bin\\wkhtmltopdf.exe";
p.StartInfo.Arguments = argument.ToString();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.Start();
p.WaitForExit();
}
savez-vous comment générer le fichier PDF sans désactiver la sécurité sur cette page?
Merci, je vais essayer cette solution de contournement. – Toc