LGS Member Licensed User Longtime User Mar 4, 2024 #1 Hello everyone I am creating a word document trying to justify a paragraph. $"[p Alignment=Center]text here[/p]"$ I have tried to use all the constants described in: https://poi.apache.org/apidocs/dev/org/apache/poi/xwpf/usermodel/ParagraphAlignment.html But I can only adjust the text, and I can't justify it I found the following: https://stackoverflow.com/questions/43427006/how-can-i-do-to-justify-a-paragraph-with-apache-poi I included the following: Me.as(JavaObject).RunMethod("justifica", Array(doc.XWPFDocument.RunMethod("getParagraphArray",Array(1)))) #if java import org.apache.poi.xwpf.usermodel.*; public static void justifica(XWPFParagraph ParagraphToModify) { //ParagraphToModify.setAlignment(ParagraphAlignment.BOTH); //ParagraphToModify.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE); ParagraphToModify.setAlignment(ParagraphAlignment.DISTRIBUTE); } #EndIf But equally the text is not justified, it is only aligned. Small program attached I would like to know if there is a way to justify the text of a specific paragraph. Thanks in advance Attachments WordExample.zip WordExample.zip 16.2 KB · Views: 402
Hello everyone I am creating a word document trying to justify a paragraph. $"[p Alignment=Center]text here[/p]"$ I have tried to use all the constants described in: https://poi.apache.org/apidocs/dev/org/apache/poi/xwpf/usermodel/ParagraphAlignment.html But I can only adjust the text, and I can't justify it I found the following: https://stackoverflow.com/questions/43427006/how-can-i-do-to-justify-a-paragraph-with-apache-poi I included the following: Me.as(JavaObject).RunMethod("justifica", Array(doc.XWPFDocument.RunMethod("getParagraphArray",Array(1)))) #if java import org.apache.poi.xwpf.usermodel.*; public static void justifica(XWPFParagraph ParagraphToModify) { //ParagraphToModify.setAlignment(ParagraphAlignment.BOTH); //ParagraphToModify.setAlignment(ParagraphAlignment.THAI_DISTRIBUTE); ParagraphToModify.setAlignment(ParagraphAlignment.DISTRIBUTE); } #EndIf But equally the text is not justified, it is only aligned. Small program attached I would like to know if there is a way to justify the text of a specific paragraph. Thanks in advance
teddybear Well-Known Member Licensed User Mar 4, 2024 #2 I don't understand totally your question, is this the result which you want? Upvote 0
LGS Member Licensed User Longtime User Mar 4, 2024 #3 Hello The images I showed are the result of using "THAI_DISTRIBUTE" and "DISTRIBUTE", which fill the first line with white spaces. When using "DISTRIBUTE" the word "erat." distributes it throughout the line, filling it with white spaces Apparently it is something related to the end of line when creating text with paragraphs [p][/p] What I need? Justify unfilled lines with white spaces Something like that: Upvote 0
Hello The images I showed are the result of using "THAI_DISTRIBUTE" and "DISTRIBUTE", which fill the first line with white spaces. When using "DISTRIBUTE" the word "erat." distributes it throughout the line, filling it with white spaces Apparently it is something related to the end of line when creating text with paragraphs [p][/p] What I need? Justify unfilled lines with white spaces Something like that:
teddybear Well-Known Member Licensed User Mar 4, 2024 #4 LGS said: Something like that: View attachment 151456 Click to expand... Isn't this ParagraphAlignment.LEFT? Upvote 0
LGS said: Something like that: View attachment 151456 Click to expand... Isn't this ParagraphAlignment.LEFT?
LGS Member Licensed User Longtime User Mar 4, 2024 #5 No This was justified directly from Word. To show the format I need. Upvote 0
LGS Member Licensed User Longtime User Mar 4, 2024 #6 I found a way using THAI_DISTRIBUTE When creating multiple lines in a single paragraph using $""$ B4X: [p alignment=THAI_DISTRIBUTE] here multiple lines [/p] For some reason unknown to me, it is not justified correctly(fill in the lines with blank spaces). Code: Dim parrafos() As String = Regex.Split(Chr(10), paragraphs) Code: For x=0 To parrafos.Length-1 Log(parrafos(x)) paragraphs = paragraphs & Chr(10) & $"[p alignment=THAI_DISTRIBUTE]${parrafos(x)}[/p]"$ ' & chr(10) NOT NECESSARY. JUST TO SEE THE LOG Next I don't know if it's the most efficient, but it works for me. I attached a small program in case someone needs it. I appreciate the help ? Attachments WordExample.zip WordExample.zip 15.9 KB · Views: 392 Upvote 0
I found a way using THAI_DISTRIBUTE When creating multiple lines in a single paragraph using $""$ B4X: [p alignment=THAI_DISTRIBUTE] here multiple lines [/p] For some reason unknown to me, it is not justified correctly(fill in the lines with blank spaces). Code: Dim parrafos() As String = Regex.Split(Chr(10), paragraphs) Code: For x=0 To parrafos.Length-1 Log(parrafos(x)) paragraphs = paragraphs & Chr(10) & $"[p alignment=THAI_DISTRIBUTE]${parrafos(x)}[/p]"$ ' & chr(10) NOT NECESSARY. JUST TO SEE THE LOG Next I don't know if it's the most efficient, but it works for me. I attached a small program in case someone needs it. I appreciate the help ?