This was again a custom requirement by one of the client based in Singapore who requested to add a print button in the document library’s display form ribbon to print the display form. And again I developed a custom feature in Visual Studio 2010 starting with an Empty SharePoint Project template.
Here
are the steps to start developing the custom feature.
1) Follow the steps and create an
Empty SharePoint Project as given in the article:
http://sharepointdecode.blogspot.in/2012/05/display-warning-message-box-on-click-of.html
2) While following the steps
in above article at step 8) copy and paste the below code.http://sharepointdecode.blogspot.in/2012/05/display-warning-message-box-on-click-of.html
<CustomAction
Id="PrintRibbonButton.Action" Location="CommandUI.Ribbon"
RegistrationType="List" RegistrationId="101">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
<Button Id="PrintList" Command="PrintList" Description="Print List" LabelText="Print"
Image32by32="~/_layouts/Images/CustomPrintButton/printdoc.png" TemplateAlias="o1" Sequence="20"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="PrintList" CommandAction="javascript:window.print();" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
3) Here you have to perform an additional step to add the print button icon. Right click the project and click Add -> SharePoint Mapped Folder and select Template -> IMAGES from the Add SharePoint Mapped Folder.
You
will notice a folder created in your project file. Now add print icon image in
the
created Image folder. If you do not have a 32x32 print icon then you may download it from here: http://www.softicons.com/free-icons/toolbar-icons/32x32-free-design-icons-by-aha-soft/print-icon
created Image folder. If you do not have a 32x32 print icon then you may download it from here: http://www.softicons.com/free-icons/toolbar-icons/32x32-free-design-icons-by-aha-soft/print-icon
In
my case I added the print icon under a folder name “CustomPrintButton”, Image32by32="~/_layouts/Images/CustomPrintButton/printdoc.png"
This will automatically add the print icon image to IMAGES folder of 14 hive
This will automatically add the print icon image to IMAGES folder of 14 hive
Now you are at
the final step. Build the solution and deploy.
Please
make a note here the solution will be automatically deploy to the site you
selected for debugging. To deploy the solution to other web application you
should use the SharePoint 2010 Management Shell.
To
add and install the custom feature to other web application refer to the
Microsoft technet site:
Second
install the solution: http://technet.microsoft.com/en-us/library/ff607534.aspx
YES
! You have done creating the custom solution. Now after successful deployment
of the print custom feature go to your SharePoint Site and under site
collection features activate it.
HAPPY PRINITING……… J
HAPPY PRINITING……… J
3 comments:
Thank you very much Mr. Chougle, it works :).
Can I use this also for a Custom List ?
thank you very much :)
You are most welcome my friend.
Yes, you can use this code for any list template. To use this code for a custom list just change the Registration Id to "100" in the element.
Thanks.
My problem is, that I can`t see the icon in the ribbon.
My elements.xml
....
Alt=""
Sequence="5"
Command="CMD_SPListToWordButton"
Image32by32="~/_layouts/Images/SPListToWord/wordicon32x32.png"
Image16by16="~/_layouts/Images/SPListToWord/wordicon16x16.png"
LabelText=Test"
TemplateAlias="o1"
/>
Please help me
Post a Comment