You need to sign in to do that
Don't have an account?
liron169
Open page as Word instead as PDF
I have VF page render as PDF, with some CSS definitions (including Footer, Header).
Now I want to create similar page as Word.
Appriciate if someone can advise if, at all, I can controll the layout in word in same level I can in PDF?
And if so, what generally I should change from the original page (this as PDF)?
except to replace the renderAs="PDF" --> contentType="application/msWord", is modifying the CSS file will be enough?
If you want the Word file to look exactly like the PDF, you are in for a world of pain. To get the page to render as a word file, yes, all you really have to do is changed the contentType to application/msword; charset=Windows-1252#docname.doc (you only need the #docname.doc if you want to specify the name for the doc.
You also want to put in cache="true" in the apex:page tag
On top of all that, word doesn't look at an external style sheet staticresource, so you will have to code all your MS CSS in the <style></style> tags. If you want any page control in that word document throw in the following in the style tags:
"@page WordSection1
{size:8.5in 11.0in;
margin:0.5in .75in;
mso-footer-margin:.25in .5in;
mso-paper-source:0;
mso-footer:f1;
}"
The above also has footer stuff in it too. If you wanted to get the page number, throwing in this would help
div.WordSection1
{page:WordSection1;}
p.MsoFooter, li.MsoFooter, div.MsoFooter {
mso-pagination:widow-orphan;
}
When rendering images, you cannot use static resources or attachments, you must use documents, and put in the full url of the image, and use ImageServer like so: https://c.cs14.content.force.com/servlet/servlet.ImageServer?id={docId}&oid={!YourOrgID}
When making your page, wrap the whole thing in a div with the class of WordSection1.
You might as well do a whole other VF page since PDF and Word require different coding. Hope all this helps, I had to go looking in many different places (and correct it) to find all this stuff out.
Hi,
Thanks a lot for all the advices.