Not able to apply css styling to pdf
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 1
- Joined: Mon Jun 03, 2024 11:29 am
Not able to apply css styling to pdf
Hi,
I am working on
The end result is plain black and white. But I want to add styling to the document using custom css.
I have followed all the steps in
https://www.youtube.com/watch?v=rs04iX_RdIk
and
https://www.oxygenxml.com/doc/versions/ ... yling.html
But they still doesn't seem to work using css class. Though I am able to apply css only using the tags, but not using the class.
Here is the example of code I am using:
custom.css
file.dita
I am working on
where I need to generate it in pdf format.API documentation
The end result is plain black and white. But I want to add styling to the document using custom css.
I have followed all the steps in
https://www.youtube.com/watch?v=rs04iX_RdIk
and
https://www.oxygenxml.com/doc/versions/ ... yling.html
But they still doesn't seem to work using css class. Though I am able to apply css only using the tags, but not using the class.
Here is the example of code I am using:
custom.css
Code: Select all
.key {
background-color: red !important;
}
*[outputclass~="key"] codeblock,
*[outputclass~="key"] pre,
*[outputclass~="key"] code {
background-color: red !important;
text-align: center;
}
Code: Select all
<codeblock outputclass="key" id="codeblock_jzg_2z1_lbc">
{
"reponseMsg": "Request is successfully recieved but it is still in progress.",
"requestId": "xxxbc8bf20xxx0000",
"statusCode": 202,
"message": "OK",
"timeGenerated": "2023-02-11T00:00:00.000Z"
}
</codeblock>
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Not able to apply css styling to pdf
Post by julien_lacour »
Hello,
This is normal, the selectors are incorrect for your use-case, for example if you translate *[outputclass~="key"] codeblock this means "any element whose outputclass contains 'key' having a descendant codeblock". This isn't your case as the outputclass is in the codeblock, not in an ascendant node.
A correct selector could be:
Or directly
Or using both class and outputclass:
Regards,
Julien
This is normal, the selectors are incorrect for your use-case, for example if you translate *[outputclass~="key"] codeblock this means "any element whose outputclass contains 'key' having a descendant codeblock". This isn't your case as the outputclass is in the codeblock, not in an ascendant node.
A correct selector could be:
Code: Select all
codeblock[outputclass~="key"]
Code: Select all
*[outputclass~="key"]
Code: Select all
*[class~="pr-d/codeblock"][outputclass~="key"]
Julien
-
- Posts: 1
- Joined: Mon Jun 03, 2024 11:29 am
Re: Not able to apply css styling to pdf
Hi Julien,
Thanks for you reply. I tried the code you sent but still the same. The class doesn't seem to work. Could it be the case that I am missing any setting or making any other syntax error?
FYI, I have added the reference of the class in .opt file and also added as a parameter in args.css.
Also, as mentioned earlier, the styling using tags seem to work too, it's just the css class that is not working.
Below is the styling that is working using tags:
Thanks
Thanks for you reply. I tried the code you sent but still the same. The class doesn't seem to work. Could it be the case that I am missing any setting or making any other syntax error?
FYI, I have added the reference of the class in .opt file and also added as a parameter in args.css.
Also, as mentioned earlier, the styling using tags seem to work too, it's just the css class that is not working.
Below is the styling that is working using tags:
Code: Select all
code,
pre {
font-family: "Courier New", Courier, monospace;
background-color: #2c3e50; /* Dark grey background */
color: #f8f8f2; /* Light text color */
padding: 15px;
display: block;
overflow: auto;
}
pre {
padding: 15px;
background-color: #2c3e50; /* Dark grey background */
color: #f8f8f2; /* Light text color */
border: 1px solid #444444;
border-radius: 5px;
margin: 10px 0;
}
Last edited by takolkar on Mon Jun 03, 2024 1:08 pm, edited 1 time in total.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: Not able to apply css styling to pdf
Post by julien_lacour »
Hello,
All the class selectors should work from the moment they are valid and you run the DITA Map PDF - based on HTML5 & CSS transformation scenario.
You can try to debug your CSS to see which rules are applied and which are not. You simply need to open the merged.html file in your favorite browser and inspect it.
Regards,
Julien
All the class selectors should work from the moment they are valid and you run the DITA Map PDF - based on HTML5 & CSS transformation scenario.
You can try to debug your CSS to see which rules are applied and which are not. You simply need to open the merged.html file in your favorite browser and inspect it.
Regards,
Julien
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service