Examples of PDFException


Examples of org.jpedal.exception.PdfException

            /** store file name for use elsewhere as part of ref key without .pdf */
            objectStoreRef.storeFileName("r" + System.currentTimeMillis());

        } catch (Exception e) {
            throw new PdfException("[PDF] OpenPdfArray generated exception "
                    + e.getMessage());
        }
    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

            if (pdfVersion == null) {
                currentPdfFile = null;
                isDecoding = false;

                throw new PdfException( "No version on first line ");

            }

            // read reference table so we can find all objects and say if
            // encrypted
            PdfObject pdfObject=null ;

            int linearPageCount=-1;

            //linear page object set differently
            if(linearParser.hasLinearData()){

                /**
                 * read and decode the hints table and the ref table
                 */
                pdfObject=linearParser.readHintTable(pdfObject,currentPdfFile);

                linearPageCount=linearParser.getPageCount();

            }else//<end-gpl>
                pdfObject=currentPdfFile.getObjectReader().readReferenceTable(null);

            //new load code - be more judicious in how far down tree we scan
            final boolean ignoreRecursion=true;

            // open if not encrypted or has password
            if (!isEncrypted() || isPasswordSupplied()) {

                if (pdfObject != null){
                    pdfObject.ignoreRecursion(ignoreRecursion);

                    res.setValues(pdfObject,currentPdfFile);

                    //check read as may be used for Dest
                    PdfObject nameObj=pdfObject.getDictionary(PdfDictionary.Names);
                    if (nameObj != null){
                        currentPdfFile.readNames(nameObj, options.getJS(),false);
                    }
                }

                int type=pdfObject.getParameterConstant(PdfDictionary.Type);
                if(type!=PdfDictionary.Page){

                    PdfObject pageObj= pdfObject.getDictionary(PdfDictionary.Pages);
                    if(pageObj!=null){ //do this way incase in separate compressed stream

                        pdfObject=new PageObject(pageObj.getObjectRefAsString());
                        currentPdfFile.readObject(pdfObject);

                        // System.out.println("page="+pageObj+" "+pageObj.getObjectRefAsString());
                        //catch for odd files
                        if(pdfObject.getParameterConstant(PdfDictionary.Type)==-1)
                        pdfObject=pageObj;

                        //System.out.println("test code called");
                    }
                }

                if (pdfObject != null) {
                 
                  if(LogWriter.isOutput())
                    LogWriter.writeLog("Pages being read from "+pdfObject+ ' '+pdfObject.getObjectRefAsString());
                   
                  pageNumber = 1; // reset page number for metadata
                    // reset lookup table
                    //pageLookup = new PageLookup();

                    //flush annots before we reread

                    if(formRenderer!=null)
                        formRenderer.resetAnnotData(insetW, insetH, pageData, 1, currentPdfFile,null);

                    //recursively read all pages
                    int tempPageCount=readAllPageReferences(ignoreRecursion, pdfObject, new HashMap(1000), new HashMap(1000),1);

                    //set PageCount if in Linearized data
                    if(linearPageCount>0){
                        pageCount=linearPageCount;
                    }else{
                        pageCount = tempPageCount - 1; // save page count
                    }

                    pageNumber =0; // reset page number for metadata;
                    if (this.pageCount == 0 && LogWriter.isOutput())
                        LogWriter.writeLog("No pages found");
                }


                // pass handle into renderer
                if (formRenderer != null) {
                    formRenderer.openFile(pageCount);


                    formRenderer.resetFormData(insetW, insetH, pageData, currentPdfFile, res.getPdfObject(PdfResources.AcroFormObj));
                }
            }

            currentOffset = null;

            // reset so if continuous view mode set it will be recalculated for page
                pages.disableScreen();
                pages.stopGeneratingPage();

            //force back if only 1 page
            if (pageCount < 2)
                displayView = Display.SINGLE_PAGE;
            else
                displayView = options.getPageMode();

            //<start-adobe>
            setDisplayView(this.displayView, alignment); //force reset and add back listener
            /**
            //<end-adobe>
            if (currentOffset == null)
              currentOffset = new PageOffsets(pageCount, pageData);
            /**/

            isOpen = true;
        } catch (PdfException e) {

            //ensure all data structures/handles flushed
            isDecoding = false;
            isOpen=true; //temporarily set to true as otherwise will not work
            closePdfFile();

            isOpen=false;

            isDecoding = false;
            throw new PdfException(e.getMessage() + " opening file");
        }

        isDecoding = false;

    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

     * can  take values such as  new PageRanges("3,5,7-9,15");
     */
    public void setPagePrintRange(SetOfIntegerSyntax range) throws PdfException {

        if (range == null)
            throw new PdfException("[PDF] null page range entered");

        swingPrinter.setPagePrintRange(range,pageCount);

    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

                    if (rawValue instanceof Integer) {

                        nonDrawnPageColor = new Color((Integer) rawValue);

                    } else
                        throw new PdfException("JPedalSettings.UNDRAWN_PAGE_COLOR expects a Integer value");

                } else if (key.equals(JPedalSettings.PAGE_COLOR)) {
                    if (rawValue instanceof Integer) {

                        pageColor = new Color((Integer) rawValue);

                    } else
                        throw new PdfException("JPedalSettings.PAGE_COLOR expects a Integer value");

                } else if (key.equals(JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING)) {

                    if (rawValue instanceof Integer) {

                        instance_bestQualityMaxScaling = (Integer) rawValue;

                    } else
                        throw new PdfException("JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING expects a Integer value");

                } else if (key.equals(JPedalSettings.EXTRACT_AT_PAGE_SIZE)) {

                    if (rawValue instanceof String[]) {

                        instance_extactionPageSize = (String[]) rawValue;

                    } else
                        throw new PdfException("JPedalSettings.EXTRACT_AT_PAGE_SIZE expects a String[] value");

                } else if (key.equals(JPedalSettings.IGNORE_FORMS_ON_PRINT)) {

                    if (rawValue instanceof int[]) {

                        instance_formsNoPrint = (int[]) rawValue;

                    } else
                        throw new PdfException("JPedalSettings.IGNORE_FORMS_ON_PRINT expects a int[] value");

                } else if (key.equals(JPedalSettings.PAGE_SIZE_OVERRIDES_IMAGE)) {

                    if (rawValue instanceof Boolean) {

                        instance_overridePageSize = (Boolean) rawValue;


                    } else
                        throw new PdfException("JPedalSettings.EXTRACT_AT_PAGE_SIZE expects a Boolean value");

                } else if (key.equals(JPedalSettings.ALLOW_PAGES_SMALLER_THAN_PAGE_SIZE)) {

                    if (rawValue instanceof Boolean) {

                        instance_allowPagesSmallerThanPageSize = (Boolean) rawValue;


                    } else
                        throw new PdfException("JPedalSettings.ALLOW_PAGES_SMALLER_THAN_PAGE_SIZE expects a Boolean value");
                    //expansion room here

                } else //all static values
                    setParameter(values, nextKey);

            } else
                throw new PdfException("Unknown or unsupported key (not Integer) " + nextKey);

        }
    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

                //set mode if valid

                if(rawValue instanceof Boolean){
                    SwingDisplay.invertHighlight = (Boolean) rawValue;
                }else
                    throw new PdfException("JPedalSettings.INVERT_HIGHLIGHT expects an Boolean value");

            }else if(key.equals(JPedalSettings.TEXT_INVERTED_COLOUR)){
                //set colour if valid

                if(rawValue instanceof Color)
                    backgroundColor=(Color) rawValue;
                else
                    throw new PdfException("JPedalSettings.TEXT_INVERTED_COLOUR expects a Color value");

            }else if(key.equals(JPedalSettings.TEXT_HIGHLIGHT_COLOUR)){
                //set colour if valid

                if(rawValue instanceof Color)
                    highlightColor=(Color) rawValue;
                else
                    throw new PdfException("JPedalSettings.TEXT_HIGHLIGHT_COLOUR expects a Color value");

            }else if(key.equals(JPedalSettings.TEXT_PRINT_NON_EMBEDDED_FONTS)){

                if(rawValue instanceof Boolean){

                    Boolean value= (Boolean)rawValue;
                    PdfStreamDecoder.useTextPrintingForNonEmbeddedFonts = value;
                }else
                    throw new PdfException("JPedalSettings.TEXT_PRINT_NON_EMBEDDED_FONTS expects a Boolean value");

            }else if(key.equals(JPedalSettings.DISPLAY_INVISIBLE_TEXT)){

                if(rawValue instanceof Boolean){

                    Boolean value= (Boolean)rawValue;
                    TextDecoder.showInvisibleText = value;
                }else
                    throw new PdfException("JPedalSettings.DISPLAY_INVISIBLE_TEXT expects a Boolean value");

            }else if(key.equals(JPedalSettings.CACHE_LARGE_FONTS)){

                if(rawValue instanceof Integer){

                    Integer value= (Integer)rawValue;
                    FontData.maxSizeAllowedInMemory = value;
                }else
                    throw new PdfException("JPedalSettings.CACHE_LARGE_FONTS expects an Integer value");

            }else if(key.equals(JPedalSettings.IMAGE_HIRES)){
            }else if(key.equals(JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING)){

                if(rawValue instanceof Integer){

                    PDFtoImageConvertor.bestQualityMaxScaling = (Integer) rawValue;

                }else
                    throw new PdfException("JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING expects a Integer value");
                //expansion room here
            }else if(key.equals(JPedalSettings.EXTRACT_AT_PAGE_SIZE)){

                if(rawValue instanceof String[]){

                    extactionPageSize = (String[]) rawValue;

                }else
                    throw new PdfException("JPedalSettings.EXTRACT_AT_PAGE_SIZE expects a String[] value");
                //expansion room here

            }else if(key.equals(JPedalSettings.PAGE_SIZE_OVERRIDES_IMAGE)){

                if(rawValue instanceof Boolean){

                    overridePageSize = (Boolean) rawValue;


                }else
                    throw new PdfException("JPedalSettings.EXTRACT_AT_PAGE_SIZE expects a Boolean value");
                //expansion room here

            }else if(key.equals(JPedalSettings.IGNORE_FORMS_ON_PRINT)){

                if(rawValue instanceof int[]){

                    formsNoPrint = (int[]) rawValue;

                }else
                    throw new PdfException("JPedalSettings.IGNORE_FORMS_ON_PRINT expects a int[] value");

            }else if(key.equals(JPedalSettings.ALLOW_PAGES_SMALLER_THAN_PAGE_SIZE)){

                if(rawValue instanceof Boolean){

                    PDFtoImageConvertor.allowPagesSmallerThanPageSize = (Boolean) rawValue;

                }else
                    throw new PdfException("JPedalSettings.ALLOW_PAGES_SMALLER_THAN_PAGE_SIZE expects a Boolean value");


            }else
                throw new PdfException("Unknown or unsupported key "+key);

        }else
            throw new PdfException("Unknown or unsupported key (not Integer) "+nextKey);
    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

            double crw = pageData.getCropBoxWidth(pdfDecoder.pageNumber);
            double crh = pageData.getCropBoxHeight(pdfDecoder.pageNumber);

            // throw exception if viewport cannot fit in cropbox
            if (x < 0 || y < 0 || (x + w) > crw || (y + h) > crh) {
                throw new PdfException("Viewport is not totally enclosed within displayed panel.");
            }

            // if viewport exactlly matches the cropbox
            if (crw == w && crh == h) {
            } else {// else work out scaling ang apply
View Full Code Here

Examples of org.jpedal.exception.PdfException

                j++;
            }
        }

        if ((start < 1) || (end < 1) || (start > pageCount) || (end > pageCount))
            throw new PdfException(Messages.getMessage("PdfViewerPrint.InvalidPageRange") + ' ' + start + ' ' + end);

    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

            int tmp = start;
            start = end;
            end = tmp;
        }
        if ((start < 1) || (end < 1) || (start > pageCount) || (end > pageCount))
            throw new PdfException(Messages.getMessage("PdfViewerPrint.InvalidPageRange") + ' ' + start + ' ' + end);

    }
View Full Code Here

Examples of org.jpedal.exception.PdfException

            if(!JAIHelper.isJAIused())
            message="JPeg 2000 Images and JAI not setup.\nYou need both JAI and imageio.jar on classpath, " +
        "and the VM parameter -Dorg.jpedal.jai=true switch turned on";

            throw new PdfException(message);
        }

        if(iir==null)
        return null;
View Full Code Here

Examples of org.jpedal.exception.PdfException

                case 0:
                    break;

                default:
                    throw new PdfException("Unrecognised type "+currentType);
            }
        }
    }
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.