You need to sign in to do that
Don't have an account?
Niki Shah 12
how to add image in apex code
<apex:page Controller="OrderAcknowledgement" renderAs="pdf" applyBodyTag="false" docType="html">
<head>
<style>
body { font-family: 'Arial Unicode MS'; }
.companyName { font: bold 30px; color: red; }
</style>
</head>
<body>
<center>
<h1>New Account Name!</h1>
<apex:image id="theImage" value="{!IMAGEPROXYURL('https://swifterfans.com/wp-content/uploads/sites/3/2018/10/SWIFTER-FINAL-SD.png')}" alt="Description of image here"/>
<img src="https://swifterfans.com/wp-content/uploads/sites/3/2018/10/SWIFTER-FINAL-SD.png" alt="Description of image here"/>
<apex:panelGrid columns="1" width="100%">
<apex:outputText value="{!a.Name}" styleClass="companyName"/>
<apex:outputText value="{!NOW()}"></apex:outputText>
</apex:panelGrid>
</center>
</body>
</apex:page>
<head>
<style>
body { font-family: 'Arial Unicode MS'; }
.companyName { font: bold 30px; color: red; }
</style>
</head>
<body>
<center>
<h1>New Account Name!</h1>
<apex:image id="theImage" value="{!IMAGEPROXYURL('https://swifterfans.com/wp-content/uploads/sites/3/2018/10/SWIFTER-FINAL-SD.png')}" alt="Description of image here"/>
<img src="https://swifterfans.com/wp-content/uploads/sites/3/2018/10/SWIFTER-FINAL-SD.png" alt="Description of image here"/>
<apex:panelGrid columns="1" width="100%">
<apex:outputText value="{!a.Name}" styleClass="companyName"/>
<apex:outputText value="{!NOW()}"></apex:outputText>
</apex:panelGrid>
</center>
</body>
</apex:page>
When rendering vf pages as pdf you must use static resource, something like below
I hope you find the above solution helpful. If it does mark as best answer to help others too.
Thanks,
Ramesh D
Error: Static Resource named PdfImage does not exist. Check spelling
you must zip all your images and upload under setup--> static resources-->New
Name the zip folder as PdfImage or what ever you wish then replace 'imagePdfFile.png' this to the image name
Follow this link
https://ccoenraets.github.io/salesforce-developer-advanced/Using-Static-Resources.html
Thanks
Ramesh
Try this code it is showing the image.
For static resource you -
- First you should create a zip file for you image.
- Search static resource in Quick find box.
- Click new and upload zip file .
If you face any problem then complete this trialhead.
https://trailhead.salesforce.com/en/content/learn/modules/visualforce_fundamentals/visualforce_static_resources
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Greetings to you!
I Have tested with two lines; it is working for me in chrome. Which browser are you using?
Please copy paste this code and see if it works.
<apex:page >
<apex:image value="{!URLFOR($Resource.vfimagetest,'cats/kitten1.jpg')}"/>
<apex:image value="{!URLFOR($Resource.vfimagetest,'cats/kitten1.jpg')}"/>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.