You need to sign in to do that
Don't have an account?
Ishan K Sharma
Display notes and attachments in VF page
Hi
I have word docx file in notes and attachments. I want to display it in my vf page. Is there any way to do this.
Thanks
Ishan Sharma
Check out an earlier discussion on viewing attachments in VF:
http://boards.developerforce.com/t5/Visualforce-Development/Any-one-know-ways-to-diplay-Attachment-in-Visualforce-page/td-p/74076
Hello Ishan,
You can include related list in the VF like:
<apex:relatedList subject="ParentObjectId" list="NotesAndAttachments"/>
I dont want to show list. I want to show content in the list on my vf page.
for ex if my attachment is pdf file so i want to show whole pdf on my vf page.
Use the link I pointed you at - basically you point at the download servlet for the attachment, and if the browser has a plugin that can display it, it will use that.
Bob thanks for the help but i need little more. I am able to display the
pdf content now with help of above link but there is one more prob.
My vf page is pdf type(renderas = 'pdf'). Now if i remove this renderas
attribute then i am able to display my attachments but if i add renderas
="pdf" then i am not able to display it. Is there any solution for this.
*My vf page is also pdf type. *
When you say display the attachments, is that rendering the attachments related list or actually displaying the body of an attachment?
*I want to display whole body of attachment(pdf) in my vf page which is
also pdf type(renderas).*
I doubt you'll be able to do that. The problem is that the browser will pull the contents of the servlet and use that when rendering the page. Once you are into a PDF plugin, that won't know what to do with that markup. I suspect you'd need to find a way to render your attachment body as HTML.
Did you find any solution for displaying the pdf attachment on VF page while rendering as PDF? Even I am facing the same problem that you have mentioned above.
Regards
Nikhil
I want to convert VF to PDF and then save it to Notes and attachments and below are the VF pages and apex class.
When I run the process, a pdf is created successfully at the right location under the Custom__c but its blank. When I "login to community as a user", again the same vf page is blank but when I create a custom link of vf page in Custom__c object, I see the entire letter in pdf. Before putting the extension and action tag, I was able to see the same page from the custom link and from "login to community as a user". Can you please tell me what I am doing wrong, why its showing blank page.
Also VF page render the output dynamically, its not a static page.
Please help me.
1st Visualforce Page: (Letter)
<apex:page standardcontroller="Custom__c" extensions="attachPDFToCustom" action="{!attachPDF}" standardStylesheets="false" showHeader="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0" >
<apex:include pageName="Letter_V2"/>
2nd Visualforce Page: (Letter_V2)
<apex:page renderAs="pdf"> </apex:page>
Apex Class:
public class attachPDFToCustom {
public attachPDFToCustom(ApexPages.StandardController standardPageController) {
}
public void attachPDF() {
PageReference pdfPage = Page.Letter_V2;
Attachment attach = new Attachment();
Blob pdfBlob;
try {
pdfBlob = pdfPage.getContent();
}
catch (VisualforceException e) {
pdfBlob = Blob.valueOf('Some Text');
}
attach.parentId = ApexPages.currentPage().getParameters().get('id');
attach.Name = 'Letter - '+ system.Now() + ' .pdf';
attach.body = pdfBlob;
insert attach;
}
}
Thank you
Regards,
Ankit