Package java.awt.print

Examples of java.awt.print.Pageable


            getPageable() instanceof OpenBook) {

            /* We could almost(!) use PrinterJob.getPageFormat() except
             * here we need to start with the PageFormat from the OpenBook :
             */
            Pageable pageable = getPageable();
            Printable printable = pageable.getPrintable(0);
            PageFormat pf = (PageFormat)pageable.getPageFormat(0).clone();
            Paper paper = pf.getPaper();

            /* If there's a media but no media printable area, we can try
             * to retrieve the default value for mpa and use that.
             */
 
View Full Code Here


            if (s != null) {
                return s.getMax();
            }
        }

        Pageable pageable = getPageable();
        if (pageable != null) {
            int numPages = pageable.getNumberOfPages();
            if (numPages <= Pageable.UNKNOWN_NUMBER_OF_PAGES) {
                numPages = MAX_UNKNOWN_PAGES;
            }
            return  ((numPages == 0) ? 1 : numPages);
        }
View Full Code Here

                }
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)){
                Printable printable = (Printable)data;
                print(printable, null);
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) {
                Pageable pageable = (Pageable)data;
                print(null, pageable);
            } else {
                throw new PrintException("Wrong DocFlavor class: "
                        + docflavorClassName);
            }
View Full Code Here

     * @see java.awt.print.PrinterJob#print()
     */
    public void print() throws PrinterException {
        Doc doc = null;
        if (psPrintable != null) {
            Pageable pageable = new Pageable() {
                public int getNumberOfPages() {
                    return UNKNOWN_NUMBER_OF_PAGES;
                }
                public PageFormat getPageFormat(int pageIndex)
                        throws IndexOutOfBoundsException {
View Full Code Here

                }
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)){
                Printable printable = (Printable)data;
                print(printable, null);
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) {
                Pageable pageable = (Pageable)data;
                print(null, pageable);
            } else {
                throw new PrintException("Wrong DocFlavor class: "
                        + docflavorClassName);
            }
View Full Code Here

                }
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)){
                Printable printable = (Printable)data;
                print(printable, null);
            } else if (docflavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE)) {
                Pageable pageable = (Pageable)data;
                print(null, pageable);
            } else {
                throw new PrintException("Wrong DocFlavor class: "
                        + docflavorClassName);
            }
View Full Code Here

     * @see java.awt.print.PrinterJob#print()
     */
    public void print() throws PrinterException {
        Doc doc = null;
        if (psPrintable != null) {
            Pageable pageable = new Pageable() {
                public int getNumberOfPages() {
                    return UNKNOWN_NUMBER_OF_PAGES;
                }
                public PageFormat getPageFormat(int pageIndex)
                        throws IndexOutOfBoundsException {
View Full Code Here

        }

        private void printPageable(final Doc doc,
                        final PrintRequestAttributeSet attributes)
                        throws PrintException {
            final Pageable pageable = castDoc(doc, Pageable.class);
            final PageFormat defaultFormat = getPageFormat(doc.getAttributes(),
                            attributes);
            final long pdc = WinPrinterFactory.getPrinterDC(
                            service.printerName, service.getPrinterProps()
                                            .getStructPtr());
            final AttributeSet docAttrs = doc.getAttributes();
            int pages = pageable.getNumberOfPages();
            final PageRanges ranges = getAttribute(PageRanges.class, docAttrs,
                            attributes);

            if (pages == Pageable.UNKNOWN_NUMBER_OF_PAGES) {
                pages = Integer.MAX_VALUE;
            }

            try {
                startJob(pdc, getDocName(pageable, docAttrs, attributes),
                                getDestinationPath(attributes));

                for (int i = 0; i < pages; i++) {
                    if ((ranges != null) && !ranges.contains(i)) {
                        continue;
                    }

                    final Printable printable = pageable.getPrintable(i);
                    final PageFormat format = null;

                    if (printable == null) {
                        throw new PrintException("No such page: " + i); //$NON-NLS-1$
                    }
View Full Code Here

        MediaPrintableArea mpa =
            (MediaPrintableArea)attributes.get(MediaPrintableArea.class);
        if ((orientReq != null || media != null || mpa != null) &&
            isOpenBook(getPageable())) {

            Pageable pageable = getPageable();
            Printable printable = pageable.getPrintable(0);
            PageFormat pf = (PageFormat)pageable.getPageFormat(0).clone();
            Paper paper = pf.getPaper();

            if (isSupportedValue(orientReq, attributes) ||
                (!fidelity & orientReq != null)) {
                int orient;
View Full Code Here

        if (noDefaultPrinter == true) {
            return false;
        }

        Pageable pageable = getPageable();
        Frame frame = getEmbeddedFrame();
        if (frame != null)
            dialogOwnerPeer = frame.getPeer();
        boolean flag = jobSetup(pageable, checkAllowedToPrintToFile());
        if (flag && isOpenBook(pageable)) {
            float f = (float)mPrintXRes / 72;
            float f1 = (float)mPrintYRes / 72;
            float f2 = (float)mPageWidth / f;
            float f3 = (float)mPageHeight / f1;
            PageFormat pageformat = pageable.getPageFormat(0);
            Paper paper = pageformat.getPaper();
            switch (mAttOrientation) {
              case 2:
                pageformat.setOrientation(0);
                paper.setSize(f3, f2);
                break;

              default:
                pageformat.setOrientation(1);
                paper.setSize(f2, f3);
                break;
            }
            pageformat.setPaper(paper);
            pageformat = validatePage(pageformat);
            setPrintable(pageable.getPrintable(0), pageformat);
            pageable = getPageable();
            pageformat = pageable.getPageFormat(0);
            paper = pageformat.getPaper();
           }
        return flag;
    }
View Full Code Here

TOP

Related Classes of java.awt.print.Pageable

Copyright © 2018 www.massapicom. 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.