You need to sign in to do that
Don't have an account?
YR
Render PDF as landscape issue ??
Hi
I tried to make the visualforce page renderas PDF in landscape with following styles
<style >
@page {
size:landscape;
}
</style>
But it is not working now. Is anybody face the same issue? or have any idea to render the PDF as landscape??
Thanks!
Following code will work...
<head>
<style>
@page {
size:landscape;
}
</style>
</head>
All Answers
The pdf renderer has some limitations, maybe this is one of them.
The usage of a specific size in the @page-elements works for me, e.g.:
@page { size: 29.7cm 21.0cm ; margin-top: 1.0cm; margin-left: 1.0cm; margin-right: 1.0cm; margin-bottom: 1.0cm; }
(european standard paper, 1cm border on each side)
hth
Ingo
Following code will work...
<head>
<style>
@page {
size:landscape;
}
</style>
</head>
Neither specifying the size as landscape or as 29.7cm, 21.0cm seams to get the rendering of PDF to actually be landscape mode. Anyone recently able to do this?
I had this problem for a while, and then I figured out that the tag <html> which I was usind was creating the problem make sure that there aren't any extra tags.
<apex:page renderAs="PDF">
<head>
<style>
@page{
size: A4 landscape;
}
</style>
</head>
<h1>Testing Landscape</h1>
Rendering PDF as Landscape
</apex:page>
This is not working in Salesforce.com API version 28.0
Just to verify, the following does work for me.
However it works in API version 26 and 27 only. Renders as portrait in API version 28.
Also, the "<head>" tag is critical - it does not work without it.
<apex:page renderAs="PDF" applyBodyTag="false" applyHtmlTag="false" showHeader="false">
<html>
<head>
<style>
@page{
size: A4 landscape;
}
</style>
</head>
<body>
<h1>Testing Landscape</h1>
Rendering PDF as Landscape
</body>
</html>
</apex:page>
<apex:page id="apex_page" standardcontroller="Day_of_Caring_Project__c" extensions="DoCProjectReportController" tabStyle="Account" renderAs="pdf" showheader="false" >
<head>
<style type="text/css">
@page
{
/* Landscape orientation */
size:landscape;
margin:0.25in;
}
</style>
</head>
That styling works (the page renders in landscape) when the page-meta.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>27.0</apiVersion>
<availableInTouch>false</availableInTouch>
<confirmationTokenRequired>false</confirmationTokenRequired>
<label>DoCMatchByAgencyReportTZ</label>
<packageVersions>
<majorNumber>2</majorNumber>
<minorNumber>0</minorNumber>
<namespace>npe01</namespace>
</packageVersions>
</ApexPage>
The page renders as incorrectly portrait when the page-mega.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>29.0</apiVersion>
<availableInTouch>false</availableInTouch>
<confirmationTokenRequired>false</confirmationTokenRequired>
<label>DoCMatchByAgencyReportTZ</label>
<packageVersions>
<majorNumber>3</majorNumber>
<minorNumber>0</minorNumber>
<namespace>npe01</namespace>
</packageVersions>
</ApexPage>
So it looks like the API Version is a very important factor when troubleshooting this problem.
AlejandroRaigon's answer works well. My page is currently in the latest 46.0 version and it works.
Thanks,
Chellappa