function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mélanie TexereauMélanie Texereau 

Add PDF Document to VF Page

Hi,

I have a PDF Quote which is a VisualForce Page, and I would insert a "terms and conditions" document (is a PDF file) in my Visualforce page.

It is possible ? I try to use :

- <apex:image>
- <apex:iframe>
- <object>

and it doesn't work...

Do you have any ideas ?
Best Answer chosen by Mélanie Texereau
Mélanie TexereauMélanie Texereau
Finally,

I convert my PDF file to PNG and put it in static resource. Then, I recuperate this resource in my Visualforce page.

Thanks for your help sunny522.


All Answers

Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
<apex:inputfile> will help you i guess
Mélanie TexereauMélanie Texereau
Thank you for your help,

<apex:inputfile> isn't for my problem, I think... 

I recuperate a document PDF in Document object ( my document has an id, name, a file associated, etc) and I would display the content of this PDF in my Quote PDF. 
sunny522sunny522
Hi Texereau,
              you can generate terms and conditions pdf document in one vf page named " page1" . You can now include this vf page in main vf page where you generate Quote pdf.

sample code will be as below.

<apex:page controller="cls_printpage1" sidebar="false" showHeader="false" renderAs="pdf">
<apex:include pageName="PDFDownload"/>
You can include the code that should be displayed in main vf page
</apex:page>


Mélanie TexereauMélanie Texereau
Hi Sunny522,

Your solution is interesting but how to insert my PDF content of "terms and conditions" in Visualforce ? I can insert image but a file PDF I don't know ...
sunny522sunny522
Hi Texereau,
       you can display "terms and conditions" in vf page using apex controller and then you can use renderas="pdf" in vf page.If you are unable to do like this can u give more description how "terms and conditions " are displayed?whether that is static. or it is generated by some logic?
Mélanie TexereauMélanie Texereau
My "terms and conditions" is a document. It's a static resource. Document is a standard object of Salesforce. With this document I attached a PDF file which represents terms and conditions of my company. 
In my class I recuperate this document with soql : 
String nomFichier = 'conditions_' + myDev.SocieteProprietaire__r.Name;
doc = [SELECT Id, Name, Body
              FROM Document 
              WHERE Name =: nomFichier
              LIMIT 1];
and I would display this document in my visualforce page after my code which display a quote information.

Thank you for your help Sunny522


sunny522sunny522
Hi Texereau,
  you can directly display terms and conditions in vf page by querying static resource in controller.

StaticResource resource=[SELECT Id, Body FROM StaticResource WHERE id=:idofstaticresource];

try in this way and let me know if any issues
Mélanie TexereauMélanie Texereau
I try to do this : 
<apex:outputText value="{!doc.Body}" escape="false" />
doc = [SELECT Id, Name, Body FROM StaticResource WHERE Name=: nomFichier];

But when I open my PDF Quote, I have this : core.filemanager.ByteBlobValue@7364c3ce

How to display Blob value ?
sunny522sunny522
Hi Texereau ,
           You can place "terms and conditions " in notepad as text file and then place this file as static resource.Then create class like this
public class NotepadContent {

   public List<StaticResource> docs;
   public String content{get; set;}
   public NotepadContent() {
       docs = [SELECT Id, Name, Body FROM StaticResource WHERE Name = 'Notepad'];
       System.debug('******************'+docs);
       for(StaticResource d : docs) {
           content = d.Body.toString();
           System.debug('******************'+content);
       }
   }
}

visualforce page :

<apex:page controller="NotepadContent" >
   <h1>{!content}</h1>
</apex:page>

let us know if it worked
Mélanie TexereauMélanie Texereau
Finally,

I convert my PDF file to PNG and put it in static resource. Then, I recuperate this resource in my Visualforce page.

Thanks for your help sunny522.


This was selected as the best answer