6

私は現在、abcPDF7を使用してHTMLをPDFに変換しています。これは、RenderメソッドをオーバーライドするASPXページを介して行われます。

Doc theDoc = new Doc();
theDoc.SetInfo(0, "License", m_License );
theDoc.HtmlOptions.Paged = true;
theDoc.HtmlOptions.Timeout = 1000000;

string callUrl = "http:// my app page";
theDoc.AddImageUrl(callUrl);
Response.Clear();

Response.Cache.SetCacheability(HttpCacheability.Private);
Response.AddHeader("Content-Disposition", "attachment; filename=" + sFile + ".pdf");
Response.ContentType = "application/octet-stream";

theDoc.Save(Response.OutputStream);

Response.Flush();

これは最初のページでは完全に機能しますが、その後ページを切り捨て、残りのページのレンダリングを続行しません。

ページの後で停止する理由を誰かが知っていますか?

4

2 に答える 2

11

これとまったく同じ問題がありました。答えは連鎖を使用していますが、前の回答で提供されたページには、これを行う方法が正確に示されていません。以下は私のサイトの例です: 変数 htmlOutput は、レンダリングしたい htmlOutput を受け取るオブジェクト内の変数であることに注意してください。html を変数に直接プッシュするか、または現在のページの場合は、ページに対して保護されたオーバーライド void Render(HtmlTextWriter output) を実行し、Render のコンテンツをこの htmlOutput 変数にプッシュして、ページからこれを収集します。

Doc theDoc = new Doc();
int theID;
theDoc.Page = theDoc.AddPage();

theID = theDoc.AddImageHtml(htmlOutput);

 while (true)
 {
     theDoc.FrameRect(); // add a black border
     if (!theDoc.Chainable(theID))
         break;
      theDoc.Page = theDoc.AddPage();
      theID = theDoc.AddImageToChain(theID);
 }

 for (int i = 1; i <= theDoc.PageCount; i++)
 {
    theDoc.PageNumber = i;
    theDoc.Flatten();
  }
  //reset back to page 1 so the pdf starts displaying there
  if(theDoc.PageCount > 0)
       theDoc.PageNumber = 1;

  //now get your pdf content from the document
  byte[] theData = theDoc.GetData();
于 2009-11-13T01:05:31.163 に答える
10

「ドキュメントの最初のページのみが描画されます。後続のページは、AddImageToChainメソッドを使用して描画できます。」

ここから

AddImageToChainの使用方法の例はここにあります

于 2008-11-13T10:29:26.033 に答える