Examples of SimpleDoc


Examples of javax.print.SimpleDoc

*/
public class getStreamForBytes implements Testlet
{
  public void test(TestHarness harness)
  {
    SimpleDoc doc = new SimpleDoc(new byte[]{'2','3'},
        DocFlavor.BYTE_ARRAY.GIF, null);

    try
      {
        InputStream stream1 = doc.getStreamForBytes();
        InputStream stream2 = doc.getStreamForBytes();
        harness.check(stream1 == stream2);
        harness.check(stream1 instanceof ByteArrayInputStream);
      }
    catch (IOException e)
      {
        harness.check(false);
      }

    SimpleDoc doc1 = new SimpleDoc(
        new ByteArrayInputStream(new byte[] { 'A', 'b' }),
        DocFlavor.INPUT_STREAM.GIF, null);

    try
      {
        InputStream stream3 = doc1.getStreamForBytes();
        InputStream stream4 = doc1.getStreamForBytes();
        harness.check(stream3 == stream4);
        harness.check(stream3 == doc1.getPrintData());
      }
    catch (IOException e)
      {
        harness.check(false);
      }
View Full Code Here

Examples of javax.print.SimpleDoc

    HashDocAttributeSet set = new HashDocAttributeSet();
    set.add(Sides.DUPLEX);
    set.add(Compression.COMPRESS);
    set.add(OrientationRequested.LANDSCAPE);
   
    SimpleDoc doc =
      new SimpleDoc(new byte[100], DocFlavor.BYTE_ARRAY.GIF, set);
   
    DocAttributeSet set1 = doc.getAttributes();
    DocAttributeSet set2 = doc.getAttributes();
   
    // everytime the same object needs to be returned.
    harness.check(set1 == set2);
   
    try
View Full Code Here

Examples of javax.print.SimpleDoc

*/
public class getReaderForText implements Testlet
{
  public void test(TestHarness harness)
  {     
    SimpleDoc doc = new SimpleDoc(
      new String("Text to print"), DocFlavor.STRING.TEXT_PLAIN, null);
   
    try
      {
        Reader reader1 = doc.getReaderForText();
        Reader reader2 = doc.getReaderForText();
        harness.check(reader1 == reader2);
        harness.check(reader1 instanceof StringReader);
      }
    catch (IOException e)
      {
        harness.check(false);
      }   
   
    SimpleDoc doc1 = new SimpleDoc(
      new char[]{'A','b'}, DocFlavor.CHAR_ARRAY.TEXT_PLAIN, null);
                               
    try
      {
        Reader reader2 = doc1.getReaderForText();
        Reader reader3 = doc1.getReaderForText();
        harness.check(reader2 == reader3);
        harness.check(reader2 instanceof CharArrayReader);
      }
    catch (IOException e)
      {
        harness.check(false);
      }
   
    SimpleDoc doc2 = new SimpleDoc(
      new CharArrayReader(new char[]{'A','b'}), DocFlavor.READER.TEXT_PLAIN, null);
                                                            
    try
      {
        Reader reader4 = doc2.getReaderForText();
        Reader reader5 = doc2.getReaderForText();
        harness.check(reader4 == reader5);
        harness.check(reader4 == doc2.getPrintData());
      }
    catch (IOException e)
      {
        harness.check(false);
      }  
   
    SimpleDoc doc3 = new SimpleDoc(
      new byte[]{'A','b'}, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
                                                                                         
    try
      {
        Reader reader6 = doc3.getReaderForText();
        harness.check(reader6 == null);
      }
    catch (IOException e)
      {
        harness.check(false);
View Full Code Here

Examples of javax.print.SimpleDoc

            throw new ViewHandlerException("Unable write to browser OutputStream", e);
        }
        */

        DocFlavor docFlavor = DocFlavor.BYTE_ARRAY.PDF;
        Doc myDoc = new SimpleDoc(out.toByteArray(), docFlavor, null);
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        aset.add(new Copies(1));
        //aset.add(MediaSize.A4);
        aset.add(Sides.ONE_SIDED);

View Full Code Here

Examples of javax.print.SimpleDoc

        Result res = new SAXResult(fop.getDefaultHandler());

        // Start XSLT transformation and FOP processing
        transformer.transform(src, res);

        Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
        printJob.print(doc, null);
    }
View Full Code Here

Examples of javax.print.SimpleDoc

                aset.add(OrientationRequested.PORTRAIT);
                aset.add(new JobName(AppLocal.APP_NAME + " - Document", null));
                aset.add(media);

                DocPrintJob printjob = ps.createPrintJob();
                Doc doc = new SimpleDoc(new PrintableBasicTicket(m_ticketcurrent, imageable_x, imageable_y, imageable_width, imageable_height), DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);

                printjob.print(doc, aset);
            }

        } catch (PrintException ex) {
View Full Code Here

Examples of javax.print.SimpleDoc

                "A" + (offset+pixA[9]) + ",180,0,1,1,1,N,\"" +"AGENCIA "  + Shared.getConfig("storeName") +"\"\n"+
                "B" + (offset+pixA[10]) + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+
                "P" + firstLot + "\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
View Full Code Here

Examples of javax.print.SimpleDoc

                "A" + pixA[9] + ",180,0,1,1,1,N,\"" +"AGENCIA "  + Shared.getConfig("storeName") +"\"\n"+
                "B" + pixA[10] + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+
                "P1\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
View Full Code Here

Examples of javax.print.SimpleDoc

                "A" + (offset+pixA[9]) + ",180,0,1,1,1,N,\""+"AGENCIA " +Shared.getConfig("storeName"+"\"\n"+
                "B" + (offset+pixA[10]) + ",130,0,1,1,2,100,N,\"" + barCodeB + "\"\n"+
                "P1\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
View Full Code Here

Examples of javax.print.SimpleDoc

                    Debug.logInfo("Adding DocAttribute: " + da, module);
                    docAttributeSet.add((DocAttribute) da);
                }
            }

            Doc myDoc = new SimpleDoc(bais, psInFormat, docAttributeSet);

            PrintService printer = null;

            // lookup the print service for the supplied printer name
            String printerName = (String) serviceContext.remove("printerName");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.