Forum How do I...?

How To Apply Css

arunanu86
HI i m newbie in princexml have no idea how to apply css while converting HTML to pdf using java :-

i m try something like this:-

//prince.addStyleSheet(outputPath + "bootstrap-3.css");
//prince.addStyleSheet(outputPath + "font-awesome-4.css");

its not work
Plz help its urgent.....

Thx in advance
mikeday
What is the value of outputPath? Does it end with a slash? Is this the directory where the CSS files are located?

It may help to check the Prince output log for errors or warning messages.
arunanu86
value of outputPath like a css location...

C:\Users\Arun\Desktop\PdfContainer\bootstrap-3.css

also i m using gui interface load js css but file are not created as like in html......
mikeday
Hmm, I think you will need to check the output log. Is a PDF file getting created at all?
arunanu86
using setLog() method and pass log path here is log :-

Fri Apr 24 14:36:32 2015: ---- begin
Fri Apr 24 14:36:32 2015: Loading document...
Fri Apr 24 14:36:32 2015: Applying style sheets...
Fri Apr 24 14:36:33 2015: Preparing document...
Fri Apr 24 14:36:33 2015: Converting document...
Fri Apr 24 14:36:33 2015: finished: success
Fri Apr 24 14:36:33 2015: ---- end


what i can do so document looks same as web page also css work file.....
mikeday
By default, Prince assumes @media print. So if your style sheets use @media screen, they may not apply. You can call Prince.setOptions("--media=screen") to check this.

It may be helpful to experiment from the command-line first, and try applying some color in your CSS, eg. "color: red" or "background: blue" and see if it applies.
arunanu86
Thx it will help few color are shown here but there are only single html page and its convert to 4 page left first page blank .... content are not formatted as like in web page
mikeday
Okay it is difficult to tell what is going wrong without seeing the document. You could attach the HTML + CSS here, or email it to me (mikeday@yeslogic.com).
arunanu86
Chk your inbox