![](/img/trans.png)
[英]How to use the ABCPdf.NET to extract texts from all pages of a PDF file?
[英]Generate PDF from aspx page using abcpdf.net
我有一個網頁網址,我想將其轉換為PDF。我在網頁中使用了abcpdf.net,它在本地主機上工作正常,但在服務器中不起作用。我已經安裝了abcpdf.net 6.1版本並添加了abcpdf.dll在我的bin文件夾中。我的服務器是Windows Server 2008 R2。 如果有版本問題,請給我一個建議。
這是我的代碼:
string projectid = partnerid;
string versionid = DDLVersion.SelectedItem.Text.ToString().Trim();
string serverurl = "http://serverurl/Design/Pro/Previewtopdf.aspx?PID=" + projectid + "&versionID=" + versionid + "";
Doc theDoc = new Doc();
theDoc.Rect.Inset(10, 30);
theDoc.Page = theDoc.AddPage();
int theID;
theID = theDoc.AddImageUrl(serverurl);
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();
}
theDoc.Save(Server.MapPath("report.pdf"));
theDoc.Clear();
Response.Redirect("report.pdf");
看來您的問題出在:
theDoc.Save(Server.MapPath("report.pdf"));
Response.Redirect("report.pdf");
確保將report.pdf保存在當前請求的目錄中。 檢查report.pdf是否在正確的服務器目錄中idd。 我問它是否保存在其他地方。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.