次のライブラリを使用してPDFドキュメント(https://www.nuget.org/packages/HtmlRenderer.PdfSharp)を生成しています。C#PdfSharp - 難易度HTMLからPDFを生成する
[ValidateInput(false)]
public FileStreamResult GeneratePDF(String html)
{
MemoryStream stream = new MemoryStream();;
CssData css = PdfGenerator.ParseStyleSheet(System.IO.File.ReadAllText(Server.MapPath("~/Content/pdfForms.css")));
PdfDocument doc = new PdfDocument();
doc = PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4, 25, css);
doc.Save(stream, false);
byte[] file = stream.ToArray();
stream.Write(file, 0, file.Length);
stream.Position = 0;
return new FileStreamResult(stream, "application/pdf");
}
ライブラリを使用しようとしているときに私はいくつかの問題を抱えています。 HTML文字列が適切に渡されていますが、次のエラーが表示されます。次のように
An exception of type 'System.InvalidOperationException' occurred in PdfSharp.dll but was not handled in user code
Additional information: Cannot save a PDF document with no pages.
しかし、HTMLの変数はなります
<table><tr><th colspan=9><h2>Pre-Screening Notice and Certification Requesiton for the Work Opportunity Credit</h2><h3 class='formInfo'>Information about Form 8850 and its separate instructions is at www.irs.gov/form8850</h3><h3 class='formInstructions'>Job applicant: Fill in the lines below and check any boxes that apply.</h3></th></tr><tr><td colspan=2>Your name </td><td colspan=3><span class='userInput'>form.EmployeeName</span></td><td colspan=2>Social security number</td><td colspan=2><span class='userInput'>form.SSN</td></tr><tr><td colspan=3>Street Address: </td><td colspan=6><span class='userInput'>form.StreetAddress</span></td></tr><tr><td colspan=3>City or town, state, and ZIP code </td><td colspan=6><span class='userInput'>90210</span></td></tr><tr><td colspan=2>County</td><td colspan=3><span class='userInput'>form.County</span></td><td colspan=2>Telephone</td><td colspan=2><span class='userInput'>1234567890 </span></td></tr><tr><td colspan=5>If you are under age 40, enter your date of birth (month, day, year) </td><td colspan=4><span class='userInput'>form.DOB</span></td></tr><tr><td><input type='checkbox' checked /></td><td colspan=8> Check here if you received a conditional certification from the state workforce agency (SWA) or a participating local agency for the work opportunity credit. </td></tr><tr><td><input type='checkbox' checked /></td><td colspan=8> Check here if <b>any</b> of the following statements apply to you. <ul> <li> I am a member of a family that has received assistance from Temporary Assistance for Needy Families (TANF) for any 9 months during the past 18 months. </li> <li> I am a veteran and a member of a family that received Supplemental Nutrition Assistance Program (SNAP) benefits (food stamps) for at least a 3-month period during the past 15 months. </li> <li> I was referred here by a rehabilitation agency approved by the state, an employment network under the Ticket to Work program, or the Department of Veterans Affairs. </li> <li> I am at least age 18 but not age 40 or older and I am a member of a family that: <ul class='letterList'> <li> Received SNAP benefits (food stamps) for the past 6 months; or </li> <li> Received SNAP benefits (food stamps) for at least 3 of the past 5 months, but is no longer eligible to receive them.</li> </ul> </li> <li>During the past year, I was convicted of a felony or released from prison for a felony.</li> <li> I received supplemental security income (SSI) benefits for any month ending during the past 60 days. </li> <li>I am a veteran and I was unemployed for a period or periods totaling at least 4 weeks but less than 6 months during the past year.</li> </ul> </td></tr><tr><td><input type='checkbox' checked /> </td><td colspan=8> Check here if you are a veteran and you were unemployed for a period or periods totaling at least 6 months during the pastyear.</td></tr><tr><td><input type='checkbox' checked /></td><td colspan=8>Check here if you are a veteran entitled to compensation for a service-connected disability and you were discharged or released from active duty in the U.S. Armed Forces during the past year.</td></tr><tr><td><input type='checkbox' checked /><td><td colspan=8>Check here if you are a veteran entitled to compensation for a service-connected disability and you were unemployed for a period or periods totaling at least 6 months during the past year.<td></tr> <tr><td><input type='checkbox' checked /></td><td colspan=8>Check here if you are a member of a family that: <ul> <li>Received TANF payments for at least the past 18 months; <b>or</b></li> <li> Received TANF payments for any 18 months beginning after August 5, 1997, <b>and</b> the earliest 18-month period beginning after August 5, 1997, ended during the past 2 years; <b>or</b> </li> <li> Stopped being eligible for TANF payments during the past 2 years because federal or state law limited the maximum time those payments could be made.</li> </ul></td></tr> <tr><td> <input type='checkbox' checked /> </td> <td colspan=8>Check here if you are in a period of unemployment that is at least 27 consecutive weeks and for all or part of that period you received unemployment compensation.</td></tr></fieldset><tr><td colspan=9> <h3 class='formInstructions'>Signature - All Applicants Must Sign.</h3> <p>Under penalties of perjury, I declare that I gave the above information to the employer on or before the day I was offered a job, and it is, to the best of my knowledge, true, correct, and complete</p></td></tr><tr><td colspan=3>Job applicant's signature</td><td colspan=4><img class='img-responsive' src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAByEAAAE+CAYAAAAqKGwWAAAYk0lEQVR4nO3dL2jd+b/n8ac4IiIiIiKisBXhEvhVRERERBS2LGWJqIioiKiIKGxhKyp6oSyBEV2oqKioGDGiLBUjfmLYHTG7WzFi4I4Y8RMDdy6MGNiKEbPc2aXsreiKT3rT/n6dmf5J881JHg84pD05OeeVVr54v98FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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> <td colspan=2><span class='userInput'>form.SignedDate</span></td></tr></table>
私は別のファイルにHTMLを保存し、ブラウザで開いて、それだけで表示しました。
さらに、<html><body></body></html>
にHTMLをラップしようとしました。奇妙なことは、私はエラーを受けなかったが、空白のPDFを得たことである。
それが助け場合は、HTMLは以下によって生成されますでしょう
public partial class Form8850
{/** code omitted for brevity **/
public string WriteForm()
{
String html = "<table><tr><th colspan=9><h2>Pre-Screening Notice and Certification Requesiton for the Work Opportunity Credit</h2>";
html += "<h3 class='formInfo'>Information about Form 8850 and its separate instructions is at www.irs.gov/form8850</h3>";
html += "<h3 class='formInstructions'>Job applicant: Fill in the lines below and check any boxes that apply.</h3></th></tr>";
html += String.Format("<tr><td colspan=2>Your name </td><td colspan=3><span class='userInput'>{0}</span></td><td colspan=2>Social security number</td><td colspan=2><span class='userInput'>{1}</td></tr>", this.EmployeeName, this.SSN);
html += String.Format("<tr><td colspan=3>Street Address: </td><td colspan=6><span class='userInput'>{0}</span></td></tr>", this.StreetAddress);
html += String.Format("<tr><td colspan=3>City or town, state, and ZIP code </td><td colspan=6><span class='userInput'>{0}</span></td></tr>", this.CityStateZip);
html += String.Format("<tr><td colspan=2>County</td><td colspan=3><span class='userInput'>{0}</span></td><td colspan=2>Telephone</td><td colspan=2><span class='userInput'>{1} </span></td></tr>", this.County, this.Telephone);
html += String.Format("<tr><td colspan=5>If you are under age 40, enter your date of birth (month, day, year) </td><td colspan=4><span class='userInput'>{0}</span></td></tr>", (this.DOB != null) ? this.DOB : "");
html += String.Format("<tr><td><input type='checkbox' {0} /></td><td colspan=8> Check here if you received a conditional certification from the state workforce agency (SWA) or a participating local agency for the work opportunity credit. </td></tr>", IsQ1Checked ? "checked" : "");
html += String.Format("<tr><td><input type='checkbox' {0} /></td><td colspan=8> Check here if <b>any</b> of the following statements apply to you. <ul> <li> I am a member of a family that has received assistance from Temporary Assistance for Needy Families (TANF) for any 9 months during the past 18 months. </li> <li> I am a veteran and a member of a family that received Supplemental Nutrition Assistance Program (SNAP) benefits (food stamps) for at least a 3-month period during the past 15 months. </li> <li> I was referred here by a rehabilitation agency approved by the state, an employment network under the Ticket to Work program, or the Department of Veterans Affairs. </li> <li> I am at least age 18 but not age 40 or older and I am a member of a family that: <ul class='letterList'> <li> Received SNAP benefits (food stamps) for the past 6 months; or </li> <li> Received SNAP benefits (food stamps) for at least 3 of the past 5 months, but is no longer eligible to receive them.</li> </ul> </li> <li>During the past year, I was convicted of a felony or released from prison for a felony.</li> <li> I received supplemental security income (SSI) benefits for any month ending during the past 60 days. </li> <li>I am a veteran and I was unemployed for a period or periods totaling at least 4 weeks but less than 6 months during the past year.</li> </ul> </td></tr>", IsQ2Checked ? "checked" : "");
html += String.Format("<tr><td><input type='checkbox' {0} /> </td><td colspan=8> Check here if you are a veteran and you were unemployed for a period or periods totaling at least 6 months during the pastyear.</td></tr>", IsQ3Checked ? "checked" : "");
html += String.Format("<tr><td><input type='checkbox' {0} /></td><td colspan=8>Check here if you are a veteran entitled to compensation for a service-connected disability and you were discharged or released from active duty in the U.S. Armed Forces during the past year.</td></tr>", IsQ4Checked ? "checked" : "");
html += String.Format("<tr><td><input type='checkbox' {0} /><td><td colspan=8>Check here if you are a veteran entitled to compensation for a service-connected disability and you were unemployed for a period or periods totaling at least 6 months during the past year.<td></tr> ", IsQ5Checked ? "checked" : "");
html += String.Format("<tr><td><input type='checkbox' {0} /></td><td colspan=8>Check here if you are a member of a family that: <ul> <li>Received TANF payments for at least the past 18 months; <b>or</b></li> <li> Received TANF payments for any 18 months beginning after August 5, 1997, <b>and</b> the earliest 18-month period beginning after August 5, 1997, ended during the past 2 years; <b>or</b> </li> <li> Stopped being eligible for TANF payments during the past 2 years because federal or state law limited the maximum time those payments could be made.</li> </ul></td></tr> ", IsQ6Checked ? "checked" : "");
html += String.Format("<tr><td> <input type='checkbox' {0} /> </td> <td colspan=8>Check here if you are in a period of unemployment that is at least 27 consecutive weeks and for all or part of that period you received unemployment compensation.</td></tr></fieldset>", IsQ7Checked ? "checked" : "");
html += "<tr><td colspan=9> <h3 class='formInstructions'>Signature - All Applicants Must Sign.</h3> <p>Under penalties of perjury, I declare that I gave the above information to the employer on or before the day I was offered a job, and it is, to the best of my knowledge, true, correct, and complete</p></td></tr>";
html += String.Format("<tr><td colspan=3>Job applicant's signature</td><td colspan=4><img class='img-responsive' src={0} /></td><td colspan=2>Date</td> <td colspan=2><span class='userInput'>{1}</span></td></tr></table>", this.form8850SigData, this.SignedDate);
return html;
}
とコントローラメソッド
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Confirm8850(Form8850 form)
{
Confirm8850ViewModel vm = new Confirm8850ViewModel();
String formData = form.WriteForm();
vm.form = form;
vm.htmlForm = formData;
// vm.tempPDFPath = GeneratePDF(formData, String.Format("{0}_{1}_8850", model.newHire.LastName, model.newHire.FirstName), true);
return View(vm);
}
で見る
<h1>Review and Confirm</h1>
<h2>Please review your document below. </h2>
<form target="_blank" method="post" action="GeneratePDF" > <input type='hidden' name='html' value="@Model.htmlForm "/> <button class="btn-block btn-primary ">View</button></form>
に何かアドバイスを通過しました感謝する。
"insert section from htmlrenderer pdfsharp"を探すときに見つけました。また、新しい文書にページをコピーしなければならないバグについてのフォーラムスレッドがありました。しかし、同様に誰かがpdfdocumentオブジェクトを使う前にページを追加していないところに問題がありました。 – Tyeth