?? pdfdocument.java
字號:
else if ((preferences & PdfWriter.PageModeUseThumbs) != 0) put(PdfName.PAGEMODE, PdfName.USETHUMBS); else if ((preferences & PdfWriter.PageModeFullScreen) != 0) put(PdfName.PAGEMODE, PdfName.FULLSCREEN); if ((preferences & PdfWriter.ViewerPreferencesMask) == 0) return; PdfDictionary vp = new PdfDictionary(); if ((preferences & PdfWriter.HideToolbar) != 0) vp.put(PdfName.HIDETOOLBAR, PdfBoolean.PDFTRUE); if ((preferences & PdfWriter.HideMenubar) != 0) vp.put(PdfName.HIDEMENUBAR, PdfBoolean.PDFTRUE); if ((preferences & PdfWriter.HideWindowUI) != 0) vp.put(PdfName.HIDEWINDOWUI, PdfBoolean.PDFTRUE); if ((preferences & PdfWriter.FitWindow) != 0) vp.put(PdfName.FITWINDOW, PdfBoolean.PDFTRUE); if ((preferences & PdfWriter.CenterWindow) != 0) vp.put(PdfName.CENTERWINDOW, PdfBoolean.PDFTRUE); if ((preferences & PdfWriter.NonFullScreenPageModeUseNone) != 0) vp.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USENONE); else if ((preferences & PdfWriter.NonFullScreenPageModeUseOutlines) != 0) vp.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USEOUTLINES); else if ((preferences & PdfWriter.NonFullScreenPageModeUseThumbs) != 0) vp.put(PdfName.NONFULLSCREENPAGEMODE, PdfName.USETHUMBS); if ((preferences & PdfWriter.DirectionL2R) != 0) vp.put(PdfName.DIRECTION, PdfName.L2R); else if ((preferences & PdfWriter.DirectionR2L) != 0) vp.put(PdfName.DIRECTION, PdfName.R2L); put(PdfName.VIEWERPREFERENCES, vp); } void setOpenAction(PdfAction action) { put(PdfName.OPENACTION, action); } /** Sets the document level additional actions. * @param actions dictionary of actions */ void setAdditionalActions(PdfDictionary actions) { try { put(PdfName.AA, writer.addToBody(actions).getIndirectReference()); } catch (Exception e) { new ExceptionConverter(e); } } void setPageLabels(PdfPageLabels pageLabels) { put(PdfName.PAGELABELS, pageLabels.getDictionary()); } void setAcroForm(PdfObject fields) { put(PdfName.ACROFORM, fields); } } // membervariables /** The characters to be applied the hanging ponctuation. */ static final String hangingPunctuation = ".,;:'"; /** The <CODE>PdfWriter</CODE>. */ private PdfWriter writer; /** some meta information about the Document. */ private PdfInfo info = new PdfInfo(); /** Signals that OnOpenDocument should be called. */ private boolean firstPageEvent = true; /** Signals that onParagraph is valid. */ private boolean isParagraph = true; // Horizontal line /** The line that is currently being written. */ private PdfLine line = null; /** This represents the current indentation of the PDF Elements on the left side. */ private float indentLeft = 0; /** This represents the current indentation of the PDF Elements on the right side. */ private float indentRight = 0; /** This represents the current indentation of the PDF Elements on the left side. */ private float listIndentLeft = 0; /** This represents the current alignment of the PDF Elements. */ private int alignment = Element.ALIGN_LEFT; // Vertical lines /** This is the PdfContentByte object, containing the text. */ private PdfContentByte text; /** This is the PdfContentByte object, containing the borders and other Graphics. */ private PdfContentByte graphics; /** The lines that are written until now. */ private ArrayList lines = new ArrayList(); /** This represents the leading of the lines. */ private float leading = 0; /** This is the current height of the document. */ private float currentHeight = 0; /** This represents the current indentation of the PDF Elements on the top side. */ private float indentTop = 0; /** This represents the current indentation of the PDF Elements on the bottom side. */ private float indentBottom = 0; /** This checks if the page is empty. */ private boolean pageEmpty = true; private int textEmptySize; // resources /** This is the size of the next page. */ protected Rectangle nextPageSize = null; /** This is the size of the crop box of the current Page. */ protected Rectangle thisCropSize = null; /** This is the size of the crop box that will be used in * the next page. */ protected Rectangle cropSize = null; /** This is the FontDictionary of the current Page. */ protected PdfFontDictionary fontDictionary; /** This is the XObjectDictionary of the current Page. */ protected PdfXObjectDictionary xObjectDictionary; /** This is the ColorSpaceDictionary of the current Page. */ protected PdfColorDictionary colorDictionary; /** This is the PatternDictionary of the current Page. */ protected PdfPatternDictionary patternDictionary; /** This is the ShadingDictionary of the current Page. */ protected PdfShadingDictionary shadingDictionary; // images /** This is the list with all the images in the document. */ private HashMap images = new HashMap(); /** This is the image that could not be shown on a previous page. */ private Image imageWait = null; /** This is the position where the image ends. */ private float imageEnd = -1; /** This is the indentation caused by an image on the left. */ private float imageIndentLeft = 0; /** This is the indentation caused by an image on the right. */ private float imageIndentRight = 0; // annotations and outlines /** This is the array containing the references to the annotations. */ private ArrayList annotations; /** This is an array containg references to some delayed annotations. */ private ArrayList delayedAnnotations = new ArrayList(); /** This is the AcroForm object. */ PdfAcroForm acroForm; /** This is the root outline of the document. */ private PdfOutline rootOutline;; /** This is the current <CODE>PdfOutline</CODE> in the hierarchy of outlines. */ private PdfOutline currentOutline; /** The current active <CODE>PdfAction</CODE> when processing an <CODE>Anchor</CODE>. */ private PdfAction currentAction = null; /** * Stores the destinations keyed by name. Value is * <CODE>Object[]{PdfAction,PdfIndirectReference,PdfDestintion}</CODE>. */ private TreeMap localDestinations = new TreeMap(new StringCompare()); private ArrayList documentJavaScript = new ArrayList(); /** these are the viewerpreferences of the document */ private int viewerPreferences = 0; private String openActionName; private PdfAction openActionAction; private PdfDictionary additionalActions; private PdfPageLabels pageLabels; //add by Jin-Hsia Yang private boolean isNewpage = false; private boolean isParagraphE = false; private float paraIndent = 0; //end add by Jin-Hsia Yang /** margin in x direction starting from the left. Will be valid in the next page */ protected float nextMarginLeft; /** margin in x direction starting from the right. Will be valid in the next page */ protected float nextMarginRight; /** margin in y direction starting from the top. Will be valid in the next page */ protected float nextMarginTop; /** margin in y direction starting from the bottom. Will be valid in the next page */ protected float nextMarginBottom; /** The duration of the page */ protected int duration=-1; // negative values will indicate no duration /** The page transition */ protected PdfTransition transition=null; protected PdfDictionary pageAA = null; // constructors /** * Constructs a new PDF document. * @throws DocumentException on error */ public PdfDocument() throws DocumentException { super(); addProducer(); addCreationDate(); } // listener methods /** * Adds a <CODE>PdfWriter</CODE> to the <CODE>PdfDocument</CODE>. * * @param writer the <CODE>PdfWriter</CODE> that writes everything * what is added to this document to an outputstream. * @throws DocumentException on error */ public void addWriter(PdfWriter writer) throws DocumentException { if (this.writer == null) { this.writer = writer; acroForm = new PdfAcroForm(writer); return; } throw new DocumentException("You can only add a writer to a PdfDocument once."); } /** * Sets the pagesize. * * @param pageSize the new pagesize * @return <CODE>true</CODE> if the page size was set */ public boolean setPageSize(Rectangle pageSize) { if (writer != null && writer.isPaused()) { return false; } nextPageSize = new Rectangle(pageSize); return true; } /** * Changes the header of this document. * * @param header the new header */ public void setHeader(HeaderFooter header) { if (writer != null && writer.isPaused()) { return; } super.setHeader(header); } /** * Resets the header of this document. */ public void resetHeader() { if (writer != null && writer.isPaused()) { return; } super.resetHeader(); } /** * Changes the footer of this document. * * @param footer the new footer */ public void setFooter(HeaderFooter footer) { if (writer != null && writer.isPaused()) { return; } super.setFooter(footer); } /** * Resets the footer of this document. */ public void resetFooter() { if (writer != null && writer.isPaused()) { return; } super.resetFooter(); } /** * Sets the page number to 0.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -