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 ..

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 Gu
    Mar 20 '14 at 15:48
  • the code is C#, so you can add it as web part. Mar 21 '14 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 Gu
    Mar 21 '14 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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