Skip to content

Instantly share code, notes, and snippets.

@kevanmoothien
Last active February 16, 2018 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevanmoothien/9be28563888f10736aea3293c51af920 to your computer and use it in GitHub Desktop.
Save kevanmoothien/9be28563888f10736aea3293c51af920 to your computer and use it in GitHub Desktop.
Render a Visualforce as Pdf
<apex:page standardController="Contact"
applyHtmlTag="false"
showHeader="false"
renderAs="pdf">
<html>
<head>
<style>
@page {
size: 6.4in 4.5in;
}
.center {
margin: auto;
width: 60%;
padding: 20px;
}
</style>
</head>
<body>
<div>
<img src="https://kevan-dev-ed--c.eu15.content.force.com/servlet/servlet.ImageServer?id=0151p000004v4JH&oid=00D24000000e1d4&lastMod=1518775947000" />
</div>
<apex:outputPanel layout="block" styleClass="center">
<apex:outputText value="{! Contact.Name }"></apex:outputText>
<br/>
<apex:outputText value="{! Contact.MailingStreet }"></apex:outputText>
<br/>
<apex:outputText value="{! Contact.MailingCity }"></apex:outputText>
, &nbsp;
<apex:outputText value="{! Contact.MailingState }"></apex:outputText>
&nbsp;
<apex:outputText value="{! Contact.MailingPostalCode }"></apex:outputText>
<br/>
<apex:outputText value="{! Contact.MailingCountry }"></apex:outputText>
<br/>
<apex:outputText value="{! Contact.Phone }"></apex:outputText>
</apex:outputPanel>
</body>
</html>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment