So I've been trying to make use of some heading styles in Apache POI. These are loaded from a template with the following code:
val document = XWPFDocument(template.inputStream)
val par = document.createParagraph()
par.style = "Heading 1"
Here, template is a Spring Resource.
The styles I am using are confirmed to exist in the template, they are named 'Heading 1', 'Heading 2', etc.
When I apply one of the styles to a paragraph, I am met with disappointing results. The paragraphs with these styles lack the styles whatsoever, even though the styles are still present in the document. The worst part is, that this occurs only in Microsoft Word, LibreOffice has no issues with using the template styles. Regrettably, I am required to use Microsoft Word.
I've found out, that when the template has some text using these styles present, the problem does not occur. These 'style holders' however, cannot be present in the final document, so I cannot use that.
Is there any way to make Microsoft behave properly and use these styles properly?
Result when opened in Microsoft Word
Result when the same file is opened in LibreOffice
I can define my own styles in accordance with solutions to this question: How can I use predefined formats in DOCX with POI?
but I have no idea how to create a style with the numbering included, so that is why I've been trying to use the template styles.
I suppose this isn't an issue many people face, but I wanted to offer a workaround I ended up using.
So I've found, that you do not need to have all the styles used in the template, only one of them was sufficient for word to not delete any of them. So I placed the largest header into the document template, and then used docx4j stamper to make the header have the desired text.
The result works fine, but I suppose it is not a generic solution to this issue.
Related
I am trying to find an answer several days but not able to.
How can I add custom styles just like in Ckeditor 4 (For example, using CKEDITOR.stylesSet.add) ?
Thanks
Edit the CkEditor css file in its entirety, that can be found at This guide
From the page:
By default, content styles are loaded by the editor JavaScript which makes them only present
when users edit their content and this, in turn, usually takes place in the back–end of an application. If you want to use the same styles in the front–end, you may find yourself in a situation that requires you to load CKEditor just for that purpose, which is (performance–wise) not the best idea.
To avoid unnecessary dependencies in your front–end, use a stylesheet with a complete list of CKEditor 5 content styles used by all editor features. There are two ways to obtain it:
By taking it directly from this guide and saving it as a static resource in your application (e.g. content-styles.css) (recommended).
By generating it using a dedicated script. Learn more in the Development environment guide.
Load the content-styles.css file in your application by adding the following code to the template:
I would like to know if there's any shorthand to fill the empty vue file with all three tags: template, script and style with proper default content.
As a comparison, at least, VS Code allows to autofill an html file with all default required tags/codes on ! + Enter. I want to know if there's something alike in VS Code or Vetur extension.
I've personally never used it but this seems to do what you're looking for. There seems to be a lot of different configuration options as well.
#seven-phases-max I have refactored my code a few times based mostly on your answers to my stackoverflow.com posts but would like to get your feedback to my latest and hopefully final variation:
Ultimately I ended up using :extend to get copies of css properties of styles not under my control:
Below is example of approach I've used in several places create css from base css/less selectors defined in less files outside of my control and optionally over-ridden in another less file outside my control:
.CODE-COLORING-ICON {opacity: 0.0};
Below code works works with and w/o above css / mixin line
.CodeMirror-gutters:before,
.CodeMirror-gutters:hover:after {
&:extend(.CODE-COLORING-ICON);
}
In other places, I created created empty selectors fearing less would not like an extend like above with ".CODE-COLORING-ICON" not defined. I was surprised the above code worked.
The end game is to merge css from theme with override values from another file.
I have to download CSS file and apply style sheet to my app. I downloaded this file at the local folder and referenced it as
style.href = "ms-appdata:///local/css//custom.css";
and appended to head as
document.getElementsByTagName('head')[0].appendChild(style);
after document onready event.
Seems it has no effect (but I can see this element in the dom browser).
So is there any restriction for css source: app package, local folder? May be this impossible to reference downloaded CSS due to MS limitations? Or may be I'm doing something wrong? Any suggestions?
Do keep in mind, however, that you can access the document.styleSheets collection and list, add, or remove CSS rules dynamically from JavaScript. You can access the individual rules themselves through the DOM using statements like document.styleSheets[0].cssRules[0].style.color = "red" or you if you've fetched yourself some custom CSS text (dynamically from your other CSS file online) you can add its styles to one of your active style sheets using something like document.styleSheets[0].cssText = "{my CSS code}". Do be sure that you're manipulating the right style sheet by checking the document.styleSheets[0].href.
I think you're out of luck trying to head down that path.
Note that, for security reasons, you cannot navigate to
HTML you have downloaded to this location and you cannot
run any executable or potentially executable code, such
as script or CSS.
Source: http://msdn.microsoft.com/en-us/library/windows/apps/hh781215
Also, this blog post seems possibly helpful: http://palermo4.com/post/How-to-Use-IFrames-in-WinRT-Apps.aspx
The wxWidgets library includes a simple HTML parser and viewer, which I'm trying to use to display some simple HTML. I'd like to make certain links (the ones that go to items that don't yet exist) a different color, or otherwise indicate that they need to be created, but I don't see any obvious way to do so.
Does anyone know of a way to do this?
Use the color CSS Style for span (Something like
<span style='color:red;'>Red Link</span>). Here is a quote from class' documentation here
List of supported styles
wxHTML doesn't really have CSS support but it does support a few
simple styles: you can use "text-align", "width", "vertical-align" and
"background" with all elements and for SPAN elements a few other
styles are additionally recognized:
color
font-family
font-size (only in point units)
font-style (only "oblique", "italic" and "normal" values are supported)
font-weight (only "bold" and "normal" values are supported)
text-decoration (only "underline" value is supported)
See: https://docs.wxwidgets.org/3.1/overview_html.html