0

Our client has asked if we can add a link to their current Wiki pages named "Export to PDF", so when the user click on the link the Wiki content will be exported inside a pdf file ?

i got confused if sharePoint 2013 support such a feature out of the box or not ? If not then can i write a web part or a javaScript code to implement this scenario ?

Thanks in advance for any help ..

1 Answer 1

3

There is no such feature out of the box . You need to write your own code for achieving it. something like

protected void ExporttoPDF_Click(object sender, EventArgs e)
{
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=ExporttoPDF.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        this.Page.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
}

Refer this

3
  • thanks for the code, but how i should add this code to my SharePoint site, i mean should i add the code as a web part, or as a JavaScript ?
    – John John
    Commented Mar 20, 2014 at 15:48
  • the code is C#, so you can add it as web part. Commented Mar 21, 2014 at 4:13
  • i am not sure how i will be converting to pdf ? will i gave to add a link to my wiki Pages which will call the Web Part ?
    – John John
    Commented Mar 21, 2014 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.