Class PdfDecoder
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jpedal.PdfDecoder
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Pageable
,Printable
,Serializable
,Accessible
,org.jpedal.PdfDecoderInt
public class PdfDecoder extends JPanel implements Printable, Pageable, org.jpedal.PdfDecoderInt
Provides an object to decode pdf files, view and print in Swing and provide a rasterizer if required - Normal usage is to create instance of PdfDecoder and access via public methods.
If you only want to rasterize or extracxt text and images you can use PdfDecoderServer
Examples showing usage in org.jpedal.examples
We recommend you access JPedal using only public methods listed in API- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
-
Field Summary
Fields Modifier and Type Field Description org.jpedal.display.Display
pages
org.jpedal.parser.SwingPrinter
swingPrinter
static String
version
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
-
Fields inherited from interface org.jpedal.PdfDecoderInt
CLIPPEDIMAGES, FINALIMAGES, NOTEXTPRINT, RASTERIZE_FORMS, RAWCOMMANDS, RAWIMAGES, REMOVE_NOFORMS, REMOVE_RENDERSHAPES, RENDERIMAGES, RENDERTEXT, STANDARDTEXTSTRINGPRINT, SUBSTITUTE_FONT_USING_FAMILY_NAME, SUBSTITUTE_FONT_USING_FILE_NAME, SUBSTITUTE_FONT_USING_FULL_FONT_NAME, SUBSTITUTE_FONT_USING_POSTSCRIPT_NAME, SUBSTITUTE_FONT_USING_POSTSCRIPT_NAME_USE_FAMILY_NAME_IF_DUPLICATES, TEXT, TEXTCOLOR, TEXTGLYPHPRINT, TEXTSTRINGPRINT, XFORMMETADATA
-
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
-
Constructor Summary
Constructors Constructor Description PdfDecoder()
Recommend way to create a PdfDecoder for renderer only viewer (not recommended for server extraction only processes)PdfDecoder(boolean newRender)
Recommend way to create a PdfDecoder if no rendering of page may be required
Otherwise use PdfDecoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExternalHandler(Object newHandler, int type)
not part of API used internallyvoid
clearScreen()
remove all displayed objects for JPanel display (wipes current page)void
closePdfFile()
convenience method to close the current PDF file and release all resources/delete any temporary filesvoid
decodePage(int rawPage)
decode a page, - page must be between 1 and PdfDecoder.getPageCount() - Will kill off if already runningvoid
decodePageInBackground(int i)
decode a page as a background thread (use other background methods to access data)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()static void
disposeAllStatic()
remove all static elements - only do once completely finished with JPedal as will not be reinitialisedvoid
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 displaymodevoid
ensurePointIsVisible(Point p)
make screen scroll to ensure point is visiblevoid
flushAdditionalObjectsOnPage(int page)
allow user to remove all additional grapical content from the page (only for display) ONLY works in SINGLE VIEW displaymodevoid
flushObjectValues(boolean reinit)
provide method for outside class to clear store of objects once written out to reclaim memoryorg.jpedal.grouping.PdfGroupingAlgorithms
getBackgroundGroupingObject()
returns object containing grouped text from background grouping - Please see org.jpedal.examples.text for example codeint
getCurrentPrintPage()
return page currently being printed or -1 if finishedorg.jpedal.parser.DecoderOptions
getDecoderOptions()
Return decoder options as object for cases where value is needed externally and can't be staticorg.jpedal.display.DisplayOffsets
getDisplayOffsets()
int
getDisplayRotation()
current page rotation (in addition to rotation in file) in degrees So if user turns page by 90 degrees, value will be 90int
getDisplayView()
returns view mode used - ie SINGLE_PAGE,CONTINUOUS,FACING,CONTINUOUS_FACING (no effect in OS versions)org.jpedal.utils.DPIFactory
getDPIFactory()
return handle on PDFFactory which adjusts display size so matches size in Acrobatorg.jpedal.render.DynamicVectorRenderer
getDynamicRenderer()
Not part of API - used internallyorg.jpedal.render.DynamicVectorRenderer
getDynamicRenderer(boolean reset)
Not part of API - used internallyorg.jpedal.external.ExternalHandlers
getExternalHandler()
Object
getExternalHandler(int type)
not part of API used internallyorg.jpedal.objects.PdfFileInformation
getFileInformationData()
method to return null or object giving access info fields and metadata.String
getFileName()
currently open PDF file nameorg.jpedal.objects.acroforms.AcroRenderer
getFormRenderer()
Allow user to access Forms renderer object if neededorg.jpedal.grouping.PdfGroupingAlgorithms
getGroupingObject()
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
getHiResUpscaleFactor()
return scaleup factor applied to last Hires image of page generatedString
getInfo(int type)
Returns list of the fonts used on the current page decoded or null type can be PdfDictionary.Font or PdfDictionary.Imageint
getInsetH()
Return amount to inset the page rectangle height byint
getInsetW()
Return amount to inset the page rectangle width byorg.jpedal.io.PdfObjectReader
getIO()
allow access to PDF fileorg.jpedal.objects.Javascript
getJavaScript()
Allow user to access javascript object if neededObject
getJPedalObject(int id)
Not part of API - used internallyint
getlastPageDecoded()
return page number for last page decoded (only use in SingleDisplay mode)Document
getMarkedContent()
return markedContent object as XML DocumentDimension
getMaximumSize()
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 (ie a PDF size 800 * 600 with a scaling factor of 2 will return 1600 *1200)int[]
getMaxSizeWH()
Dimension
getMinimumSize()
get width of panelint
getNumberOfPages()
part of pageable interface - used only in printing Use getPageCount() for number of pagesorg.jpedal.io.ObjectStore
getObjectStore()
return object which provides access to file images and nameDocument
getOutlineAsXML()
return a DOM document containing the PDF Outline object as a DOM Document - may return nullorg.jpedal.objects.outlines.OutlineData
getOutlineData()
provide direct access to outlineData objectint
getPageAlignment()
return type of alignment for pages if smaller than panel - see options in Display class.BufferedImage
getPageAsHiRes(int pageIndex)
BufferedImage
getPageAsHiRes(int pageIndex, boolean isTransparent)
BufferedImage
getPageAsHiRes(int pageIndex, Map<Integer,Object> params)
BufferedImage
getPageAsHiRes(int pageIndex, Map<Integer,Object> params, boolean isTransparent)
BufferedImage
getPageAsImage(int pageIndex)
generate BufferedImage of a page in current fileBufferedImage
getPageAsImage(int pageIndex, float scaling)
generate BufferedImage of a page in current fileBufferedImage
getPageAsTransparentImage(int pageIndex)
generate BufferedImage of a page in current fileint
getPageCount()
get page count of current PDF fileString
getPageDecodeReport()
return any errors or other messages while calling decodePage() - zero length is no problemsboolean
getPageDecodeStatus(int status)
returns booleans based on flags in class org.jpedal.parser.DecoderStatusString
getPageDecodeStatusReport(int status)
get page statuses (flags in class org.jpedal.parser.DecoderStatus)String
getPageFailureMessage()
Return String with all error messages from last printed (useful for debugging)PageFormat
getPageFormat(int p)
part of pageable interfaceint
getPageFromObjectRef(String ref)
given a ref, what is the pageIterator<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 resultint
getPageNumber()
current logical page numberorg.jpedal.display.Display
getPages()
int[]
getPaneBounds()
org.jpedal.objects.PdfData
getPdfBackgroundData()
NOT PART OF APIorg.jpedal.objects.PdfImageData
getPdfBackgroundImageData()
provide method for outside class to get data object containing images.Border
getPDFBorder()
get border for screen and print which will be displayedsorg.jpedal.objects.PdfData
getPdfData()
Access should not generally be required to this class but used in examples.int
getPDFHeight()
get sizes of panel - This is the PDF pagesizeorg.jpedal.objects.PdfImageData
getPdfImageData()
provide method for outside class to get data object containing imagesorg.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.String
getPDFVersion()
get PDF version in fileint
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 setDimension
getPreferredSize()
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 (ie a PDF size 800 * 600 with a scaling factor of 2 will return 1600 *1200)Printable
getPrintable(int page)
part of pageable interfacefloat
getScaling()
returns current scaling value used internallyint
getScrollInterval()
return amount to scroll window by when scrolling (default is 10)BufferedImage
getSelectedRectangleOnscreen(float t_x1, float t_y1, float t_x2, float t_y2, float scaling)
If running in GUI mode, will extract a section of rendered page as BufferedImage -coordinates are PDF co-ordinates.int
getSpecialMode()
retusn a value defined in SpecialOptions used internally and in custom JPedal releasesorg.jpedal.text.TextLines
getTextLines()
access textlines objectint
getTextPrint()
Point
getUserOffsets(int mode)
not part of API used internallyPageFormat
getUserSetPageFormat(int p)
Returns pageFormats set by the user for a given page or a standard page format for all pages if set.org.jpedal.objects.raw.PdfObject
getViewerPreferences()
boolean
hasAllImages()
flag to show if we suspect problem with some imagesboolean
hasEmbeddedFonts()
shows if embedded fonts present on page just decodedboolean
hasOutline()
flag to show if PDF document contains an outlinestatic void
init(boolean newEmbedWidthData)
This will be needed for text extraction and set to true as paramter makes sure widths included in text streamboolean
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.boolean
isExtractionAllowed()
show if content can be extractedboolean
isFileViewable()
show if encrypted file can be viewed,
if false a password needs enteringboolean
isForm()
return true if currently open PDF file is an FDF formboolean
isLoadingLinearizedPDF()
track if file still loaded in backgroundboolean
isOpen()
see if file open - may not be open if user interrupted open or problem encounteredboolean
isPageAvailable(int rawPage)
see if page available if in Linearized mode or return trueboolean
isPageSuccessful()
shows if page reported any errors while printing.boolean
isPasswordSupplied()
show if encryption password has been supplied or set a certificateboolean
isXMLExtraction()
shows if text extraction is XML or pure textstatic void
modifyJPedalParameters(Map<Integer,Object> values)
allow user to alter certain values in software such as Colour,void
modifyNonstaticJPedalParameters(Map<Integer,Object> values)
allow user to alter certain values in software such as Colour,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.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.void
openPdfFile(String filename)
routine to open PDF file and extract key info from pdf file so we can decode any pages.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 keyboolean
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 memoryboolean
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 memoryvoid
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.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 memoryboolean
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 memoryvoid
paint(Graphics g)
void
paintComponent(Graphics g)
standard method to draw page and any highlights onto JPanelint
print(Graphics graphics, PageFormat pageFormat, int page)
Implements the standard Java printing functionality.void
printAdditionalObjectsOverAllPages(int[] type, Color[] colors, Object[] obj)
store objects to use on a printvoid
printAdditionalObjectsOverPage(int page, int[] type, Color[] colors, Object[] obj)
store objects to use on a printvoid
repaintPane(int page)
void
requestFocus()
void
resetCurrentPrintPage()
void
resetForNonPDFPage(int pageCount)
used for non-PDF files to reset pagevoid
setAllowDifferentPrintPageSizes(boolean allowDifferentPrintPageSizes)
allow printing of different sizes pagesvoid
setCenterOnScaling(boolean center)
Specify if the pdf page should be centered within the pageformat when print.void
setCursor(Cursor c)
void
setDefaultCursor(Cursor c)
When changing the mouse mode we call this method to set the mouse mode default cursorvoid
setDisplayRotation(int newRotation)
void
setEncryptionPassword(String password)
set a password for encryption - software will resolve if user or owner password- calls verifyAccess() from 2.74 so no separate call neededvoid
setEncryptTempFiles()
ensure that files are always encrypted if cached to disk regardless of whether file has a password setvoid
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 examplesvoid
setExtractionMode(int mode, float scaling)
Please do not use for general usage.void
setHardwareAccelerationforScreen(boolean useAcceleration)
Enables/Disables hardware acceleration of screen rendering (default is on)void
setInset(int width, int height)
set an inset display so that display will not touch edge of panelvoid
setObjectStore(org.jpedal.io.ObjectStore newStore)
return object which provides access to file images and name (use not recommended)void
setPageFormat(int p, PageFormat pf)
Set PageFormat for a specific page when printing.void
setPageFormat(PageFormat pf)
Set PageFormat to be used when a specific PageFormat has not been set for a page.void
setPageMode(int mode)
Not part of API - used internallyvoid
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 settingvoid
setPageParameters(float scaling, int pageNumber, int newRotation)
calls setPageParameters(scaling,pageNumber) after setting rotation to draw pagevoid
setPagePrintRange(int start, int end)
set page range (inclusive) - If end is less than start it will print them backwards (invalid range will throw PdfException)void
setPagePrintRange(SetOfIntegerSyntax range)
set inclusive range to print (see SilentPrint.java and Viewer.java for sample print code (invalid range will throw PdfException) can take values such as new PageRanges("3,5,7-9,15");void
setPDFBorder(Border newBorder)
set border for screen and print which will be displayed
Setting a new value will enable screen and border painting - disable with disableBorderForPrinting()void
setPDFCursor(Cursor c)
Override setCursor so that we can turn on and offvoid
setPreviewThumbnail(BufferedImage previewImage, String previewText)
internal method used by Viewer to provide preview of PDF in Viewervoid
setPrintAutoRotate(boolean rotate)
Specify if the pdf page should be rotated to best fit the printed page imagable area.void
setPrintAutoRotateAndCenter(boolean value)
set print mode (Matches Abodes Auto Print and rotate outputvoid
setPrintCurrentView(boolean value)
tell printout to print only visible area in viewer if setvoid
setPrintIndent(int oddPages, int evenPages)
set a left margin for printing pages (ie for duplex)void
setPrintPageMode(int mode)
allow user to select only odd or even pages to printvoid
setPrintPageScalingMode(int pageScalingMode)
set page scaling mode to use - default setting is PAGE_SCALING_REDUCE_TO_PRINTER_MARGINS All values start PAGE_SCALINGvoid
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 pagevoid
setScrollInterval(int scrollInterval)
set amount to scroll window by when scrollingvoid
setStatusBarObject(org.jpedal.io.StatusBar statusBar)
Not part of API - used internallyvoid
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.void
setTextPrint(int textPrint)
tells program to try and use Java's font printing if possible as work around for issue with PCL printing - values are PdfDecoder.TEXTGLYPHPRINT (use Java to rasterize font if available) PdfDecoder.TEXTSTRINGPRINT( print as text not raster - fastest option) PdfDecoder.NOTEXTPRINT (default - highest quality)void
setUsePDFPaperSize(boolean usePDFPaperSize)
void
setUserOffsets(int x, int y, int mode)
not part of API used internallyvoid
stopPrinting()
ask JPedal to stop printing a pagevoid
updateCursorBoxOnScreen(int[] rectParams, int outlineColor)
update rectangle we draw to highlight an area - See Viewer example for example code showing current usage.void
useLogicalPrintOffset(int pagesPrinted)
If you are printing PDFs using JPedal in your custom code, you may find pages missing, because JPedal does not know about these additional pages.boolean
useNewGraphicsMode()
void
useNewGraphicsMode(boolean isEnabled)
switches on or off glow border in JPedal viewervoid
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/)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/)void
waitForDecodingToFinish()
wait for decoding to finish-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
version
public static final String version
-
swingPrinter
public final org.jpedal.parser.SwingPrinter swingPrinter
-
pages
public org.jpedal.display.Display pages
-
-
Constructor Detail
-
PdfDecoder
public PdfDecoder(boolean newRender)
Recommend way to create a PdfDecoder if no rendering of page may be required
Otherwise use PdfDecoder()- Parameters:
newRender
- flag to show if pages are being rendered (true) or only extraction taking place (flase).
-
PdfDecoder
public PdfDecoder()
Recommend way to create a PdfDecoder for renderer only viewer (not recommended for server extraction only processes)
-
-
Method Detail
-
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 interfaceorg.jpedal.PdfDecoderInt
-
isOpen
public boolean isOpen()
see if file open - may not be open if user interrupted open or problem encountered- Specified by:
isOpen
in interfaceorg.jpedal.PdfDecoderInt
-
getMarkedContent
public Document getMarkedContent()
return markedContent object as XML Document- Specified by:
getMarkedContent
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- Document containing XML structure with data
-
getExternalHandler
public org.jpedal.external.ExternalHandlers getExternalHandler()
- Specified by:
getExternalHandler
in interfaceorg.jpedal.PdfDecoderInt
-
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 interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int current display rotation
-
getPageNumber
public int getPageNumber()
current logical page number- Specified by:
getPageNumber
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int current page number
-
setDisplayRotation
public void setDisplayRotation(int newRotation)
- Specified by:
setDisplayRotation
in interfaceorg.jpedal.PdfDecoderInt
-
getPages
public org.jpedal.display.Display getPages()
- Specified by:
getPages
in interfaceorg.jpedal.PdfDecoderInt
-
getlastPageDecoded
public int getlastPageDecoded()
return page number for last page decoded (only use in SingleDisplay mode)- Specified by:
getlastPageDecoded
in interfaceorg.jpedal.PdfDecoderInt
-
getDisplayOffsets
public org.jpedal.display.DisplayOffsets getDisplayOffsets()
- Specified by:
getDisplayOffsets
in interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
getOutlineData
public org.jpedal.objects.outlines.OutlineData getOutlineData()
provide direct access to outlineData object- Specified by:
getOutlineData
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- OutlineData outline of current file
-
isLoadingLinearizedPDF
public boolean isLoadingLinearizedPDF()
track if file still loaded in background- Specified by:
isLoadingLinearizedPDF
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- boolean true if PDF is linearized
-
setScaling
public void setScaling(float scaleFactor)
allow user to adjust scaling factor on page- Specified by:
setScaling
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
scaleFactor
-
-
getPageAlignment
public int getPageAlignment()
return type of alignment for pages if smaller than panel - see options in Display class.- Specified by:
getPageAlignment
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
getPdfBackgroundData
public final org.jpedal.objects.PdfData getPdfBackgroundData()
NOT PART OF APIAccess 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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
- Returns:
- PdfPageData object
-
setPagePrintRange
public void setPagePrintRange(int start, int end) throws PdfException
set page range (inclusive) - If end is less than start it will print them backwards (invalid range will throw PdfException)- Parameters:
start
- start of page rangeend
- end of page range- Throws:
PdfException
- when range is invalid
-
setTextPrint
public void setTextPrint(int textPrint)
tells program to try and use Java's font printing if possible as work around for issue with PCL printing - values are PdfDecoder.TEXTGLYPHPRINT (use Java to rasterize font if available) PdfDecoder.TEXTSTRINGPRINT( print as text not raster - fastest option) PdfDecoder.NOTEXTPRINT (default - highest quality)- Parameters:
textPrint
- text print
-
useLogicalPrintOffset
public void useLogicalPrintOffset(int pagesPrinted)
If you are printing PDFs using JPedal in your custom code, you may find pages missing, because JPedal does not know about these additional pages. This method allows you to tell JPedal you have already printed pagesPrinted- Parameters:
pagesPrinted
- pages printed
-
print
public int print(Graphics graphics, PageFormat pageFormat, int page) throws PrinterException
Implements the standard Java printing functionality.- Specified by:
print
in interfacePrintable
- Parameters:
graphics
- the context into which the page is drawnpageFormat
- the size and orientation of the page being drawnpage
- the zero based index of the page to be drawn- Returns:
- int Printable.PAGE_EXISTS or Printable.NO_SUCH_PAGE
- Throws:
PrinterException
- PrinterException
-
getPageAsHiRes
public BufferedImage getPageAsHiRes(int pageIndex) throws PdfException
- Specified by:
getPageAsHiRes
in interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
- Parameters:
pageIndex
- number of the page we want to extractparams
- 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 interfaceorg.jpedal.PdfDecoderInt
- Parameters:
pageIndex
- number of the page we want to extractparams
- list of values to override static settings in modifyJPedalParameters for this instance onlyisTransparent
- - 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 interfaceorg.jpedal.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 filePage 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 interfaceorg.jpedal.PdfDecoderInt
- Throws:
PdfException
-
getPageAsImage
public BufferedImage getPageAsImage(int pageIndex, float scaling) throws PdfException
generate BufferedImage of a page in current filePage size is defined by CropBox
- Specified by:
getPageAsImage
in interfaceorg.jpedal.PdfDecoderInt
- Throws:
PdfException
-
getPageAsTransparentImage
public BufferedImage getPageAsTransparentImage(int pageIndex) throws PdfException
generate BufferedImage of a page in current filePage size is defined by CropBox see http://files.idrsolutions.com/samplecode/org/jpedal/examples/images/ConvertPagesToImages.java.html for full details
- Specified by:
getPageAsTransparentImage
in interfaceorg.jpedal.PdfDecoderInt
- Throws:
PdfException
-
getHiResUpscaleFactor
public float getHiResUpscaleFactor()
return scaleup factor applied to last Hires image of page generatednegative values mean no upscaling applied and should be ignored
- Specified by:
getHiResUpscaleFactor
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- float hires upscale factor
-
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 interfaceorg.jpedal.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 imagesPlease look at examples for usage
- Specified by:
getPdfImageData
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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
- Map of Jpedal Parameters- Throws:
PdfException
- PdfException
-
getFileInformationData
public final org.jpedal.objects.PdfFileInformation getFileInformationData()
method to return null or object giving access info fields and metadata.- Specified by:
getFileInformationData
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
- Returns:
- DPIFactory
-
setPageParameters
public 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 interfaceorg.jpedal.PdfDecoderInt
-
setPageParameters
public void setPageParameters(float scaling, int pageNumber, int newRotation)
calls setPageParameters(scaling,pageNumber) after setting rotation to draw page- Specified by:
setPageParameters
in interfaceorg.jpedal.PdfDecoderInt
-
setStatusBarObject
public void setStatusBarObject(org.jpedal.io.StatusBar statusBar)
Not part of API - used internallyset status bar to use when decoding a page - StatusBar provides a GUI object to display progress and messages.
- Specified by:
setStatusBarObject
in interfaceorg.jpedal.PdfDecoderInt
-
waitForDecodingToFinish
public void waitForDecodingToFinish()
wait for decoding to finish- Specified by:
waitForDecodingToFinish
in interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
getDynamicRenderer
public org.jpedal.render.DynamicVectorRenderer getDynamicRenderer()
Not part of API - used internallygets DynamicVector Object
- Specified by:
getDynamicRenderer
in interfaceorg.jpedal.PdfDecoderInt
-
getDynamicRenderer
public org.jpedal.render.DynamicVectorRenderer getDynamicRenderer(boolean reset)
Not part of API - used internallygets DynamicVector Object - NOT PART OF API and subject to change (DO NOT USE)
- Specified by:
getDynamicRenderer
in interfaceorg.jpedal.PdfDecoderInt
-
setPDFCursor
public void setPDFCursor(Cursor c)
Override setCursor so that we can turn on and off- Parameters:
c
- Cursor
-
setDefaultCursor
public void setDefaultCursor(Cursor c)
When changing the mouse mode we call this method to set the mouse mode default cursor- Parameters:
c
- :: The cursor to set as the default
-
decodePage
public final void decodePage(int rawPage)
decode a page, - page must be between 1 and PdfDecoder.getPageCount() - Will kill off if already runningreturns minus page if trying to open linearized page not yet available
- Specified by:
decodePage
in interfaceorg.jpedal.PdfDecoderInt
-
isPageAvailable
public boolean isPageAvailable(int rawPage)
see if page available if in Linearized mode or return true- Specified by:
isPageAvailable
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
rawPage
- page to be checked- Returns:
- boolean true if page is available
-
printAdditionalObjectsOverPage
public void printAdditionalObjectsOverPage(int page, int[] type, Color[] colors, Object[] obj)
store objects to use on a print- Parameters:
page
- page to be drawn overtype
- type usedcolors
- colours usedobj
- Objects drawn
-
printAdditionalObjectsOverAllPages
public void printAdditionalObjectsOverAllPages(int[] type, Color[] colors, Object[] obj)
store objects to use on a print- Parameters:
type
- type usedcolors
- colours usedobj
- objects drawn
-
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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
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 interfaceorg.jpedal.PdfDecoderInt
-
getPageCount
public final int getPageCount()
get page count of current PDF file- Specified by:
getPageCount
in interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
isPasswordSupplied
public final boolean isPasswordSupplied()
show if encryption password has been supplied or set a certificate- Specified by:
isPasswordSupplied
in interfaceorg.jpedal.PdfDecoderInt
-
isFileViewable
public boolean isFileViewable()
show if encrypted file can be viewed,
if false a password needs entering- Specified by:
isFileViewable
in interfaceorg.jpedal.PdfDecoderInt
-
isExtractionAllowed
public boolean isExtractionAllowed()
show if content can be extracted- Specified by:
isExtractionAllowed
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
- Parameters:
filename
- The name of the file to opencertificate
- certificate of PDF filekey
- private key of PDF file- 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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 memoryIMPORTANT 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 interfaceorg.jpedal.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 memoryIMPORTANT 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 interfaceorg.jpedal.PdfDecoderInt
- Throws:
PdfException
-
getJPedalObject
public Object getJPedalObject(int id)
Not part of API - used internallywill return some dictionary values - if not a set value, will return null
- Specified by:
getJPedalObject
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- Object jpedal object
-
setPageMode
public void setPageMode(int mode)
Not part of API - used internally- Specified by:
setPageMode
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
mode
- page mode
-
isXMLExtraction
public boolean isXMLExtraction()
shows if text extraction is XML or pure text- Specified by:
isXMLExtraction
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
hasEmbeddedFonts
public boolean hasEmbeddedFonts()
shows if embedded fonts present on page just decoded- Specified by:
hasEmbeddedFonts
in interfaceorg.jpedal.PdfDecoderInt
-
getPageFromObjectRef
public int getPageFromObjectRef(String ref)
given a ref, what is the page- Specified by:
getPageFromObjectRef
in interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
-
getFormRenderer
public org.jpedal.objects.acroforms.AcroRenderer getFormRenderer()
Allow user to access Forms renderer object if needed- Specified by:
getFormRenderer
in interfaceorg.jpedal.PdfDecoderInt
-
getJavaScript
public org.jpedal.objects.Javascript getJavaScript()
Allow user to access javascript object if needed- Specified by:
getJavaScript
in interfaceorg.jpedal.PdfDecoderInt
-
isPageSuccessful
public boolean isPageSuccessful()
shows if page reported any errors while printing. Log can be found with getPageFailureMessage()- Returns:
- Returns the printingSuccessful.
-
getPageDecodeReport
public String getPageDecodeReport()
return any errors or other messages while calling decodePage() - zero length is no problems- Specified by:
getPageDecodeReport
in interfaceorg.jpedal.PdfDecoderInt
-
getPageFailureMessage
public String getPageFailureMessage()
Return String with all error messages from last printed (useful for debugging)- Returns:
- String
-
getSelectedRectangleOnscreen
public BufferedImage getSelectedRectangleOnscreen(float t_x1, float t_y1, float t_x2, float t_y2, float scaling)
If running in GUI mode, will extract a section of rendered page as BufferedImage -coordinates are PDF co-ordinates. If you wish to use hires image, you will need to enable hires image display with- Specified by:
getSelectedRectangleOnscreen
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
t_x1
- x1 coordinatet_y1
- y1 coordinatet_x2
- x2 coordinatet_y2
- y2 coordinatescaling
- scaling of rectangle- Returns:
- pageErrorMessages - Any printer errors
-
getObjectStore
public org.jpedal.io.ObjectStore getObjectStore()
return object which provides access to file images and name- Specified by:
getObjectStore
in interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.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 interfaceorg.jpedal.PdfDecoderInt
- Throws:
PdfException
-
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 interfaceorg.jpedal.PdfDecoderInt
-
getPDFVersion
public final String getPDFVersion()
get PDF version in file- Specified by:
getPDFVersion
in interfaceorg.jpedal.PdfDecoderInt
-
resetForNonPDFPage
public void resetForNonPDFPage(int pageCount)
used for non-PDF files to reset page- Specified by:
resetForNonPDFPage
in interfaceorg.jpedal.PdfDecoderInt
-
hasAllImages
public boolean hasAllImages()
flag to show if we suspect problem with some images- Returns:
- boolean
-
getPageDecodeStatus
public boolean getPageDecodeStatus(int status)
returns booleans based on flags in class org.jpedal.parser.DecoderStatus- Specified by:
getPageDecodeStatus
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
status
- status of decoding- Returns:
- boolean based on flags in DecoderStatus
-
getPageDecodeStatusReport
public String getPageDecodeStatusReport(int status)
get page statuses (flags in class org.jpedal.parser.DecoderStatus)- Specified by:
getPageDecodeStatusReport
in interfaceorg.jpedal.PdfDecoderInt
-
setPrintAutoRotateAndCenter
public void setPrintAutoRotateAndCenter(boolean value)
set print mode (Matches Abodes Auto Print and rotate output- Parameters:
value
- mode to be set
-
setPrintCurrentView
public void setPrintCurrentView(boolean value)
tell printout to print only visible area in viewer if set- Parameters:
value
- true if only visible area should be printed
-
addExternalHandler
public void addExternalHandler(Object newHandler, int type)
not part of API used internallyallows external helper classes to be added to JPedal to alter default functionality -
- Specified by:
addExternalHandler
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
newHandler
- Handler to addtype
- type of handler
-
getExternalHandler
public Object getExternalHandler(int type)
not part of API used internallyallows 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 interfaceorg.jpedal.PdfDecoderInt
- Parameters:
type
- type of handler
-
getIO
public org.jpedal.io.PdfObjectReader getIO()
allow access to PDF file- Specified by:
getIO
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- PdfObjectReader
-
getFileName
public String getFileName()
currently open PDF file name- Specified by:
getFileName
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- String
-
isForm
public boolean isForm()
return true if currently open PDF file is an FDF form- Specified by:
isForm
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- boolean
-
getPrintable
public Printable getPrintable(int page) throws IndexOutOfBoundsException
part of pageable interface- Specified by:
getPrintable
in interfacePageable
- Throws:
IndexOutOfBoundsException
-
setAllowDifferentPrintPageSizes
public void setAllowDifferentPrintPageSizes(boolean allowDifferentPrintPageSizes)
allow printing of different sizes pages- Parameters:
allowDifferentPrintPageSizes
- true if printing of different sized pages is allowed
-
getTextLines
public org.jpedal.text.TextLines getTextLines()
access textlines object- Specified by:
getTextLines
in interfaceorg.jpedal.PdfDecoderInt
-
setInset
public final void setInset(int width, int height)
set an inset display so that display will not touch edge of panel- Specified by:
setInset
in interfaceorg.jpedal.PdfDecoderInt
-
ensurePointIsVisible
public void ensurePointIsVisible(Point p)
make screen scroll to ensure point is visible- Parameters:
p
- Point to be made visible
-
setPrintIndent
public void setPrintIndent(int oddPages, int evenPages)
set a left margin for printing pages (ie for duplex)- Parameters:
oddPages
- oddPagesevenPages
- evenpages
-
setUserOffsets
public void setUserOffsets(int x, int y, int mode)
not part of API used internallyallow user to 'move' display of PDF
mode is a Constant in org.jpedal.external.OffsetOptions (ie OffsetOptions.SWING_DISPLAY,OffsetOptions.PRINTING)
- Specified by:
setUserOffsets
in interfaceorg.jpedal.PdfDecoderInt
-
getUserOffsets
public Point getUserOffsets(int mode)
not part of API used internally- Parameters:
mode
- mode- Returns:
- Points
-
getMaximumSize
public Dimension getMaximumSize()
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 (ie a PDF size 800 * 600 with a scaling factor of 2 will return 1600 *1200)- Overrides:
getMaximumSize
in classJComponent
-
getMinimumSize
public final Dimension getMinimumSize()
get width of panel- Overrides:
getMinimumSize
in classJComponent
-
getPreferredSize
public Dimension getPreferredSize()
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 (ie a PDF size 800 * 600 with a scaling factor of 2 will return 1600 *1200)- Overrides:
getPreferredSize
in classJComponent
- Returns:
- Dimension
-
updateCursorBoxOnScreen
public final void updateCursorBoxOnScreen(int[] rectParams, int outlineColor)
update rectangle we draw to highlight an area - See Viewer example for example code showing current usage. This method takes an int array containing the x,y,w,h params of the rectangle we wish to update. It also takes an int outLineColor which is the rgb value of a Color object.- Specified by:
updateCursorBoxOnScreen
in interfaceorg.jpedal.PdfDecoderInt
-
paint
public void paint(Graphics g)
- Overrides:
paint
in classJComponent
-
paintComponent
public void paintComponent(Graphics g)
standard method to draw page and any highlights onto JPanel
-
getPDFWidth
public 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 interfaceorg.jpedal.PdfDecoderInt
-
getPDFHeight
public final int getPDFHeight()
get sizes of panel - This is the PDF pagesize- Specified by:
getPDFHeight
in interfaceorg.jpedal.PdfDecoderInt
-
setPDFBorder
public final void setPDFBorder(Border newBorder)
set border for screen and print which will be displayed
Setting a new value will enable screen and border painting - disable with disableBorderForPrinting()- Specified by:
setPDFBorder
in interfaceorg.jpedal.PdfDecoderInt
-
getPDFBorder
public final Border getPDFBorder()
get border for screen and print which will be displayeds- Returns:
- Border
-
setHardwareAccelerationforScreen
public void setHardwareAccelerationforScreen(boolean useAcceleration)
Enables/Disables hardware acceleration of screen rendering (default is on)- Specified by:
setHardwareAccelerationforScreen
in interfaceorg.jpedal.PdfDecoderInt
-
getScrollInterval
public int getScrollInterval()
return amount to scroll window by when scrolling (default is 10)- Specified by:
getScrollInterval
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int
-
setScrollInterval
public void setScrollInterval(int scrollInterval)
set amount to scroll window by when scrolling- Specified by:
setScrollInterval
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
scrollInterval
- scroll interval
-
getDisplayView
public int getDisplayView()
returns view mode used - ie SINGLE_PAGE,CONTINUOUS,FACING,CONTINUOUS_FACING (no effect in OS versions)- Specified by:
getDisplayView
in interfaceorg.jpedal.PdfDecoderInt
-
setPrintPageScalingMode
public void setPrintPageScalingMode(int pageScalingMode)
set page scaling mode to use - default setting is PAGE_SCALING_REDUCE_TO_PRINTER_MARGINS All values start PAGE_SCALING- Parameters:
pageScalingMode
- mode to set
-
setUsePDFPaperSize
public void setUsePDFPaperSize(boolean usePDFPaperSize)
-
getScaling
public float getScaling()
returns current scaling value used internally- Specified by:
getScaling
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- float
-
getInsetH
public int getInsetH()
Description copied from interface:org.jpedal.PdfDecoderInt
Return amount to inset the page rectangle height by- Specified by:
getInsetH
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int
-
getInsetW
public int getInsetW()
Description copied from interface:org.jpedal.PdfDecoderInt
Return amount to inset the page rectangle width by- Specified by:
getInsetW
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int
-
getNumberOfPages
public int getNumberOfPages()
part of pageable interface - used only in printing Use getPageCount() for number of pages- Specified by:
getNumberOfPages
in interfacePageable
-
getPageFormat
public PageFormat getPageFormat(int p) throws IndexOutOfBoundsException
part of pageable interface- Specified by:
getPageFormat
in interfacePageable
- Throws:
IndexOutOfBoundsException
-
getUserSetPageFormat
public PageFormat getUserSetPageFormat(int p) throws IndexOutOfBoundsException
Returns pageFormats set by the user for a given page or a standard page format for all pages if set.- Parameters:
p
- :: Page to check for a page format- Returns:
- PageFormat that has been set or null is no value has been sets
- Throws:
IndexOutOfBoundsException
- incorrect index
-
setCenterOnScaling
public void setCenterOnScaling(boolean center)
Specify if the pdf page should be centered within the pageformat when print.- Parameters:
center
- :: If true the pdf page will be centered in the imageable area.
-
setPrintAutoRotate
public void setPrintAutoRotate(boolean rotate)
Specify if the pdf page should be rotated to best fit the printed page imagable area.- Parameters:
rotate
- :: If true the pdf page will be rotated to better fit the imageable area.
-
setPageFormat
public void setPageFormat(int p, PageFormat pf)
Set PageFormat for a specific page when printing. If no pageFormat is set a default will be used. Recommended to use setPageFormat(PageFormat pf) to set a single PageFormat for all pages.- Parameters:
p
- int value representing the page number to apply the PageFormat topf
- PageFormat object to be used when printing the specified page
-
setPageFormat
public void setPageFormat(PageFormat pf)
Set PageFormat to be used when a specific PageFormat has not been set for a page.- Parameters:
pf
- PageFormat object to be used when printing
-
setPagePrintRange
public void setPagePrintRange(SetOfIntegerSyntax range) throws PdfException
set inclusive range to print (see SilentPrint.java and Viewer.java for sample print code (invalid range will throw PdfException) can take values such as new PageRanges("3,5,7-9,15");- Parameters:
range
- range of pages to print- Throws:
PdfException
- PdfException
-
setPrintPageMode
public void setPrintPageMode(int mode)
allow user to select only odd or even pages to print- Parameters:
mode
- mode to use for printing
-
stopPrinting
public final void stopPrinting()
ask JPedal to stop printing a page
-
getCurrentPrintPage
public int getCurrentPrintPage()
return page currently being printed or -1 if finished- Returns:
- int
-
resetCurrentPrintPage
public void resetCurrentPrintPage()
-
getSpecialMode
public int getSpecialMode()
retusn a value defined in SpecialOptions used internally and in custom JPedal releases- Specified by:
getSpecialMode
in interfaceorg.jpedal.PdfDecoderInt
- Returns:
- int
-
useNewGraphicsMode
public boolean useNewGraphicsMode()
- Specified by:
useNewGraphicsMode
in interfaceorg.jpedal.PdfDecoderInt
-
useNewGraphicsMode
public void useNewGraphicsMode(boolean isEnabled)
switches on or off glow border in JPedal viewer- Specified by:
useNewGraphicsMode
in interfaceorg.jpedal.PdfDecoderInt
- Parameters:
isEnabled
-
-
getMaxSizeWH
public int[] getMaxSizeWH()
- Specified by:
getMaxSizeWH
in interfaceorg.jpedal.PdfDecoderInt
-
getPaneBounds
public int[] getPaneBounds()
- Specified by:
getPaneBounds
in interfaceorg.jpedal.PdfDecoderInt
-
repaintPane
public void repaintPane(int page)
- Specified by:
repaintPane
in interfaceorg.jpedal.PdfDecoderInt
-
requestFocus
public void requestFocus()
- Specified by:
requestFocus
in interfaceorg.jpedal.PdfDecoderInt
- Overrides:
requestFocus
in classJComponent
-
getTextPrint
public int getTextPrint()
- Specified by:
getTextPrint
in interfaceorg.jpedal.PdfDecoderInt
-
getViewerPreferences
public org.jpedal.objects.raw.PdfObject getViewerPreferences()
- Specified by:
getViewerPreferences
in interfaceorg.jpedal.PdfDecoderInt
-
-