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

📄 pdfpage.java

📁 Java生成PDF Java生成PDF Java生成PDF
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public static final int BARCODE39CHECKSUM=1;    /**     * Barcode type for <code>drawBarCode</code> representing an     * "Interleaved 2 of 5" barcode. The interleaved 2 of 5 barcode     * is only suitable for numbers, and requires an even number of     * digits (a leading "0" will be automatically added if required).     */    public static final int BARCODE25=2;    /**     * Barcode type for <code>drawBarCode</code> representing an "Interleaved 2 of 5" barcode,     * with checksum. The interleaved 2 of 5 barcode is only suitable for numbers and requires     * an even number of digits including the checksum digit - a leading "0" will be     * automatically added if required. The checksum digit is added at the end, and is the     * value of the equation <tt>(10 - ((s[0]*3 + s[1] + s[2]*3 + s[3] <i><small>and so on,     * multiplying every second digit by 3</small></i>) % 10)) % 10 </tt>     */    public static final int BARCODE25CHECKSUM=3;    /**     * Barcode type for <code>drawBarCode</code> representing the "Extended Code 39" barcode.     * This barcode can display all the characters in the U+0000 to U+007F range (i.e. US ASCII)     * by re-encoding those characters into two character pairs and then using the normal     * Code 39 barcode. The re-encoding algorithm is described on     * <a target=_new href="http://www.barcodeman.com/info/c39_ext.php3">this page</a>.     */    public static final int BARCODE39X=4;    /**     * Barcode type for <code>drawBarCode</code> representing the "Extended Code 39" barcode,     * with checksum. This barcode can display all the characters in the U+0000 to U+007F     * range (i.e. US ASCII), by re-encoding those characters into two character pairs and then     * using the normal Code 39 barcode. The re-encoding algorithm is described on     * <a target=_new href="http://www.barcodeman.com/info/c39_ext.php3">this page</a>.     */    public static final int BARCODE39XCHECKSUM=5;    /**     * Barcode type for <code>drawBarCode</code> representing the "Code 128" barcode.     * The Code 128 barcode can display digits, upper and lower-case letters and most     * punctuation characters from the U+0020 - U+007E (US-ASCII) range. A checksum is     * automatically included as part of the barcode. The appropriate varient     * (CodeB or CodeC) is chosen automatically depending on the code that is printed.     * EAN128 barcodes can also be printed by using a newline (<tt>\n</tt>) to represent     * the FNC1 control character (this feature was added in version 1.1.23)     */    public static final int BARCODE128=6;    /**     * Barcode type for <code>drawBarCode</code> representing the EAN-13 barcode. An EAN-13     * code represents a 13 digit number - broadly speaking, the first 7 digits the     * country and manufacturer code, the next 5 digits the product code, and the final     * digit the checksum. The 12 digit UPC-A barcodes as used in the USA are just EAN-13     * codes with a leading zero. Most EAN-13 bar codes are an inch wide, so the recommended     * <tt>width</tt>, as passed into the <code>drawBarCode</code> method, is 0.75.     * @since 1.1.14     */    public static final int BARCODEEAN13=7;    /**     * Barcode type for <code>drawBarCode</code> representing the UPC-A barcode. Although     * the Uniform Code Council in the US has declared that all UPC-A readers be able to     * read EAN-13 codes by 2005, some clients may still prefer to use the older format     * 12 digit UPC-A codes. Barcodes using this code type must be 11 digits long, or 12     * digits if the check digit is pre-calculated. As with EAN-13, the recommended     * <tt>width</tt> is 0.75     * @since 1.2     */    public static final int BARCODEUPCA=9;    /**     * Barcode type for <code>drawBarCode</code> representing the "Codabar" barcode. A Codabar     * code can contain the digits 0 to 9, plus the characters +, /, $, -, : and the decimal     * point (.).  Additionally it must begin and end with a "stop letter", which may be one     * of A, B, C or D.     * @since 1.1.14     */    public static final int BARCODECODABAR=8;    PDFPage(org.faceless.pdf2.PDFPage page)    {	this.page = page;	state=new State();	statestack = new Stack();	setCanvas(0,0,page.getWidth(), page.getHeight(), POINTS, PAGEBOTTOM|PAGELEFT);    }    Object getPeer()    {        return page;    }    /**     * Return the width of the page in points. This returns the width of the     * visible page (as defined by the CropBox) as opposed to the width of     * the physical page. For 99% of documents this is the same value.     */    public float getWidth()    {	return page.getWidth();    }    /**     * Return the height of the page in points. This returns the height of the     * visible page (as defined by the CropBox) as opposed to the height of     * the physical page. For 99% of documents this is the same value.     */    public float getHeight()    {	return page.getHeight();    }    /**     * Get which page this is in the PDF document - the first page is number 1.     * @since 1.1     */    public int getPageNumber()    {	return page.getPageNumber();    }    /**     * Set the current "canvas", or drawing area. When a new page is     * created, the canvas defaults to the entire page, measured in points     * from the bottom-left hand corner of the page. The canvas can be reset     * as many times as necessary.     *     * @param left the left edge of the canvas, in points     * @param bottom the bottom edge of the canvas, in points     * @param width the width of the canvas, in points     * @param height the height of the canvas, in points     * @param scale the units to measure it in. Can be {@link #POINTS} (the default),     * {@link #INCHES}, {@link #CM}, {@link #MM}, {@link #PICAS} or {@link #PERCENT}     * @param zerocorner which corner of the page is nearest to (0,0). A logical-or     * of {@link #PAGETOP}, {@link #PAGELEFT}, {@link #PAGERIGHT} and {@link #PAGEBOTTOM}     *     */    public void setCanvas(float left, float bottom, float width, float height, int scale, int zerocorner)    {	float newscale=page.UNITS_POINTS;	int neworigin=0;	translatex=left;	translatey=bottom;	if (scale==POINTS)	scalex=scaley=page.UNITS_POINTS;	else if (scale==INCHES) scalex=scaley=page.UNITS_INCHES;	else if (scale==CM)	scalex=scaley=page.UNITS_CM;	else if (scale==MM)	scalex=scaley=page.UNITS_MM;	else if (scale==PICAS)	scalex=scaley=page.UNITS_PICAS;	else if (scale==PERCENT) {	    scaley=height/100;	    scalex=width/100;	}	if ((zerocorner&PAGETOP)==PAGETOP)	{ scaley=-scaley; translatey+=height; }	if ((zerocorner&PAGERIGHT)==PAGERIGHT)	{ scalex=-scalex; translatex+=width; }	canvaswidth=width;	canvasheight=height;    }    private final float cx(float x) 	 { return (translatex+x*scalex)*state.scalex + state.translatex; }    private final float cy(float y) 	 { return (translatey+y*scaley)*state.scaley + state.translatey; }    private final float canvasx(float x) { return translatex + x*scalex; }    private final float canvasy(float y) { return translatey + y*scaley; }    /**     * Get the height of the current canvas in points.     */    public float getCanvasHeight()    {	return canvasheight;    }    /**     * Get the width of the current canvas in points.     */    public float getCanvasWidth()    {	return canvaswidth;    }    /**     * Set the current style.     */    public void setStyle(PDFStyle style)    {	page.setStyle(style.style);	this.tempstyle=style;    }    /**     * Return a copy of the the currently applied Style. Any changes to the     * returned style won't take effect unless it's applied by calling     * <code>setStyle</code>     */    public PDFStyle getStyle()    {	return (PDFStyle)PeeredObject.getPeer(page.getStyle());    }    /**     * Draw a line from x1,y1 to x2,y2 in the current styles <code>LineColor</code>.     * <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 x1 the X co-ordinate of the start of the line     * @param y1 the Y co-ordinate of the start of the line     * @param x2 the X co-ordinate of the end of the line     * @param y2 the Y co-ordinate of the end of the line     * @throws IllegalStateException if the current style has no LineColor specified, or if the call is nested between a call to <tt>beginText</tt> and <tt>endText</tt>     */    public void drawLine(float x1, float y1, float x2, float y2)    {	page.drawLine(cx(x1),cy(y1),cx(x2),cy(y2));    }    /**     * <p>     * Draw a rectangle through the two corners (x1,y1) and     * (x2,y2). Whether the rectangle is drawn as an outline     * or filled depends on the <code>LineColor</code> and     * <code>FillColor</code> of the current style (see the     * {@link #pathPaint} method for more information).     * </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 x1 the X co-ordinate of the first corner of the rectangle     * @param y1 the Y co-ordinate of the first corner of the rectangle     * @param x2 the X co-ordinate of the second corner of the rectangle     * @param y2 the Y co-ordinate of the second corner of the rectangle     * @throws IllegalStateException if the call is nested between a call to <tt>beginText</tt> and <tt>endText</tt>     */    public void drawRectangle(float x1, float y1, float x2, float y2)    {	page.drawRectangle(cx(x1),cy(y1),cx(x2),cy(y2));    }    /**     * <p>     * Draw a rectangle between the two corners (x1,y1) and     * (x2,y2). The corners of the rectangle are rounded, the     * radius of the corner arcs is specified by the parameter     * <code>r</code>.     * </p>     * <p>     * Whether the rectangle is drawn as an outline or filled depends     * the current style (see the {@link #pathPaint} method for more     * information).     * </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 x1 the X co-ordinate of the first corner of the rectangle     * @param y1 the Y co-ordinate of the first corner of the rectangle     * @param x2 the X co-ordinate of the second corner of the rectangle     * @param y2 the Y co-ordinate of the second corner of the rectangle     * @param r The radius of the circle used to round the corners. A value     * of zero produces an identical result to <code>drawRectangle</code>.     * @throws IllegalStateException if the call is nested between a call to <tt>beginText</tt> and <tt>endText</tt>     * @since 1.1     */    public void drawRoundedRectangle(float x1, float y1, float x2, float y2, float r)    {	page.drawRoundedRectangle(cx(x1),cy(y1),cx(x2),cy(y2),r);    }    /**     * <p>     * Draw a polygon. The X and Y co-ordinates of the vertices are     * in the supplied arrays. Whether the polygon is drawn as an     * outline or filled depends on the <code>LineColor</code> and     * <code>FillColor</code> of the current style (see the     * {@link #pathPaint} method for more information).     * </p>     * <p>     * (The resulting shape isn't a true polygon, in that it doesn't     * have to be closed, but we felt that <code>drawPolygon</code>     * was catchier than <code>drawSequenceOfLineSegments</code>.)     * </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-ordinates of the vertices     * @param y the Y co-ordinates of the vertices     * @throws IllegalStateException if the call is nested between a call to <tt>beginText</tt> and <tt>endText</tt>     */    public void drawPolygon(float[] x, float[] y)    {	float[] x2 = new float[x.length];	float[] y2 = new float[y.length];	for (int i=0;i<x.length;i++) x2[i]=cx(x[i]);	for (int i=0;i<y.length;i++) y2[i]=cy(y[i]);		page.drawPolygon(x2, y2);    }    /**     * <p>     * Draw an ellipse inside the specified rectangle. To     * draw a circle centered on 300,200 with a radius of     * 50, the invocation would be     * <code>drawEllipse(250,150,350,250)</code>. (<i>since     * 1.1 this is a contrived example - it's easier to call     * <code>drawCircle</code>)</i>     * </p>     * <p>     * Whether the ellipse is drawn as an outline or filled depends on the     * <code>LineColor</code> and <code>FillColor</code> of the current style     * (see the {@link #pathPaint} method for more information).     * </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.

⌨️ 快捷键说明

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