You need to sign in to do that
Don't have an account?
Pooja05
Rendering a page as pdf with landscape layout
Hi,
I want to render a page as PDF but the table has too many columns and looks messy in a potrait style layout.
How can I change it to landscape layout?
thanks,
Pooja
Hi Pooja,
Try this:
<apex:page renderas="pdf"> <style> @page { size: landscape; } </style> </apex:page>
Hope that helps,
Sati
<apex:page renderAs="pdf">
<style>
@page
{
size:landscape;
}
</style>
<apex:outputText value="Hi"/>
</apex:page>
I tried it, but it doesnt work.
I'm missing something or there is an issue here. I have placed an @page { size:landscape;} block into a css file and uploaded it as a static resource named landscapePDF. This is what I have in my Visuleforce page...
But when the PDF is rendered it is not landscape.ThePDF producer is iText 2.0.8 and the PDF version is 1.4(Acrobat 5.x)
Try this:
<apex:stylesheet value="{!URLFOR($Resource.landscapePDF)}"/>
URLFOR() isn't doing it either. I removed the renderAs attribute from the page tag so I could look at the HTML markup and see if the link tag was even being added and what I found was the link tag was added but the href attribute was missing the .css file extension. So I did this...
and then this...
Both approaches added the correct href in the link tag but that still didn't solve the problem after resetting renderAs back to pdf. So I have confirmed that the link tag is being added and that the href is correct when rendering as a normal HTML page but when rendering as PDF it looks like its not picking up the stylesheet at all.
Oops... You shouldn't add .css to the href. That has nothing to do with it. I added a class to my stylesheet and set a background-color and then set a div tag class attribute to that class. The pdf is rendered and the div tag shows the background color I set in the stylesheet. So the stylesheet is picked up but still no landscape.
Is it an error with my css file...
Hi!! All of the posts are correct but they're only missing <head> tag. I have this code and works fine:
<apex:page renderAs="PDF">
<head>
<style>
@page{
size: landscape;
}
</style>
</head>
<h1>Testing Landscape</h1>
Rendering PDF as Landscape
</apex:page>
Tall timber tree landscaping service (https://talltimbertree.com/residential-landscaping-services/) Get in touch with us today to give your gardens the highest caliber of care around.