简体   繁体   中英

Generate PDF from aspx page using abcpdf.net

I have one web page url and i want to convert it to PDF.I used abcpdf.net in my webpage and its working fine in local host but its not working in server.I have installed abcpdf.net 6.1 version and added abcpdf.dll in my bin folder.my server is windows server 2008 r2. If there is a version problem ,please give me a suggestion.

here is my code:

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");

It seems your problem is in:

    theDoc.Save(Server.MapPath("report.pdf"));

    Response.Redirect("report.pdf");

Make sure you are saving the report.pdf in the directory of your current request. Check if the report.pdf is idd in the right server directory. I quess it is saved somewhere else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM