Skip to content
Snippets Groups Projects
Commit c03da507 authored by Andrey Ruzhanskiy's avatar Andrey Ruzhanskiy
Browse files

Added method dump for printdirector, adjusted main

parent a6b54807
No related branches found
No related tags found
1 merge request!41Feat/print byte dump 56
......@@ -43,6 +43,8 @@ import tec.units.ri.unit.MetricPrefix;
import javax.measure.Quantity;
import javax.measure.quantity.Length;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
......@@ -234,6 +236,7 @@ public final class App {
throw new Exception("Can't find any Printservices on this System.");
}
/*
We do not want to actually print on each run.
Until CLI parsing is fully integrated, you will have to disable this check by hand if you actually do
......@@ -249,6 +252,11 @@ public final class App {
String printerConfigUpperCase = indexV4Printer.getProperty("mode").toString().toUpperCase();
PrintDirector printD = new PrintDirector(PrinterCapability.valueOf(printerConfigUpperCase), indexV4Printer);
printD.print(mat);
FileOutputStream textDumpOutput = new FileOutputStream("dump.txt");
textDumpOutput.write(printD.textDump(mat));
} catch (final Exception e) {
terminateWithException(e);
......
......@@ -89,6 +89,19 @@ public class PrintDirector {
print(result);
}
@SuppressWarnings("unchecked")
public byte[] textDump(PrintableData data) {
mLogger.info("starting with textdump process.");
byte[] result;
try {
mLogger.trace("assembling the data according to protocol: {}.", mBuilder.getClass().getCanonicalName());
result = mBuilder.assemble(data);
} catch (ClassCastException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
mLogger.info("Finished with creating textdump.");
return result;
}
/**
* Method for setting up the DocFlavor for printing. Currently, not parameterised because the printer can
* (hopefully) understand raw bytes with an octet stream.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment