Package org.jpedal

Class PdfDecoderServer

java.lang.Object
org.jpedal.PdfDecoderServer
All Implemented Interfaces:
PdfDecoderInt

public class PdfDecoderServer extends Object implements PdfDecoderInt
Provides an object to decode PDF files and provide a rasterizer if required - Normal usage is to create instance and access via public methods. If you require viewing and printing as well, use PdfDecoder/PdfDecoderFX (which also include all the functionality in PdfDecoderServer)

Examples showing usage in org.jpedal.examples
We recommend you access JPedal using only public methods listed in API

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    recommended way to create for most uses
    PdfDecoderServer(boolean newRender)
    Recommend Constructor to use is PdfDecoder()
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addExternalHandler(Object newHandler, int type)
    not part of API used internally
    void
    remove all displayed objects for JPanel display (wipes current page)
    final void
    convenience method to close the current PDF file and release all resources/delete any temporary files
    final void
    decodePage(int rawPage)
    decode a page, - page must be between 1 and PdfDecoder.getPageCount() - Will kill off if already running
    final void
    decode a page as a background thread (use other background methods to access data)
    final void
    convenience method to remove all items from memory If you wish to clear all static objects as well, you will also need to call disposeAllStatic()
    static void
    remove all static elements - only do once completely finished with JPedal as will not be reinitialised
    void
    drawAdditionalObjectsOverPage(int page, int[] type, Color[] colors, Object[] obj)
    allow user to add grapical content on top of page - for display ONLY Additional calls will overwrite current settings on page ONLY works in SINGLE VIEW displaymode
    void
    allow user to remove all additional grapical content from the page (only for display) ONLY works in SINGLE VIEW displaymode
    final void
    flushObjectValues(boolean reinit)
    provide method for outside class to clear store of objects once written out to reclaim memory
    org.jpedal.grouping.PdfGroupingAlgorithms
    returns object containing grouped text from background grouping - Please see org.jpedal.examples.text for example code
    org.jpedal.parser.DecoderOptions
    Return decoder options as object for cases where value is needed externally and can't be static
    org.jpedal.display.DisplayOffsets
     
    int
    current page rotation (in addition to rotation in file) in degrees So if user turns page by 90 degrees, value will be 90
    int
    returns view mode used - ie SINGLE_PAGE,CONTINUOUS,FACING,CONTINUOUS_FACING (no effect in OS versions)
    org.jpedal.utils.DPIFactory
    return handle on PDFFactory which adjusts display size so matches size in Acrobat
    org.jpedal.render.DynamicVectorRenderer
    Not part of API - used internally
    org.jpedal.render.DynamicVectorRenderer
    getDynamicRenderer(boolean reset)
    Not part of API - used internally
    org.jpedal.external.ExternalHandlers
     
    not part of API used internally
    final org.jpedal.objects.PdfFileInformation
    method to return null or object giving access info fields and metadata.
    currently open PDF file name
    org.jpedal.objects.acroforms.AcroRenderer
    Allow user to access Forms renderer object if needed
    org.jpedal.grouping.PdfGroupingAlgorithms
    returns object containing grouped text of last decoded page - if no page decoded, a Runtime exception is thrown to warn user Please see org.jpedal.examples.text for example code.
    float
    return scaleup factor applied to last Hires image of page generated
    getInfo(int type)
    Returns list of the fonts used on the current page decoded or null type can be PdfDictionary.Font or PdfDictionary.Image
    int
    Return amount to inset the page rectangle height by
    int
    Return amount to inset the page rectangle width by
    org.jpedal.io.PdfObjectReader
    allow access to PDF file
    org.jpedal.objects.Javascript
    Allow user to access javascript object if needed
    Not part of API - used internally
    int
    return page number for last page decoded (only use in SingleDisplay mode)
    return markedContent object as XML Document
    int[]
     
    org.jpedal.io.ObjectStore
    return object which provides access to file images and name
    final Document
    return a DOM document containing the PDF Outline object as a DOM Document - may return null
    org.jpedal.objects.outlines.OutlineData
    provide direct access to outlineData object
    int
    return type of alignment for pages if smaller than panel - see options in Display class.
    getPageAsHiRes(int pageIndex)
     
    getPageAsHiRes(int pageIndex, boolean isTransparent)
     
    getPageAsHiRes(int pageIndex, Map<Integer,Object> params)
     
    getPageAsHiRes(int pageIndex, Map<Integer,Object> params, boolean isTransparent)
     
    getPageAsImage(int pageIndex)
    generate BufferedImage of a page in current file
    getPageAsImage(int pageIndex, float scaling)
    generate BufferedImage of a page in current file with the given scaling
    generate BufferedImage of a page in current file
    final int
    get page count of current PDF file
    return any errors or other messages while calling decodePage() - zero length is no problems
    boolean
    getPageDecodeStatus(int status)
    returns booleans based on flags in DecodeStatus
    get page statuses (flags in DecodeStatus)
    int
    given a ref, what is the page
    getPageInfo(int type)
    return details on page for type (defined in org.jpedal.constants.PageInfo) or null if no values Unrecognised key will throw a RunTime exception
    int
    current logical page number
    org.jpedal.display.Display
    not part of API - do not use
    int[]
     
    final org.jpedal.objects.PdfData
    NOT PART OF API
    final org.jpedal.objects.PdfImageData
    provide method for outside class to get data object containing images.
    final org.jpedal.objects.PdfData
    Access should not generally be required to this class but used in examples.
    final int
    get sizes of panel - This is the PDF pagesize
    final org.jpedal.objects.PdfImageData
    provide method for outside class to get data object containing images
    final org.jpedal.objects.PdfPageData
    Provides method for outside class to get data object containing information on the page for calculating grouping
    Please note: Structure of PdfPageData is not guaranteed to remain constant.
    final String
    get PDF version in file
    final int
    get sizes of panel
    This is the PDF pagesize (as set in the PDF from pagesize) - It now includes any scaling factor you have set
    float
    returns current scaling value used internally
    int
    Return amount to scroll window by when scrolling (default is 10).
    getSelectedRectangleOnscreen(float t_x1, float t_y1, float t_x2, float t_y2, float scaling)
     
    int
    retusn a value defined in SpecialOptions used internally and in custom JPedal releases in PdfDecoder - always returns 0 in this class
    access textlines object
    int
     
    org.jpedal.objects.raw.PdfObject
     
     
    boolean
    flag to show if we suspect problem with some images
    boolean
    shows if embedded fonts present on page just decoded
    final boolean
    flag to show if PDF document contains an outline
    static void
    init(boolean newEmbedWidthData)
    This will be needed for text extraction and set to true as paramter makes sure widths included in text stream
    final boolean
    return true if the current pdf file is encrypted
    check isFileViewable(),

    if file is encrypted and not viewable - a user specified password is needed.
    boolean
    show if content can be extracted
    boolean
    show if encrypted file can be viewed,
    if false a password needs entering
    boolean
    return true if currently open PDF file is a PDF form
    boolean
    track if file still loaded in background
    boolean
    see if file open - may not be open if user interrupted open or problem encountered
    boolean
    isPageAvailable(int rawPage)
    see if page available if in Linearized mode or return true
    final boolean
    show if encryption password has been supplied or set a certificate
    boolean
    shows if text extraction is XML or pure text
    static void
    allow user to alter certain values in software such as Colour,
    void
    allow user to alter certain values in software such as Colour,
    final void
    openPdfArray(byte[] data)
    routine to open a byte stream containing the PDF file and extract key info from pdf file so we can decode any pages.
    final void
    openPdfArray(byte[] data, String password)
    routine to open a byte stream containing the PDF file and extract key info from pdf file so we can decode any pages.
    final void
    openPdfFile(String filename)
    routine to open PDF file and extract key info from pdf file so we can decode any pages.
    final void
    openPdfFile(String filename, String password)
    routine to open PDF file and extract key info from pdf file so we can decode any pages which also sets password.
    void
    openPdfFile(String filename, Certificate certificate, PrivateKey key)
    allow user to open file using Certificate and key
    final boolean
    openPdfFileFromInputStream(InputStream is, boolean supportLinearized)
    routine to open PDF file via InputStream and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves -
    You must explicitly close any open files with closePdfFile() to Java will not release all the memory
    final boolean
    openPdfFileFromInputStream(InputStream is, boolean supportLinearized, String password)
    routine to open PDF file via InputStream and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves -
    You must explicitly close any open files with closePdfFile() to Java will not release all the memory
    final void
    openPdfFileFromStream(Object filename, String password)
    routine to open PDF file and extract key info from pdf file so we can decode any pages which also sets password.
    final boolean
    openPdfFileFromURL(String pdfUrl, boolean supportLinearized)
    routine to open PDF file via URL and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves - Also reads the form data - Based on an idea by Peter Jacobsen
    You must explicitly close any open files with closePdfFile() so Java will release all the memory
    final boolean
    openPdfFileFromURL(String pdfUrl, boolean supportLinearized, String password)
    routine to open PDF file via URL and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves - Also reads the form data - Based on an idea by Peter Jacobsen
    You must explicitly close any open files with closePdfFile() so Java will release all the memory
    void
     
    void
     
    void
    repaintPane(int page)
     
    void
     
    void
    resetForNonPDFPage(int pageCount)
    used for non-PDF files to reset page
    void
    setDisplayRotation(int newRotation)
     
    final void
    set a password for encryption - software will resolve if user or owner password- calls verifyAccess() from 2.74 so no separate call needed
    void
    ensure that files are always encrypted if cached to disk regardless of whether file has a password set
    final void
    set extraction mode telling JPedal what to extract - (TEXT,RAWIMAGES,FINALIMAGES - add together to combine) - See org.jpedal.examples for specific extraction examples
    final void
    setExtractionMode(int mode, float scaling)
    Please do not use for general usage.
    void
    setHardwareAccelerationforScreen(boolean useAcceleration)
     
    void
    setInset(int width, int height)
     
    void
    setObjectStore(org.jpedal.io.ObjectStore newStore)
    return object which provides access to file images and name (use not recommended)
    void
    setPageMode(int mode)
    Not part of API - used internally
    final void
    setPageParameters(float scaling, int pageNumber)
    initialise panel and set size to fit PDF page
    intializes display with rotation set to the default, specified in the PDF document scaling value of -1 means keep existing setting
    final void
    setPageParameters(float scaling, int pageNumber, int newRotation)
    calls setPageParameters(scaling,pageNumber) after setting rotation to draw page
    void
    setPDFBorder(Border newBorder)
     
    void
    setPreviewThumbnail(BufferedImage previewImage, String previewText)
    internal method used by Viewer to provide preview of PDF in Viewer
    final void
    setRenderMode(int mode)
    set render mode to state what is displayed onscreen (ie RENDERTEXT,RENDERIMAGES) - only generally required if you do not wish to show all objects on screen (default is all).
    void
    setScaling(float scaleFactor)
    allow user to adjust scaling factor on page in Viewer - DOES NOTHING in this class
    void
    setScrollInterval(int scrollInterval)
    Sets the ammount to scroll the window by (default is 10).
    void
    setStatusBarObject(org.jpedal.io.StatusBar statusBar)
     
    void
    allows user to cache large objects to disk to avoid memory issues, setting minimum size in bytes (of uncompressed stream) above which object will be stored on disk if possible (default is -1 bytes which is all objects stored in memory) - Must be set before file opened.
    void
    setUserOffsets(int x, int y, int mode)
     
    static void
     
    void
    updateCursorBoxOnScreen(int[] rectParams, int outlineColor)
     
    boolean
     
    void
    useNewGraphicsMode(boolean isEnabled)
    switches on or off glow border in JPedal viewer - does nothing in this class
    void
    Controls type of text extraction if using JPedal purely for as a text extraction engine (otherwise do not touch) XML extraction is the default - pure text extraction is much faster for pure Text extraction, otherwise should not need to be set (for examples and more details see https://www.idrsolutions.com/how-to-extract-text-from-pdf-files/)
    void
    Controls type of text extraction if using JPedal purely for as a text extraction engine (otherwise do not touch) XML extraction is the default - pure text extraction is much faster for pure Text extraction, otherwise should not need to be set (for examples and more details see https://www.idrsolutions.com/how-to-extract-text-from-pdf-files/)
    void
    wait for decoding to finish

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.jpedal.PdfDecoderInt

    setImageNameCollector
  • Field Details

    • version

      public static final String version
  • Constructor Details

    • PdfDecoderServer

      public PdfDecoderServer(boolean newRender)
      Recommend Constructor to use is PdfDecoder()
      Parameters:
      newRender - flag to show if pages are being rendered (true) or only extraction taking place (false).
    • PdfDecoderServer

      public PdfDecoderServer()
      recommended way to create for most uses

      Otherwise use PdfDecoder(render)

  • Method Details

    • setEncryptTempFiles

      public void setEncryptTempFiles()
      ensure that files are always encrypted if cached to disk regardless of whether file has a password set
      Specified by:
      setEncryptTempFiles in interface PdfDecoderInt
    • isOpen

      public boolean isOpen()
      see if file open - may not be open if user interrupted open or problem encountered
      Specified by:
      isOpen in interface PdfDecoderInt
    • getMarkedContent

      public Document getMarkedContent()
      return markedContent object as XML Document
      Specified by:
      getMarkedContent in interface PdfDecoderInt
      Returns:
      Document containing XML structure with data
    • getDisplayRotation

      public int getDisplayRotation()
      current page rotation (in addition to rotation in file) in degrees So if user turns page by 90 degrees, value will be 90
      Specified by:
      getDisplayRotation in interface PdfDecoderInt
      Returns:
      int
    • getPageNumber

      public int getPageNumber()
      current logical page number
      Specified by:
      getPageNumber in interface PdfDecoderInt
      Returns:
      int
    • setDisplayRotation

      public void setDisplayRotation(int newRotation)
      Specified by:
      setDisplayRotation in interface PdfDecoderInt
    • getPages

      public org.jpedal.display.Display getPages()
      not part of API - do not use
      Specified by:
      getPages in interface PdfDecoderInt
      Returns:
      Display
    • getlastPageDecoded

      public int getlastPageDecoded()
      return page number for last page decoded (only use in SingleDisplay mode)
      Specified by:
      getlastPageDecoded in interface PdfDecoderInt
    • getPageInfo

      public Iterator<Integer> getPageInfo(int type)
      return details on page for type (defined in org.jpedal.constants.PageInfo) or null if no values Unrecognised key will throw a RunTime exception

      null returned if JPedal not clear on result

      Specified by:
      getPageInfo in interface PdfDecoderInt
    • getOutlineData

      public org.jpedal.objects.outlines.OutlineData getOutlineData()
      provide direct access to outlineData object
      Specified by:
      getOutlineData in interface PdfDecoderInt
      Returns:
      OutlineData
    • isLoadingLinearizedPDF

      public boolean isLoadingLinearizedPDF()
      track if file still loaded in background
      Specified by:
      isLoadingLinearizedPDF in interface PdfDecoderInt
      Returns:
      boolean
    • showExpiry

      public static void showExpiry()
    • getPageAlignment

      public int getPageAlignment()
      return type of alignment for pages if smaller than panel - see options in Display class.
      Specified by:
      getPageAlignment in interface PdfDecoderInt
    • init

      public static void init(boolean newEmbedWidthData)
      This will be needed for text extraction and set to true as paramter makes sure widths included in text stream
      Parameters:
      newEmbedWidthData - - flag to embed width data in text fragments for use by grouping algorithms
    • disposeAllStatic

      public static void disposeAllStatic()
      remove all static elements - only do once completely finished with JPedal as will not be reinitialised
    • dispose

      public final void dispose()
      convenience method to remove all items from memory If you wish to clear all static objects as well, you will also need to call disposeAllStatic()
      Specified by:
      dispose in interface PdfDecoderInt
    • closePdfFile

      public final void closePdfFile()
      convenience method to close the current PDF file and release all resources/delete any temporary files
      Specified by:
      closePdfFile in interface PdfDecoderInt
    • getPdfBackgroundData

      public final org.jpedal.objects.PdfData getPdfBackgroundData()
      NOT PART OF API

      Access should not generally be required to this class. Please look at getBackgroundGroupingObject() - provide method for outside class to get data object containing text and metrics of text. - Viewer can only access data for finding on page

      Returns:
      PdfData object containing text content from PDF
    • getPdfData

      public final org.jpedal.objects.PdfData getPdfData() throws PdfException
      Access should not generally be required to this class but used in examples. Returns the PdfData object containing raw content from page
      Specified by:
      getPdfData in interface PdfDecoderInt
      Returns:
      PdfData object containing text content from PDF
      Throws:
      PdfException
    • hasOutline

      public final boolean hasOutline()
      flag to show if PDF document contains an outline
      Specified by:
      hasOutline in interface PdfDecoderInt
    • getOutlineAsXML

      public final Document getOutlineAsXML()
      return a DOM document containing the PDF Outline object as a DOM Document - may return null
      Specified by:
      getOutlineAsXML in interface PdfDecoderInt
    • getPdfPageData

      public final org.jpedal.objects.PdfPageData getPdfPageData()
      Provides method for outside class to get data object containing information on the page for calculating grouping
      Please note: Structure of PdfPageData is not guaranteed to remain constant. Please contact IDRsolutions for advice.
      Specified by:
      getPdfPageData in interface PdfDecoderInt
      Returns:
      PdfPageData object
    • getPageAsHiRes

      public BufferedImage getPageAsHiRes(int pageIndex) throws PdfException
      Specified by:
      getPageAsHiRes in interface PdfDecoderInt
      Parameters:
      pageIndex - number of the page we want to extract
      Returns:
      image of the extracted page
      Throws:
      PdfException - Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToHiResImages.java.html for full details
    • getPageAsHiRes

      public BufferedImage getPageAsHiRes(int pageIndex, Map<Integer,Object> params) throws PdfException
      Specified by:
      getPageAsHiRes in interface PdfDecoderInt
      Parameters:
      pageIndex - number of the page we want to extract
      params - list of values to override static settings in modifyJPedalParameters for this instance only
      Returns:
      image of the extracted page
      Throws:
      PdfException - Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToHiResImages.java.html for full details
    • getPageAsHiRes

      public BufferedImage getPageAsHiRes(int pageIndex, Map<Integer,Object> params, boolean isTransparent) throws PdfException
      Specified by:
      getPageAsHiRes in interface PdfDecoderInt
      Parameters:
      pageIndex - number of the page we want to extract
      params - list of values to override static settings in modifyJPedalParameters for this instance only
      isTransparent - - set if transparent or has background
      Returns:
      image of the extracted page
      Throws:
      PdfException - Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToHiResImages.java.html for full details
    • getPageAsHiRes

      public BufferedImage getPageAsHiRes(int pageIndex, boolean isTransparent) throws PdfException
      Specified by:
      getPageAsHiRes in interface PdfDecoderInt
      Parameters:
      pageIndex - number of the page we want to extract
      Returns:
      image of the extracted page
      Throws:
      PdfException - Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToHiResImages.java.html for full details
    • getPageAsImage

      public BufferedImage getPageAsImage(int pageIndex) throws PdfException
      generate BufferedImage of a page in current file

      Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToImages.java.html for full details

      Specified by:
      getPageAsImage in interface PdfDecoderInt
      Throws:
      PdfException
    • getPageAsImage

      public BufferedImage getPageAsImage(int pageIndex, float scaling) throws PdfException
      generate BufferedImage of a page in current file with the given scaling

      Page size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToImages.java.html for full details

      Specified by:
      getPageAsImage in interface PdfDecoderInt
      Throws:
      PdfException
    • getPageAsTransparentImage

      public BufferedImage getPageAsTransparentImage(int pageIndex) throws PdfException
      generate BufferedImage of a page in current file

      Page size is defined by CropBox

      Specified by:
      getPageAsTransparentImage in interface PdfDecoderInt
      Throws:
      PdfException
    • getHiResUpscaleFactor

      public float getHiResUpscaleFactor()
      return scaleup factor applied to last Hires image of page generated

      negative values mean no upscaling applied and should be ignored

      Specified by:
      getHiResUpscaleFactor in interface PdfDecoderInt
    • flushObjectValues

      public final void flushObjectValues(boolean reinit)
      provide method for outside class to clear store of objects once written out to reclaim memory
      Specified by:
      flushObjectValues in interface PdfDecoderInt
      Parameters:
      reinit - lag to show if image data flushed as well
    • getPdfImageData

      public final org.jpedal.objects.PdfImageData getPdfImageData()
      provide method for outside class to get data object containing images

      Please look at examples for usage

      Specified by:
      getPdfImageData in interface PdfDecoderInt
      Returns:
      PdfImageData containing image metadata
    • getPdfBackgroundImageData

      public final org.jpedal.objects.PdfImageData getPdfBackgroundImageData()
      provide method for outside class to get data object containing images.

      Please look at examples for usage

      Returns:
      PdfImageData containing image metadata
    • setRenderMode

      public final void setRenderMode(int mode)
      set render mode to state what is displayed onscreen (ie RENDERTEXT,RENDERIMAGES) - only generally required if you do not wish to show all objects on screen (default is all). Add values together to combine settings.
      Specified by:
      setRenderMode in interface PdfDecoderInt
    • setExtractionMode

      public final void setExtractionMode(int mode)
      set extraction mode telling JPedal what to extract - (TEXT,RAWIMAGES,FINALIMAGES - add together to combine) - See org.jpedal.examples for specific extraction examples
      Specified by:
      setExtractionMode in interface PdfDecoderInt
    • modifyNonstaticJPedalParameters

      public void modifyNonstaticJPedalParameters(Map<Integer,Object> values) throws PdfException
      allow user to alter certain values in software such as Colour,

      Please note all Color and text highlighting values are static and common across the JVM

      Specified by:
      modifyNonstaticJPedalParameters in interface PdfDecoderInt
      Throws:
      PdfException
    • modifyJPedalParameters

      public static void modifyJPedalParameters(Map<Integer,Object> values) throws PdfException
      allow user to alter certain values in software such as Colour,

      If you are using decoder.getPageAsHiRes() after passing additional parameters into JPedal using the static method PdfDecoder.modifyJPedalParameters(), then getPageAsHiRes() wont necessarily be thread safe. If you want to use getPageAsHiRes() and pass in additional parameters, in a thread safe mannor, please use the method getPageAsHiRes(int pageIndex, Map params) or getPageAsHiRes(int pageIndex, Map params, boolean isTransparent) and pass the additional parameters in directly to the getPageAsHiRes() method without calling PdfDecoder.modifyJPedalParameters() first.

      Please see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToHiResImages.java.html for example of usage

      Please note all Color and text highlighting values except page colour are static and common across the JVM

      Parameters:
      values - a map of jpedal parameters
      Throws:
      PdfException - if key or value data type is not recognised
    • getFileInformationData

      public final org.jpedal.objects.PdfFileInformation getFileInformationData()
      method to return null or object giving access info fields and metadata.
      Specified by:
      getFileInformationData in interface PdfDecoderInt
    • setExtractionMode

      public final void setExtractionMode(int mode, float scaling)
      Please do not use for general usage. Use setPageParameters(scalingValue, pageNumber) to set page scaling
      Specified by:
      setExtractionMode in interface PdfDecoderInt
    • getDPIFactory

      public org.jpedal.utils.DPIFactory getDPIFactory()
      return handle on PDFFactory which adjusts display size so matches size in Acrobat
      Specified by:
      getDPIFactory in interface PdfDecoderInt
      Returns:
      DPIFactory
    • setPageParameters

      public final void setPageParameters(float scaling, int pageNumber)
      initialise panel and set size to fit PDF page
      intializes display with rotation set to the default, specified in the PDF document scaling value of -1 means keep existing setting
      Specified by:
      setPageParameters in interface PdfDecoderInt
    • setPageParameters

      public final void setPageParameters(float scaling, int pageNumber, int newRotation)
      calls setPageParameters(scaling,pageNumber) after setting rotation to draw page
      Specified by:
      setPageParameters in interface PdfDecoderInt
    • waitForDecodingToFinish

      public void waitForDecodingToFinish()
      wait for decoding to finish
      Specified by:
      waitForDecodingToFinish in interface PdfDecoderInt
    • getDynamicRenderer

      public org.jpedal.render.DynamicVectorRenderer getDynamicRenderer()
      Not part of API - used internally

      gets DynamicVector Object

      Specified by:
      getDynamicRenderer in interface PdfDecoderInt
    • getDynamicRenderer

      public org.jpedal.render.DynamicVectorRenderer getDynamicRenderer(boolean reset)
      Not part of API - used internally

      gets DynamicVector Object - NOT PART OF API and subject to change (DO NOT USE)

      Specified by:
      getDynamicRenderer in interface PdfDecoderInt
    • getIO

      public org.jpedal.io.PdfObjectReader getIO()
      allow access to PDF file
      Specified by:
      getIO in interface PdfDecoderInt
      Returns:
      PdfObjectReader
    • decodePage

      public final void decodePage(int rawPage)
      decode a page, - page must be between 1 and PdfDecoder.getPageCount() - Will kill off if already running

      returns minus page if trying to open linearized page not yet available

      Specified by:
      decodePage in interface PdfDecoderInt
    • isPageAvailable

      public boolean isPageAvailable(int rawPage)
      see if page available if in Linearized mode or return true
      Specified by:
      isPageAvailable in interface PdfDecoderInt
      Parameters:
      rawPage - page to check
      Returns:
      boolean
    • drawAdditionalObjectsOverPage

      public void drawAdditionalObjectsOverPage(int page, int[] type, Color[] colors, Object[] obj) throws PdfException
      allow user to add grapical content on top of page - for display ONLY Additional calls will overwrite current settings on page ONLY works in SINGLE VIEW displaymode
      Specified by:
      drawAdditionalObjectsOverPage in interface PdfDecoderInt
      Throws:
      PdfException
    • flushAdditionalObjectsOnPage

      public void flushAdditionalObjectsOnPage(int page)
      allow user to remove all additional grapical content from the page (only for display) ONLY works in SINGLE VIEW displaymode
      Specified by:
      flushAdditionalObjectsOnPage in interface PdfDecoderInt
      Parameters:
      page - the page number to flush objects from
    • decodePageInBackground

      public final void decodePageInBackground(int i)
      decode a page as a background thread (use other background methods to access data)

      we now recommend you use decodePage as this has been heavily optimised for speed

      Specified by:
      decodePageInBackground in interface PdfDecoderInt
    • getPageCount

      public final int getPageCount()
      get page count of current PDF file
      Specified by:
      getPageCount in interface PdfDecoderInt
    • isEncrypted

      public final boolean isEncrypted()
      return true if the current pdf file is encrypted
      check isFileViewable(),

      if file is encrypted and not viewable - a user specified password is needed.
      Specified by:
      isEncrypted in interface PdfDecoderInt
    • isPasswordSupplied

      public final boolean isPasswordSupplied()
      show if encryption password has been supplied or set a certificate
      Specified by:
      isPasswordSupplied in interface PdfDecoderInt
    • isFileViewable

      public boolean isFileViewable()
      show if encrypted file can be viewed,
      if false a password needs entering
      Specified by:
      isFileViewable in interface PdfDecoderInt
    • isExtractionAllowed

      public boolean isExtractionAllowed()
      show if content can be extracted
      Specified by:
      isExtractionAllowed in interface PdfDecoderInt
    • setEncryptionPassword

      public final void setEncryptionPassword(String password) throws PdfException
      set a password for encryption - software will resolve if user or owner password- calls verifyAccess() from 2.74 so no separate call needed
      Specified by:
      setEncryptionPassword in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfArray

      public final void openPdfArray(byte[] data) throws PdfException
      routine to open a byte stream containing the PDF file and extract key info from pdf file so we can decode any pages. Does not actually decode the pages themselves - By default files over 16384 bytes are cached to disk but this can be altered by setting PdfFileReader.alwaysCacheInMemory to a maximimum size or -1 (always keep in memory)
      Specified by:
      openPdfArray in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfArray

      public final void openPdfArray(byte[] data, String password) throws PdfException
      routine to open a byte stream containing the PDF file and extract key info from pdf file so we can decode any pages. Does not actually decode the pages themselves - By default files over 16384 bytes are cached to disk but this can be altered by setting PdfFileReader.alwaysCacheInMemory to a maximimum size or -1 (always keep in memory)
      Specified by:
      openPdfArray in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFile

      public void openPdfFile(String filename, Certificate certificate, PrivateKey key) throws PdfException
      allow user to open file using Certificate and key
      Specified by:
      openPdfFile in interface PdfDecoderInt
      Parameters:
      filename - file to open
      certificate - certificate, if any
      key - key, if any
      Throws:
      PdfException
    • openPdfFileFromStream

      public final void openPdfFileFromStream(Object filename, String password) throws PdfException
      routine to open PDF file and extract key info from pdf file so we can decode any pages which also sets password. Does not actually decode the pages themselves. Also reads the form data. You must explicitly close your stream!!
      Specified by:
      openPdfFileFromStream in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFile

      public final void openPdfFile(String filename) throws PdfException
      routine to open PDF file and extract key info from pdf file so we can decode any pages. Does not actually decode the pages themselves. Also reads the form data. You must explicitly close any open files with closePdfFile() to Java will not release all the memory
      Specified by:
      openPdfFile in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFile

      public final void openPdfFile(String filename, String password) throws PdfException
      routine to open PDF file and extract key info from pdf file so we can decode any pages which also sets password. Does not actually decode the pages themselves. Also reads the form data. You must explicitly close any open files with closePdfFile() or Java will not release all the memory
      Specified by:
      openPdfFile in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFileFromURL

      public final boolean openPdfFileFromURL(String pdfUrl, boolean supportLinearized) throws PdfException
      routine to open PDF file via URL and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves - Also reads the form data - Based on an idea by Peter Jacobsen
      You must explicitly close any open files with closePdfFile() so Java will release all the memory

      If boolean supportLinearized is true, method will return with true value once Linearized part read

      Specified by:
      openPdfFileFromURL in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFileFromURL

      public final boolean openPdfFileFromURL(String pdfUrl, boolean supportLinearized, String password) throws PdfException
      routine to open PDF file via URL and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves - Also reads the form data - Based on an idea by Peter Jacobsen
      You must explicitly close any open files with closePdfFile() so Java will release all the memory

      If boolean supportLinearized is true, method will return with true value once Linearized part read

      Specified by:
      openPdfFileFromURL in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFileFromInputStream

      public final boolean openPdfFileFromInputStream(InputStream is, boolean supportLinearized) throws PdfException
      routine to open PDF file via InputStream and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves -
      You must explicitly close any open files with closePdfFile() to Java will not release all the memory

      IMPORTANT NOTE: If the stream does not contain enough bytes, test for Linearization may fail If boolean supportLinearized is true, method will return with true value once Linearized part read (we recommend use you false unless you know exactly what you are doing)

      Specified by:
      openPdfFileFromInputStream in interface PdfDecoderInt
      Throws:
      PdfException
    • openPdfFileFromInputStream

      public final boolean openPdfFileFromInputStream(InputStream is, boolean supportLinearized, String password) throws PdfException
      routine to open PDF file via InputStream and extract key info from pdf file so we can decode any pages - Does not actually decode the pages themselves -
      You must explicitly close any open files with closePdfFile() to Java will not release all the memory

      IMPORTANT NOTE: If the stream does not contain enough bytes, test for Linearization may fail If boolean supportLinearized is true, method will return with true value once Linearized part read (we recommend use you false unless you know exactly what you are doing)

      Specified by:
      openPdfFileFromInputStream in interface PdfDecoderInt
      Throws:
      PdfException
    • getJPedalObject

      public Object getJPedalObject(int id)
      Not part of API - used internally

      will return some dictionary values - if not a set value, will return null

      Specified by:
      getJPedalObject in interface PdfDecoderInt
      Returns:
      Object
    • setPageMode

      public void setPageMode(int mode)
      Not part of API - used internally
      Specified by:
      setPageMode in interface PdfDecoderInt
      Parameters:
      mode - mode
    • isXMLExtraction

      public boolean isXMLExtraction()
      shows if text extraction is XML or pure text
      Specified by:
      isXMLExtraction in interface PdfDecoderInt
    • useTextExtraction

      public void useTextExtraction()
      Controls type of text extraction if using JPedal purely for as a text extraction engine (otherwise do not touch) XML extraction is the default - pure text extraction is much faster for pure Text extraction, otherwise should not need to be set (for examples and more details see https://www.idrsolutions.com/how-to-extract-text-from-pdf-files/)
      Specified by:
      useTextExtraction in interface PdfDecoderInt
    • useXMLExtraction

      public void useXMLExtraction()
      Controls type of text extraction if using JPedal purely for as a text extraction engine (otherwise do not touch) XML extraction is the default - pure text extraction is much faster for pure Text extraction, otherwise should not need to be set (for examples and more details see https://www.idrsolutions.com/how-to-extract-text-from-pdf-files/)
      Specified by:
      useXMLExtraction in interface PdfDecoderInt
    • clearScreen

      public void clearScreen()
      remove all displayed objects for JPanel display (wipes current page)
    • setStreamCacheSize

      public void setStreamCacheSize(int size)
      allows user to cache large objects to disk to avoid memory issues, setting minimum size in bytes (of uncompressed stream) above which object will be stored on disk if possible (default is -1 bytes which is all objects stored in memory) - Must be set before file opened.
      Specified by:
      setStreamCacheSize in interface PdfDecoderInt
    • setUserOffsets

      public void setUserOffsets(int x, int y, int mode)
      Specified by:
      setUserOffsets in interface PdfDecoderInt
    • hasEmbeddedFonts

      public boolean hasEmbeddedFonts()
      shows if embedded fonts present on page just decoded
      Specified by:
      hasEmbeddedFonts in interface PdfDecoderInt
    • getPageFromObjectRef

      public int getPageFromObjectRef(String ref)
      given a ref, what is the page
      Specified by:
      getPageFromObjectRef in interface PdfDecoderInt
      Parameters:
      ref - - PDF object reference
      Returns:
      - page number with being first page
    • getInfo

      public String getInfo(int type)
      Returns list of the fonts used on the current page decoded or null type can be PdfDictionary.Font or PdfDictionary.Image
      Specified by:
      getInfo in interface PdfDecoderInt
    • getFormRenderer

      public org.jpedal.objects.acroforms.AcroRenderer getFormRenderer()
      Allow user to access Forms renderer object if needed
      Specified by:
      getFormRenderer in interface PdfDecoderInt
    • getJavaScript

      public org.jpedal.objects.Javascript getJavaScript()
      Allow user to access javascript object if needed
      Specified by:
      getJavaScript in interface PdfDecoderInt
    • getPageDecodeReport

      public String getPageDecodeReport()
      return any errors or other messages while calling decodePage() - zero length is no problems
      Specified by:
      getPageDecodeReport in interface PdfDecoderInt
    • getObjectStore

      public org.jpedal.io.ObjectStore getObjectStore()
      return object which provides access to file images and name
      Specified by:
      getObjectStore in interface PdfDecoderInt
    • setObjectStore

      public void setObjectStore(org.jpedal.io.ObjectStore newStore)
      return object which provides access to file images and name (use not recommended)
      Specified by:
      setObjectStore in interface PdfDecoderInt
    • getDecoderOptions

      public org.jpedal.parser.DecoderOptions getDecoderOptions()
      Return decoder options as object for cases where value is needed externally and can't be static
      Specified by:
      getDecoderOptions in interface PdfDecoderInt
      Returns:
      DecoderOptions object containing settings for this PdfDecoder object
    • getGroupingObject

      public org.jpedal.grouping.PdfGroupingAlgorithms getGroupingObject() throws PdfException
      returns object containing grouped text of last decoded page - if no page decoded, a Runtime exception is thrown to warn user Please see org.jpedal.examples.text for example code.
      Specified by:
      getGroupingObject in interface PdfDecoderInt
      Returns:
      object containing grouped text of last decoded page
      Throws:
      PdfException - if no page has been decoded
    • getBackgroundGroupingObject

      public org.jpedal.grouping.PdfGroupingAlgorithms getBackgroundGroupingObject()
      returns object containing grouped text from background grouping - Please see org.jpedal.examples.text for example code
      Specified by:
      getBackgroundGroupingObject in interface PdfDecoderInt
      Returns:
      an object containing grouped text from background grouping
    • getPDFVersion

      public final String getPDFVersion()
      get PDF version in file
      Specified by:
      getPDFVersion in interface PdfDecoderInt
    • hasAllImages

      public boolean hasAllImages()
      flag to show if we suspect problem with some images
      Returns:
      true if all images have been processed fully
    • getPageDecodeStatus

      public boolean getPageDecodeStatus(int status)
      returns booleans based on flags in DecodeStatus
      Specified by:
      getPageDecodeStatus in interface PdfDecoderInt
      Parameters:
      status - decode status
      Returns:
      boolean
    • getPageDecodeStatusReport

      public String getPageDecodeStatusReport(int status)
      get page statuses (flags in DecodeStatus)
      Specified by:
      getPageDecodeStatusReport in interface PdfDecoderInt
    • addExternalHandler

      public void addExternalHandler(Object newHandler, int type)
      not part of API used internally

      allows external helper classes to be added to JPedal to alter default functionality -

      Specified by:
      addExternalHandler in interface PdfDecoderInt
      Parameters:
      newHandler - handler to add
      type - type of handler
    • getExternalHandler

      public Object getExternalHandler(int type)
      not part of API used internally

      allows external helper classes to be accessed if needed - also allows user to access SwingGUI if running full Viewer package - not all Options available to get - please contact IDRsolutions if you are looking to use

      Specified by:
      getExternalHandler in interface PdfDecoderInt
      Parameters:
      type - type of handler
    • getFileName

      public String getFileName()
      currently open PDF file name
      Specified by:
      getFileName in interface PdfDecoderInt
      Returns:
      String
    • isForm

      public boolean isForm()
      return true if currently open PDF file is a PDF form
      Specified by:
      isForm in interface PdfDecoderInt
      Returns:
      boolean
    • getTextLines

      public TextLines getTextLines()
      access textlines object
      Specified by:
      getTextLines in interface PdfDecoderInt
      Returns:
      an object containing text lines
    • getPDFWidth

      public final int getPDFWidth()
      get sizes of panel
      This is the PDF pagesize (as set in the PDF from pagesize) - It now includes any scaling factor you have set
      Specified by:
      getPDFWidth in interface PdfDecoderInt
    • getPDFHeight

      public final int getPDFHeight()
      get sizes of panel - This is the PDF pagesize
      Specified by:
      getPDFHeight in interface PdfDecoderInt
    • getDisplayView

      public int getDisplayView()
      returns view mode used - ie SINGLE_PAGE,CONTINUOUS,FACING,CONTINUOUS_FACING (no effect in OS versions)
      Specified by:
      getDisplayView in interface PdfDecoderInt
    • getScaling

      public float getScaling()
      returns current scaling value used internally
      Specified by:
      getScaling in interface PdfDecoderInt
      Returns:
      float
    • getInsetH

      public int getInsetH()
      Description copied from interface: PdfDecoderInt
      Return amount to inset the page rectangle height by
      Specified by:
      getInsetH in interface PdfDecoderInt
      Returns:
      int
    • getInsetW

      public int getInsetW()
      Description copied from interface: PdfDecoderInt
      Return amount to inset the page rectangle width by
      Specified by:
      getInsetW in interface PdfDecoderInt
      Returns:
      int
    • getSelectedRectangleOnscreen

      public BufferedImage getSelectedRectangleOnscreen(float t_x1, float t_y1, float t_x2, float t_y2, float scaling)
      Specified by:
      getSelectedRectangleOnscreen in interface PdfDecoderInt
    • getScrollInterval

      public int getScrollInterval()
      Description copied from interface: PdfDecoderInt
      Return amount to scroll window by when scrolling (default is 10).
      Specified by:
      getScrollInterval in interface PdfDecoderInt
      Returns:
      int
    • setScrollInterval

      public void setScrollInterval(int scrollInterval)
      Description copied from interface: PdfDecoderInt
      Sets the ammount to scroll the window by (default is 10).
      Specified by:
      setScrollInterval in interface PdfDecoderInt
      Parameters:
      scrollInterval - scroll interval
    • resetForNonPDFPage

      public void resetForNonPDFPage(int pageCount)
      Description copied from interface: PdfDecoderInt
      used for non-PDF files to reset page
      Specified by:
      resetForNonPDFPage in interface PdfDecoderInt
      Parameters:
      pageCount - the new page count
    • setPDFBorder

      public void setPDFBorder(Border newBorder)
      Specified by:
      setPDFBorder in interface PdfDecoderInt
    • updateCursorBoxOnScreen

      public void updateCursorBoxOnScreen(int[] rectParams, int outlineColor)
      Specified by:
      updateCursorBoxOnScreen in interface PdfDecoderInt
    • setHardwareAccelerationforScreen

      public void setHardwareAccelerationforScreen(boolean useAcceleration)
      Specified by:
      setHardwareAccelerationforScreen in interface PdfDecoderInt
    • getExternalHandler

      public org.jpedal.external.ExternalHandlers getExternalHandler()
      Specified by:
      getExternalHandler in interface PdfDecoderInt
    • getSpecialMode

      public int getSpecialMode()
      retusn a value defined in SpecialOptions used internally and in custom JPedal releases in PdfDecoder - always returns 0 in this class
      Specified by:
      getSpecialMode in interface PdfDecoderInt
      Returns:
      int
    • useNewGraphicsMode

      public boolean useNewGraphicsMode()
      Specified by:
      useNewGraphicsMode in interface PdfDecoderInt
    • useNewGraphicsMode

      public void useNewGraphicsMode(boolean isEnabled)
      switches on or off glow border in JPedal viewer - does nothing in this class
      Specified by:
      useNewGraphicsMode in interface PdfDecoderInt
      Parameters:
      isEnabled - true to turn on glow border in jpedal viewer
    • setScaling

      public void setScaling(float scaleFactor)
      allow user to adjust scaling factor on page in Viewer - DOES NOTHING in this class
      Specified by:
      setScaling in interface PdfDecoderInt
      Parameters:
      scaleFactor - the scale factor to be applied to the page
    • setStatusBarObject

      public void setStatusBarObject(org.jpedal.io.StatusBar statusBar)
      Specified by:
      setStatusBarObject in interface PdfDecoderInt
    • setInset

      public void setInset(int width, int height)
      Specified by:
      setInset in interface PdfDecoderInt
    • getMaxSizeWH

      public int[] getMaxSizeWH()
      Specified by:
      getMaxSizeWH in interface PdfDecoderInt
    • getPaneBounds

      public int[] getPaneBounds()
      Specified by:
      getPaneBounds in interface PdfDecoderInt
    • repaintPane

      public void repaintPane(int page)
      Specified by:
      repaintPane in interface PdfDecoderInt
    • requestFocus

      public void requestFocus()
      Specified by:
      requestFocus in interface PdfDecoderInt
    • setPreviewThumbnail

      public void setPreviewThumbnail(BufferedImage previewImage, String previewText)
      internal method used by Viewer to provide preview of PDF in Viewer
      Specified by:
      setPreviewThumbnail in interface PdfDecoderInt
    • getTextPrint

      public int getTextPrint()
      Specified by:
      getTextPrint in interface PdfDecoderInt
    • repaint

      public void repaint()
      Specified by:
      repaint in interface PdfDecoderInt
    • repaintOffscreenImage

      public void repaintOffscreenImage()
      Specified by:
      repaintOffscreenImage in interface PdfDecoderInt
    • getVisibleRect

      public Rectangle getVisibleRect()
      Specified by:
      getVisibleRect in interface PdfDecoderInt
    • getDisplayOffsets

      public org.jpedal.display.DisplayOffsets getDisplayOffsets()
      Specified by:
      getDisplayOffsets in interface PdfDecoderInt
    • getViewerPreferences

      public org.jpedal.objects.raw.PdfObject getViewerPreferences()
      Specified by:
      getViewerPreferences in interface PdfDecoderInt