How can I apply these settings (especially "Default Spacing") programmatically to a docx created with Apache POI?
(image source)
Currently I add tabs with
XWPFParagraph paragraph = document.createParagraph();
XWPFRun text = paragraph.createRun();
text.addTab();
but it looks just like a space until I manually adjust the spacing in Apple Pages...
EDIT: I googled a bit and extracted the content of my docx to compare it with what I want. It seems text.addTab(); adds a "Tab Character", while I am looking for a (set of) "Custom Tab Stops".
I faced the same problem a few month ago, and I found proper solution to give "tab(\t)" space in '.XLSX' file.
Instead of cell.setCellValue("\t");
you can give space like this
cell.setCellValue(" "); (just give multiple empty spaces...)
Related
I'm not familiar with pdf rendering system or postscript, and I'd like to know if in principle - it would be possible to extract the location of a string in a pdf. that is:
given a pdf with regular text paragraphs (not form-fileds\text boxes or other objects, simple text)
search for a specific string in the file
get the x,y coordinates of that the first letter.
I've searched pdf-libs in many languages but they don't seem to allow such operation.
does pdf standard supports this?
The closest thing I could find involves finding the location of a text box
(see here)
Depending on your use case, this could help.
for instance, in my case, I wanted to replace a specified string with another string. A possible solution for me:
Include a text box in the original pdf (the author of the pdf can do that using adobe acrobat pro or equivalent)
Find the text box using code and extract it's location
remove the text box from the document and insert your text at the extracted position.
I'm using the Kotlin language on Android Studio. I created a method where the contents of a txt file I saved get displayed in a textview.
textView.setText(stringBuilder.toString()).toString()
In this txt file, there are line breaks that have been created using \n when creating the file in the first place, but it does not appear when it's in the textview. When I look at the file itself, all the lines are formatted the way they should be, but never are in the textview. What can I do to fix this?
You should use maxLines and minLines attributes in your XML, for example:
android:maxLines="6"
android:minLines="2"
EDIT :
just don't forget to set the maxLines bigger than the biggest posibility data.
I'm just started to programming in android studio and need to add a ton of text, but if I just paste all the text in the text field of the TextView component, then I get a mess. Tried to insert in the code of .xml, correcting paragraphs, but all the same it turns out not that. Therefore, several questions arose:
What is the most correct way to add a ton of text to the content? (Please refer to the details)
How can I make the text inserted correctly, with paragraphs, etc.? (Ie so that they are observed)?
All of this question's about ton of text.
Thank you very much in advance!
You can add all your text in a .doc file, format it in the way you want, then in your code, you load this file and output it to your TextView.
You need to make sure you import this file as an asset in your project or either load it from the device storage.
Please check this SO post: How to read .doc file?
And check this to see How to import file to assets
I have been given a layout file, .lyt ,which gives me information on how to interpret a fixed width file. I need to convert this file into a comma delimited file. Normally this process is one or two files so i just do it using excels data tools by hand creating the delimitation based on reading the layout and applying it. Now however I have a multiple files with different layout files I need to apply to each and this could become tedious. I remember once seeing someone apply this type of file directly using either notepad ++ or excel but after an exhaustive google search I cannot find a tutorial on how to apply a layout file to a fixed width file to create a csv file without direct human intervention. Does anyone know how to do this?
below is a sample of what is in the layout file
Seq Position Name Length
1 1-3 Title Code Full 3
2 4-17 Given Name 14
3 18-18 Middle Initial 1
4 19-48 Surname 30
To all future users I could not find a solution but I did find a workaround using excels own data tools. Going to the data tab, go to get external data, From Text. From there follow the wizard. Im sorry I could not find the proper solution I know exists.
I am developing simple page using JSF richFaces. I displayed file content into textArea using tinyMCE.
The file have more number of lines. But tinyMCE editor show all content in
single line .
Original File content is :
sample.txt
This
is
tiny MCE editor
related doubt
I read the file content using the follwing code
String content = org.apache.commons.io.FileUtils.readFileToString(fileName);
System.out.println("File Contnet is : " + content);
fileBean.setFileContent(content);
System.out.println show the content as line by line. But the editor shows the content in single line
like
This is tiny MCE editor related doubt
Help me.
Thanks in advance.
The problem is that the file content you have is "plain text" while TinyMCE is designed to edit HTML.
In HTML, whitespace, including line breaks are ignored. As such, in the editor, you will see a single line of text.
One approach to solve this would be to parse the content prior to setting it in the editor and wrap the lines in Paragraph tags. For example,
<p>This</p>
<p>is</p>
<p>tiny MCE editor</p>
<p>related doubt</p>
To do this, you could use the onBeforeSetContent Event on the editor. The documentation on the event has an example of manipulating the HTML.
Assuming you are then planning to store the HTML in the backend, then there is no need to strip this HTML out when you save the content. If you aren't then the question is why you are using TinyMCE and not a simple TextArea.