⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdfpage.java

📁 Java生成PDF Java生成PDF Java生成PDF
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * a new clipping area without reference to the current one. However,     * as the current clipping area is part of the graphics state, it     * can and should be nested inside calls to {@link #save} and     * {@link #restore} to limit its effect.     * </p>     * <p>Calls to this method can't be made between calls to <tt>beginText</tt> and <tt>endText</tt>, as this violates the PDF specification. Since 1.1.6 An <tt>IllegalStateException</tt> will be thrown.     * @param x the X co-ordinate of the center of the circle     * @param y the Y co-ordinate of the center of the circle     * @param r the radius of the circle     * @since 1.1.5     * @throws IllegalStateException if the call is nested between a call to <tt>beginText</tt> and <tt>endText</tt>     */    public void clipCircle(float x, float y, float r)    {	page.clipCircle(cx(x),cy(y),r);    }    /**     * <p>     * Save the state of this page. This takes a snapshot of the     * currently applied style, position, clipping area and any     * rotation/translation/scaling that has been applied, which can     * be later restored with a call to {@link #restore} or undone     * with a call to {@link #undo}.     * </p><p>     * Calls to <code>save</code> can be nested, but note that for     * most PDF viewers it is an error to save the page state but     * not restore it. The <tt>save()</tt> method now saves the     * entire state of the style.     * </p><p>     * Since version 1.1, additional restrictions have been placed     * on the <code>save</code> and <code>restore</code> methods.     * <li>They can only be nested 28 deep</li>     * <li>They cannot be called betweem a <code>pathMove</code>     * and a <code>pathPaint</code> or <code>pathCancel</code> call, or     * between <code>beginText</code> and <code>endText</code>. This     * is because in PDF (unlike its parent PostScript), save does <i>not</i>     * save path information.</li>     * This ties in more accurately with the PDF specification.     * </p>     *     * @throws IllegalStateException if a save is performed between a     * call to <code>beginText</code> and <code>endText</code>, if there     * is an open path, or if saves are nested more than 12 deep.     */    public void save()    {	page.save();	statestack.push(state);    }    /**     * <p>     * Restore the state saved with the last call to {@link #save}.     * </p>     * @throws IllegalStateException if the state wasn't previously saved     */    public void restore()    {	page.restore();	state = (State)statestack.pop();    }    /**     * <p>     * Undo the page to the state at the last call to <code>save()</code>     * </p>     * @throws IllegalStateException if the state wasn't previously saved     * </p>     * @since 1.1     */    public void undo()    {	throw new UnsupportedOperationException("The undo() method has been removed in version 2 with no replacement. You'll need to rewrite your code or stick with version 1");    }    /**     * <p>     * Rotate the page. All future actions, like drawing lines or text,     * will be rotated around the specified point by the specified degrees.     * </p>     * @param x the X co-ordinate to rotate the page around     * @param y the Y co-ordinate to rotate the page around     * @param ang The number of degrees clockwise to rotate the page.     */    public void rotate(float x, float y, double ang)    {	page.rotate(cx(x),cy(y), ang);    }    /**     * <p>     * Translate the page by the specified amount.     * All future actions, like drawing lines or text,     * will be offset by the specified amount.     * </p>     * @param x the distance to translate the page in the X axis     * @param y the distance to translate the page in the Y axis     */    public void translate(float x, float y)    {	state.translatex += x*state.scalex;	state.translatey += y*state.scaley;    }    /**     * <p>     * Scale the page by the specified amount.     * All future actions, like drawing lines or text,     * will be scaled in both directions by the specified amounts.     * </p>     * @param x the scaling factor to apply in the X axis, with 1.0 being no change     * @param y the scaling factor to apply in the Y axis, with 1.0 being no change     */    public void scale(float x, float y)    {	if (x*y==0) throw new IllegalArgumentException("X or Y is zero");	state.scalex *= x;	state.scaley *= y;    }    /**     * <p>     * Set the action to perform when this page is displayed. This     * method is conceptually similar to the method with the same name in     * the {@link PDF} object, except that whereas that is run once when the     * document is opened, this is run each time the page is displayed.     * </p>     * @param action the action to run each time this page is displayed, or     * <code>null</code> to clear the action     * @since 1.1     */    public void setOpenAction(PDFAction action)    {	page.setAction(org.faceless.pdf2.Event.OPEN, action==null ? null : action.action);    }    /**     * <p>     * Set the action to perform when this page is closed. The opposite     * of the <code>setOpenAction</code> method, this action will be     * run each time the page is closed, either by closing the document     * or by moving to another page.     * </p>     * @param action the action to run each time this page is closed, or     * <code>null</code> to clear the action     * @since 1.1     */    public void setCloseAction(PDFAction action)    {	page.setAction(org.faceless.pdf2.Event.CLOSE, action==null ? null : action.action);    }    /**     * <p>     * Get the action that's perform when this page is displayed. This is     * the value set by the {@link #setOpenAction} method.     * @return the action performed whenever this page is displayed, or <tt>null</tt>     * if no action is performed.     * @since 1.1.12     */    public PDFAction getOpenAction()    {	return (PDFAction)PeeredObject.getPeer(page.getAction(org.faceless.pdf2.Event.OPEN));    }    /**     * <p>     * Get the action that's perform when this page is displayed. This is     * the value set by the {@link #setOpenAction} method.     * @return the action performed whenever this page is displayed, or <tt>null</tt>     * if no action is performed.     * @since 1.1.12     */    public PDFAction getCloseAction()    {	return (PDFAction)PeeredObject.getPeer(page.getAction(org.faceless.pdf2.Event.CLOSE));    }    /**     * <p>     * Set the filter to be applied to this page. The default filter is set to     * {@link #FILTER_FLATE}, but it can be set to {@link #FILTER_NONE}     * to simplify debugging.     * </p>     * @param filter the filter to be applied to the page {@link PDFStream}     */    public void setFilter(int filter)    {    	// NOOP    }    /**     * <p>     * Add an annotation to the page.     * </p>     * @see PDFAnnotation     * @since 1.1     */    public void addAnnotation(PDFAnnotation annotation)    {	page.getAnnotations().add(annotation.annot);    }    /**     * Remove the specified annotation from the page. If     * the annotation is not on this page, this method     * has no effect     * @since 1.1.23     */    public void removeAnnotation(PDFAnnotation annotation)    {	page.getAnnotations().remove(annotation.annot);    }    /**     * Return a list of all the annotations on this page. If no     * annotations exist, this returns a list of zero length.     * @return the list of annotations on this page     * @since 1.1.12     */    public PDFAnnotation[] getAnnotations()    {	List l = page.getAnnotations();	PDFAnnotation[] z = new PDFAnnotation[l.size()];	for (int i=0;i<z.length;i++) {	    z[i]=(PDFAnnotation)PeeredObject.getPeer(l.get(i));	}	return z;    }    /**     * <p>     * Seek to the start of the page. Any items drawn after this call     * will be drawn before any content already existing on the page, so     * appearing under the current content.     * </p><p>     * This method will throw an <tt>IllegalStateException</tt> if called     * while a path is open or between calls to <tt>beginText</tt> and     * <tt>endText</tt>.     * </p>     * <p>     * Note that if the document clears the page before writing, it will     * overwrite any content written after a <tt>seetkStart</tt>     * </p>     * @since 1.1.12     */    public void seekStart()    {	page.seekStart();    }    /**     * <p>     * Seek to the end of the page. Any items drawn after this call     * will be drawn after any content already existing on the page, so     * appearing above the current content. This is the default.     * </p><p>     * This method will throw an <tt>IllegalStateException</tt> if called     * while a path is open or between calls to <tt>beginText</tt> and     * <tt>endText</tt>.     * </p>     * @since 1.1.12     */    public void seekEnd()    {	page.seekEnd();    }    /**     * <p>     * Draw a <code>PDFImage</code> on the page at the specified location. The     * aspect-ratio of the image is dependent on the with and height of the     * rectangle given here, <i>not</i> the width and height of the original     * image. To avoid distorting the aspect ratio, the method can be called     * like so:     * <pre>drawImage(img, 100, 100, 100+img.getWidth(), 100+img.getHeight());</pre>     * </p>     *     * @param image The image to draw     * @param x1 the X co-ordinate of the first corner of the image     * @param y1 the Y co-ordinate of the first corner of the image     * @param x2 the X co-ordinate of the second corner of the image     * @param y2 the Y co-ordinate of the second corner of the image     *     */    public void drawImage(PDFImage image, float x1, float y1, float x2, float y2)    {	page.drawImage(image.image,cx(x1),cy(y1),cx(x2),cy(y2));    }    /**     * <p>     * Change the text in the supplied string to use the "correct" quote characters - i.e.     * for English change "test" to ``test'', for German change it to ,,test`` and so on.     * </p>     * <p>     * Exactly what substitution takes place depends on the current locale of the PDF     * document. We've taken the definition of "correct" from the Unicode standard,     * version 3.0 (in the event that either they or (more likely) us have got it wrong,     * please let us know). The current implementation has rules for English, Dutch,     * Italian, Spanish, Catalan, German, Portugese, Turkish, Polish, Hungarian, Swedish,     * Finnish, Norwegian, Danish, Czech and Slovak. Languages using guillemets for     * quotes (French, Greek, Russian and Slovenian) are not covered, as it's expected that     * the guillemet characters will be used in place of the normal single (') and double     * (") quote characters.     * </p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -