EPSCanvasProvider extends AbstractCanvasProvider { @Override public void establishDimensions(BarcodeDimension dim) { super.establishDimensions(dim); final Orientation orientation = getOrientation(); if (firstError != null) { return; } this.height = dim.getHeightPlusQuiet(); try { writeHeader(dim.getWidthPlusQuiet(orientation), dim.getHeightPlusQuiet(orientation)); final String w = formatmm(dim.getWidthPlusQuiet()); final String h = formatmm(dim.getHeightPlusQuiet()); switch (orientation) { case NINETY: writer.write("90 rotate 0" + " -" + h + " translate\n"); break; case ONEHUNDRED_EIGHTY: writer.write("180 rotate -" + w + " -" + h + " translate\n"); break; case TWOHUNDRED_SEVENTY: writer.write("270 rotate -" + w + " 0 translate\n"); break; default: } } catch (IOException ioe) { firstError = ioe; } } EPSCanvasProvider(OutputStream out, Orientation orientation); @Deprecated  EPSCanvasProvider(OutputStream out, int orientation); void finish(); @Override void establishDimensions(BarcodeDimension dim); @Override void deviceFillRect(double x, double y, double w, double h); @Override void deviceText(
            String text,
            double x1,
            double x2,
            double y1,
            String fontName,
            double fontSize,
            TextAlignment textAlign);  }
@Test public void testEstablishDimensions() throws Exception { System.out.println("establishDimensions"); BarcodeDimension dim = new BarcodeDimension(100, 100); EPSCanvasProvider instance = new EPSCanvasProvider(out, orientation); instance.establishDimensions(dim); instance.finish(); String result = ((ByteArrayOutputStream) out).toString("US-ASCII"); assertThat(result, startsWith("%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 284 284\n%%HiResBoundingBox: 0 0 283.5 283.5\n")); assertThat(result, endsWith("%%EndProlog\n%%EOF\n")); }