How to get the font style of a paragraph - docx4j

I am a newbie for docx4j and for my application I need to identify the sentences (or paragraph) is in bold. I cannot figure out how to get the font style details for a particular paragraph. Any help is appreciated

You need to look for w:rPr/w:b, that is, for the bold tag within the run properties element.
This can be in a run (w:r) within a paragraph (w:p), or within a style referenced from the run's style (w:rPr/w:rStyle if present) or the paragraph's style (w:p/w:pPr/w:pStyle, for example Heading1).
Since styles can be based on other styles, you need to climb the style hierarchy to check for bold.
The easiest way to do what you want is to mimic the PDF output; see https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/convert/out/fo/XsltFOFunctions.java
line 242 for the PPr level stuff
line 776 for the RPr level stuff
I assume you can work out how to visit each paragraph (see GettingStarted); probably you ought to traverse in Java (as opposed to via XSLT).

Related

Does a DCL Fonts Reference Exist?

I'm was going reviewing a few autolisp and dcl tutorials (afralisp & autolisp-exchange) to brush up on the dcl code. To cut to the question, I see that the text can be underlined by the mnemonic in afralisp and the & in autolisp-exchange.
Is there a better way to underline a string of characters?
Can a string be made bold, italicized, or strike-though with this
file type?
If the above is true, is there a reference webpage that has a list of fonts that can be used with the dcl file type?
This webpage may contain the solution, but I haven't seen how: AutoDesk.com
In short, you cannot arbitrarily change the GUI font face or style using standard DCL.
The ability to underline text is purely an exploit of the mnemonic property which allows DCL controls to be manipulated using keys on the keyboard which correspond to the underlined letters as opposed to using the mouse to click such controls.
Whilst DCL text has the is_bold property, this has never worked (and likely never will). One alternative is to feign bold text using the set_tile function in conjunction with an image tile; or you can use the fixed_width_font property, but, as the name implies, this will change the text to use a fixed width font (the exact font cannot be changed).
One other possibility is to display text using the vector_image function applied to an image tile, as I demonstrate in the 'About' dialog for my Incremental Numbering Suite application.

Highlighting text?

I've been searching for a while to know how Highlighting text (books on PDF, epub, mobi) works programmatically, what kind of code or tech stays behind this feature, yet I couldn't find anything. If you know, please share any hint here.
Thnx in advance
For PDFs you can highlight text by adding a highlight text markup annotation:
12.5.6.10 Text Markup Annotations
Text markup annotations shall appear as highlights, underlines, strikeouts (all PDF 1.3), or jagged (“squiggly”)
underlines (PDF 1.4) in the text of a document. When opened, they shall display a pop-up window containing
the text of the associated note. Table 179 shows the annotation dictionary entries specific to these types of
annotations.
(ISO 32000-1)
You can find details in Table 179. For a specification of annotations in general, read the earlier subsections of section 12.5 Annotations.
Alternatively you can also add the highlighting into the page content. This has the disadvantage that others cannot easily change the highlight (which actually might be an advantage in some use cases). Depending on the PDF viewers to support you might be forced to do this, though.

Bullet list types in Migradoc

How can i give user defined ListType using Migradoc. I have found 6 types of Listtypes.
In those Bulletlist3 is the square but i need to give bigger size square so, how can i give that?
AFAIK you cannot use custom bullet list symbols with MigraDoc.
When we needed this, we just added an empty paragraph, used AddFormattedText to add the bullet symbol (we also needed big squares), added a tab, then came the normal text.
Set the paragraph style properly as discussed here:
https://stackoverflow.com/a/9635220/1015447

purpose of vertical bar in programming IDEs/Editors

In this example. I'm using Phpstorm Code Editor and I wonder the purpose of this Vertical Bar
This is a visual limiter of the line length.
Usually the code convention in programming languages or in particular project requires to have the line of code to be limited by length.
For example Python's PEP 8 coding convention requires it to be limited to 79 characters.
So basically this limiter in your text editor or IDE is just made for convenience to help you to control the maximum line length in your code. Usually you can set-up the maximum code line length in the settings.
From: http://www.jetbrains.com/phpstorm/webhelp/editor-appearance.html
Show right margin (configured in Code Style options) Select this check box to have a thin vertical line at the right margin of the editor displayed. Refer to the description of the General page of the Code Style settings.
From: http://www.jetbrains.com/phpstorm/webhelp/editor-appearance.html
Right Margin (columns) In this text box, specify the number of columns to be used to display pages in the editor.
Wrap when typing reaches right margin Select this check box to ensure that edited text always fits in the specified right margin.
So you can probably disable it if you want...

Formatting plain text output for printing?

I have a program that outputs a report into plain text. The report must be plain text for it to load into a third party program. The report also needs to be printable.
When dealing with plain text, what limits should I set on line size and number of lines on a page to get it to print reasonably?
It definitely depends on the font you use when printing, and unless you have control over that you can't guarantee it will print nicely. For example, in Word 2007, creating a blank document and setting the font to Courier New 10pt only fits 77 characters per line and 28 lines per page. Changing the margins and line spacing will modify that. However if you used that and they tried to print from Wordpad it wouldn't work because the default with Courier New 10pt only fits 72 characters per line. In either case, the standard 80 characters doesn't work. Those defaults aren't even global defaults.
The best you can probably do is pick a size and provide instructions on printing the report with several common editors so it will look acceptable. Specify the font, margin, line spacing, etc.
Have you considered other options, like creating two files? One could be plain text for import into the other program. The other could be a format better suited for printing.
its going to depend on your printing font, you want to aim for a fixed width font so that it is consistent, 80 columns is generally safe.... i think....
edit: here is a quick guide I googled - http://dsl.org/cookbook/cookbook_17.html
If you have control over the output format, consider a lightweight WYSIWYG markup language, Such as reStructuredText, AsciiDoc, markdown etc.
This way you can pipe the plane-text format into a converter that will result in postscript, PDF or HTML, that you can then print. This also mostly negates the need to consider the line width for the sake of your printer. The converter will do this for you.