I've got pdf file that looks like it:
example
It would be easy if each word of first line would have child in the next one. But sometimes the parents are empty below. I can get whole text from pdf and find those two lines. But if there is break in third column then reading the whole text I lose information if the third word was in forth column or third column. I hope I've made it clear, but I would appreciate idea how to read those two lines and connecting them, considering that not each parent has child in next line.
Related
I want to ask a question which is related to apache poi and generated file printing. What I am doing is I am opening a .docx file, inserting some data and saving and printing it.
I am having a file with only 1 table which is something like:
document table
Now, if there are 'n' items, I am generating n-1 rows which copies the format of row 3.
First item is inserted in row 3, if there's another item I am adding a row in the table and saving it likewise I am creating the rows.
Now I want to make this table length = page length. For this I am counting exactly how many rows this page can incorporate and based on that I am inserting empty lines without inside top and bottom border.
The file does not have any header/ footer or any other details as of now.
While I am creating the file I am shown the file which is coming in print preview of covering the whole page of size A4.
But this document is printed only on 80% of paper. I am having 0.3 cm margins but in print the whole page is not printed.
This does not seem to be the printer issue because if other software like Google Chrome are used then it prints the complete page.
So I want to ask that how can I solve this? I tried to search about this but till now I couldn't solve it. I think of this as an issue that whenever I am using XWPFDocument, its margins and all are changed set to default size. I don't know whether this is the issue or something other is, do I need to write some commands to preserve the margins and all or there's something that I need to do.
How can I solve this thing?
Thank you.
I'm trying to make Table of Contents for my Word document docx.
Apache POI is still too buggy. The document.createTOC() does not produce anything unless placed at the end. Sometimes, it doesn't give the correct page numbers.
The document.enforceUpdateFields() doesn't do anything!
So I thought I make my own method that creates the Table of Content. However, I will call it at the end but I need it to be inserted at the beginning!
In other words, suppose my document at some point in my program has some text on the first page and the second page. And I haven't yet saved it; how do I insert at the beginning of first page?
I haven't tried this yet. But, after you write the document. Reload it again
Then try the following:
List<XWPFParagraph> paragraphs = document.getParagraphs();
XWPFRun run = paragraphs.get(0).insertNewRun(0); // first paragraph, 0 is the position
run.setText("your data here");
i have a bit of problem which i have run into, im trying to shorten my code for a game and i got the idea to import all the dialogue from a text file instead of hardcoding it into the code itself. however it would work if every screen only had one line to display but somescreens have more than one
if (screenCount==1)
g.drawString("Hi there!", 25,515);
if (screenCount==2)
g.drawString("Welcome to the world of Pok\u00E9mon!", 25,515);
if (screenCount==3){
g.drawString("My name is Professor BLANK!", 25,515);
g.drawString("Everyone calls me the Pok\u00E9mon Professor!", 25,540);
}
As you can see for screen one and two i could easily put the dialogue in a text file like so:
1:Hi there!
2:Welcome to the world of Pok\u00E9mon!
But for the third screen I couldnt figure out how to import it/ write it in a text file and import it
3:My name is Professor Shinwa!
Everyone calls me the Pok\u00E9mon Professor!
MORE INFO: The game only displays two lines at a time at
g.drawString("", 25,515); //the first line x and y values
g.drawString("", 25,540); // the second line x and y values
I have around 37 screens and around half or more are two lines.
Thanks for any help, much apreciated :D
You can use the escape sequence \n in your String as pointed in the JavaDocs:
Insert a newline in the text at this point.
Your String could look like:
3:My name is Professor Shinwa!\nEveryone calls me the Pok\u00E9mon Professor!
BUT I think a better solution is to put each screen text in a separate textfile. You can then read the file until no more lines are remaining and print them on the screen. The textfiles should be named with screen#, e.g. screen1, screen2 ... so you don't need this big amount of if-blocks in your code. Just concatenate the screen with your current screennumber and read this file, done. What if you need dialogues with response from the user? How would you handle this case?
everybody. I have completed my code two txt files by showing on the same area.
but I want to compare two txt files line by line. and I want to show the differences with Colored lines and finally, The letter or words that are different, different line I'm going to bold.
how can i start?
thanks for now, my code is here.
JTextArea might make a suitable view, but you still need to model the differences. I'd look at the Eclipse or NetBeans platforms, or perhaps svnview.
You might need to ask user to upload both versions of file.
In the server you need to compare line by line, and store the line numbers of the file differences in another file or location
Then, while displaying, get the line numbers and give them proper decoration (i.e bold etc.).
I have an application where I have a JTable with line breaks(pressing Enter key while editing) included in each and every cell.
The problem appears when I copy the contents from my JTable to Excel, I am not getting the contents in same format as in my Jtable(with line breaks) to my excel that is with line breaks.
Is there any way to solve my problem.I have to get the contents from my jtable to excel in the same format with line breaks.
Thank You
Chaithu
I don't know much about DnD. I think that typically you use a delimiter for each cell data (like comma or tab) and then a newline for each row of data.
So if your cell data contains newline characters you would probably need to wrap the cell data in "...". This would mean you need to write a custom TransferHandler for the table. The old TableTransferHandler from the JDK5 tutorial might help you get started.
How are you copying the contents? Are you using the build in copy support?(ie select all contents and copy w/ ctrl-c), or did you write something yourself to do the copy and paste?
You may have to do the latter, and make sure that you insert the necessary line break characters in to the text.