Pechkin.Synchronized 制作的 PDF 中的图像消失了

Images disappeared in PDF made by Pechkin.Synchronized

我写了一些代码,用 pechkin 和 pechkin.synchronized 从 HTML 制作 PDF。

初次使用会很好

从第二次开始,图片在pdf中消失了。 其他 [html 到 pdf] 也是如此。第一个pdf是对的。其他pdf不是。 第一次上服务器,就可以了。

可能是因为pechkin不会在内存中卸载。我觉得。

我需要帮助。

System.IO.File.WriteAllText(textfilepath, html);
GlobalConfig gc = new GlobalConfig();

ObjectConfig oc = new ObjectConfig()
    .SetLoadImages(true)
    .SetZoomFactor(1.0)
    .SetPrintBackground(true)
    .SetScreenMediaType(true)
    .SetCreateExternalLinks(true)
    .SetAllowLocalContent(true)
    .SetPageUri(url);

IPechkin pechkin = new Pechkin.Synchronized.SynchronizedPechkin(gc);

pdf = pechkin.Convert(oc);
using NReco.ImageGenerator;
using NReco.PdfGenerator;

//아래 주석들을 잘 여닫으면 jpg로 저장할 수 있다.
  /*
  'C:\inetpub\wwwroot\...\bin\wkhtmltopdf.exe' 경로에 대한 액세스가 거부되었습니다.
  'C:\inetpub\wwwroot\...\bin\msvcp120.dll' 경로에 대한 액세스가 거부되었습니다. 
  'C:\inetpub\wwwroot\...\bin\msvcr120.dll' 경로에 대한 액세스가 거부되었습니다. 

  위 세 파일을 해당 경로에 넣어 주면 정상 작동한다.
  */
  string article_no = Request["article_no"];
  //string[] urlArray = Request["url"].Split('/');
  //string textfilename = Guid.NewGuid().ToString() + ".html";
  //string url = urlArray[0] + "//" + urlArray[2] + "/storage/print/" + textfilename;
  //string textfilepath = Server.MapPath("/storage/print/" + textfilename);
  string html = "<html>"+HttpUtility.UrlDecode(Request["html"])+"</html>";
  //string jpgpath = Server.MapPath("/storage/print/") + article_no + ".jpg";
  string pdfpath = Server.MapPath("/storage/print/") + article_no + ".pdf";

  try
  {
    //byte[] jpg;
    byte[] pdf;
    //if (System.IO.File.Exists(jpgpath))
    if (System.IO.File.Exists(pdfpath))
    {
      //jpg = System.IO.File.ReadAllBytes(jpgpath);
      pdf = System.IO.File.ReadAllBytes(pdfpath);
    }
    else
    {
      #region Transform the HTML into PDF
      //System.IO.File.WriteAllText(textfilepath, html);

      //jpg
      /*
      var htmlToImageConv = new HtmlToImageConverter();
      jpg = htmlToImageConv.GenerateImage(html, ImageFormat.Jpeg);
      //jpg = htmlToImageConv.GenerateImageFromFile(textfilepath, ImageFormat.Jpeg);
      */

  //pdf
  var htmlToPdf = new HtmlToPdfConverter();
      pdf = htmlToPdf.GeneratePdf(html);
      //htmlToPdf.GeneratePdfFromFile(url, null, pdfpath);

      System.IO.File.WriteAllBytes(pdfpath, pdf);
      //System.IO.File.Delete(textfilepath);
      #endregion
    }

    #region Return the pdf file
    Response.Clear();

    Response.ClearContent();
    Response.ClearHeaders();

    Response.ContentType = "application/pdf";
    //Response.AddHeader("Content-Disposition", string.Format("attachment;filename={1}.jpg; size={0}", jpg.Length, article_no));
    Response.AddHeader("Content-Disposition", string.Format("attachment;filename={1}.pdf; size={0}", pdf.Length, article_no));
    Response.BinaryWrite(pdf);

    Response.Flush();
    Response.End();
    #endregion