Java ArrayList<Object> print via printer - java

I've been trying to find something on the web but was unable to find anything that can help me with my issue.
I need to send content of JFXTreeTableView to printer to print it. Any help appreciated. I can even use ArrayList<Object> as a data source to print so don't stick to the table.

Related

UDP Sockets need help on reply.getData

Hey community i need some help in my java code.
I get an object in the reply.getData and I want to cast the content as a string but it does not work as I want. Thank you friends
my code
This is the output i get. If you want i can give you more information about my code.
output

Adding control data to plain text print job

Sorry for the long winded question, I've spent a few days trying to figure this out and have so far found dozens of ways not to solve my problem.
I'm currently trying to use a Datamax O'Neill E Class Mark 3 printer to print some labels. The java application that generates the label data cannot be easily modified, and simply outputs plain text via a built in "print" function (output example below)
Unit name [LF]
Unit description [LF]
Quantity
When I print to a Ricoh printer it works (using CR+LF replacement in the Ricoh driver). However when I print to the label printer it does not. I've been advised that the label printer requires "control codes" and "encoded data" to be able to print.
I've been able to log the .prn files from the printer and when sending the exact same data from Notepad to he printer, the .prn file is much larger and appears to be "encoded" containing control codes.
This is entirely inside a windows environment using a networked printer (tried USB as well). I basically need something for my Java application to print to, that will add the necessary "encoding" to the data and then pass it along to the Datamax printer. Any ideas?
I'll try and post some samples tomorrow when I'm in the office as I'm currently typing this on mobile.
What I ended up doing was using the printers logging feature to log all jobs to C:\printlogs\ and have a batch file that loops every few seconds to run notepad /P on each file in the folder and then clean them all up.
I know it's a messy workaround, but it works.
When you print text from something like Notepad, that text gets sent to a print driver that converts it into the format the printer understands. You can't generally add control codes to the text in Notepad and have it work because it won't be seen as anything other than plain text to be printed.
The programmer's manual for that printer can be found here. That gives you everything you need to know to print labels on that printer. But in order to send those commands to the printer, you can't just paste them into Notepad. You have to write them directly to the printer, bypassing the print driver. For that you're going to need to use the WritePrinter function. The sequence of steps for printing goes like this:
To begin a print job, call StartDocPrinter.
To begin each page, call StartPagePrinter.
To write data to a page, call WritePrinter.
To end each page, call EndPagePrinter.
Repeat 2, 3, and 4 for as many pages as necessary.
To end the print job, call EndDocPrinter.
The MSDN entry for WritePrinter includes a link to example code (in C).

XDocReport generate report : loop thru collection in table (java)

I have been struggling with trying to follow a code sample by XDocReport(open source project).
I followed this tutorial from the website:
https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainListFieldInTable
I used the Freemarker template style.
I would not iterate and create the table, I just get back: $variable as text in the output doc.
Then I dug further, and discovered that this tutorial on the website was probably not updated for the newer version. I found some more examples in this url, which contains a zip file.
https://code.google.com/p/xdocreport/downloads/detail?name=docxandfreemarker-1.0.4-sample.zip
I still could not get it to work.
I was hoping someone would have a working code sample that takes a java collection and populates a table in a Word document.
I hope one of the developers of XDocReport, angelo.zerr, would give some input on this.
Sincerely,
P
I was hoping someone would have a working code sample that takes a java collection and populates a table in a Word document.
What is the problem with https://code.google.com/p/xdocreport/wiki/DocxReportingJavaMainListFieldInTable?
I suggets you that you create an issue on XDocReport forum with a very simple case (simple Java main + docx)
It seems that the issue was the template. If one sets up a mail merge field in a Word template and don't use it in the Java program, the program then complains it can't find the variable, or something to that effect. And if you just delete the mail merge text in the document, it may still exist as a mail merge field variable in the word document.
So one needs to be very careful it seems with how to set things in the template.
I think the API should be able to ignore if there is a field setup in the template, and we are not referencing it in the code though. But that solved the problem.

Silently print in the web page

All, I am trying to look for some solution to print the data in the webpage silently,
the printer type is Datamax e-4205A Label Printer, But so far I am stuck with it , Any Idea?
Any way , Is it possible to program an Activex control based on the printer API? thanks.

Automatic adding of elements to an array

Hi I'm not particular good at Java so please bear with me. I'm trying to write a very simple android app now and I need help with some coding.
Thing is, I have a server that automatically generates .png files and saves them to a public directory in a numerical order. The update occurs daily and is non-exhaustive.
Is there anyway in which I can assign the dynamic values to an array within my app?
private String[] myRemoteImages = {
"http://hypotheticalurl1.png",
"http://hypotheticalurl2.png",
"http://hypotheticalurl3.png",
"http://hypotheticalurl4.png",
"http://hypotheticalurl5.png",
"http://hypotheticalurl6.png",
"http://hypotheticalurl7.png",
"http://hypotheticalurl8.png",
"http://hypotheticalurl9.png",
"http://hypotheticalurl10.png",
"http://hypotheticalurl11.png",
"http://hypotheticalurl12.png",
//...blah blah blah
// these are all dynamically created so I won't know what is the last number on the list
};
This array will eventually be used to get the images from my server using the app. It works so far but that's only with hardcoded URLs. I would like the URLs to be dynamic, as the number of images will change from day to day.
I'm doubting that regex will work well in Java but then again I'm no expert. Was thinking of perhaps writing a script on the server end that generates a list of existing values and somehow parsing that with the android app.
Can anyone point me in the right direction? Thanks in advance.
Clarification:
The array doesn't have to be dynamically sized while the app is running.
I need a way to read the list of existing images in a remote directory and pass that information to populate the array automatically at runtime.
Resolved
Guys, thanks for the help. Sorry if I wasn't clear enough.
I've found a way to do it. Basically it was rather simple, which was to append an extra line of code to the shell script on the server end to generate a text list of existent image URLs at the same time that it generates the images.
After that, I used a combination of BufferedReader and openStream on the app to parse the remote text file into a String array.
thanks for the help. Sorry if I wasn't clear enough.
I've found a way to do it. Basically it was rather simple, which was to append an extra line of code to the shell script on the server end to generate a text list of existent image URLs at the same time that it generates the images.
After that, I used a combination of BufferedReader and openStream on the app to parse the remote text file into a String array.
With an array you can :
change the elements of the array
but you can't :
add or remove elements. The number of elements if fixed in an array. Some workaround can be found like putting null values and discarding theem when using the values in the array. But that's more troublesome than really useful.
On the other hand, if you want a full dynamic "array" : use a list (java.util.List). An ArrayList would be interesting here, or even a Vector as you will probably need some multihtreading around this array. With a list you can add and remove elements, size can vary and elements can be replaced.
I'd use an ArrayList in this case. You don't have to know the number of elements you want to add then and it's very simple to append elements at the end.
private List<String> list = new ArrayList<String>();
Then simply add elements by
list.add("http://hypotheticalurl1.png");
Regards,
Patrick
instead of using Array of String
use ArrayList<String> It will gives you more flexibility on adding and removing item on runtime refer this link...http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html
hear you can find example on arraylist...http://www.java2s.com/Tutorial/Java/0140_Collections/0160_ArrayList.htm
hope that helps
According to your scenario you need to have the followings:
1- a Web Service which has a method to get you the list of the available image names.
2- You need a web service client for your android application, I suggest you to use KSOAP 2 because it is widely known and easy to implement.
(If you can't figure out how to use the ksoap in your program, I can provide you some example codes)
3- You need to use ArrayList(java.util) to hold your dynamically sized array.
Hey ytou can do it via
ArrayList stringList = new ArrayList();
stringList.add("Item");

Categories

Resources