0

I am planning to create a custom list where the forms (new, edit, and display forms) are customized. Is there a way to generate a PDF version of the custom display form via code?

Let's say I add in a custom button called 'Save as PDF' in the display page of the list item. When this button is clicked, a PDF version of the current form will be downloaded.

I would prefer existing libraries over third party tools, but any helpful answers will be appreciated :)

3
  • There are two ways, one is using window.print(javascript) but it will have browser dependency and second way is you can create one word document exactly same as your form with placeholder instead of the actual field value. Then you can create Item Added/Updated Event receiver which will update word document with actual values and convert it to PDF using Word Automation Services. Let me know if you want code for second option as I have already implemented it... Jul 14, 2015 at 4:05
  • The second one seems a favorable option. Can you kindly expound on it? Thanks.
    – Joe
    Jul 14, 2015 at 4:10
  • @Kalpesh Vaghela do you still have the code? Could you share it with me too? It seems like it was deleted.. Thanks!
    – Aleks
    Dec 4, 2018 at 11:25

1 Answer 1

3

Following is the way to achieve this requirement:

  1. Create one document library with "ItemID" field.

  2. Add one hyperlink field to your actual list to store PDF url.

  3. Create one word document with placeholder.

    3.1. You need to enable "Developer Tools" in word. Follow this link to do so.

    3.2. Design your document exactly same as your display form and add "TextBox place holder" in document where actual field values is going to be replaced. A guide can for this can be found here.

    Note: that you need to use "RichText"control according to my code and your control "Title" and "Tag" name must be the internal name of the field

    3.3. Create Item Added/Updated Event Receiver . You can view all the code here.

If you find any issue in implementation of code then let me know because this is working code in [my] production environment currently :):).

Hope it will help to achieve your requirement.

Your Answer

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

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