diff --git a/src/libs/pdflib/bind/pdflib/Makefile b/src/libs/pdflib/bind/pdflib/Makefile new file mode 100644 index 0000000000..dec2b9d893 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/Makefile @@ -0,0 +1,11 @@ +# PDFlib bindings Makefile +# $Id: Makefile,v 1.1 2004/10/06 17:16:51 laplace Exp $ + +include ../../config/mkcommon.inc + +SUB_DIRS = $(BINDINGS) + +include ../../config/mksubdirs.inc + +distclean:: + -$(RM) php/Makefile.in diff --git a/src/libs/pdflib/bind/pdflib/java/Java.dsp b/src/libs/pdflib/bind/pdflib/java/Java.dsp new file mode 100644 index 0000000000..0a19b8d10e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/Java.dsp @@ -0,0 +1,76 @@ +# Microsoft Developer Studio Project File - Name="Java" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Java - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Java.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Java.mak" CFG="Java - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Java - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Java___Win32_Release" +# PROP BASE Intermediate_Dir "Java___Win32_Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MT /W3 /O2 /I "c:\jdk1.3\include" /I "c:\jdk1.3\include\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"pdf_java.dll" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /base:"0x55320000" /dll /pdb:none /machine:I386 /out:"pdf_java.dll" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /map /debug +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Creating jar file and documentation... +PostBuild_Cmds=c:\jdk1.3\bin\javac PDFlibException.java pdflib.java rmdir /s /q com mkdir com\pdflib copy pdflib.class com\pdflib copy PDFlibException.class com\pdflib c:\jdk1.3\bin\jar cvf pdflib.jar com/pdflib/PDFlibException.class com/pdflib/pdflib.class rmdir /s /q javadoc mkdir javadoc c:\jdk1.3\bin\javadoc -notree -author -version -d javadoc -public pdflib.java +# End Special Build Tool +# Begin Target + +# Name "Java - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib_java.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/java/Makefile b/src/libs/pdflib/bind/pdflib/java/Makefile new file mode 100644 index 0000000000..dc45406e15 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/Makefile @@ -0,0 +1,89 @@ +# Makefile for PDFlib's Java binding +# $Id: Makefile,v 1.1 2004/10/06 17:16:51 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc +PDFPEDANTIC = + +LIBS = $(PDFLIBLINK) +INCLUDES = $(PDFLIBINC) $(JAVAINCLUDE) + +LANG_LIBDIR = $(libdir) + +LIBNAME = libpdf_java$(LA) +OBJ = pdflib_java$(LO) +SRC = pdflib_java.c + +TESTPROGS = \ + hello.class \ + image.class \ + pdfclock.class \ + chartab.class \ + invoice.class \ + businesscard.class \ + quickreference.class + +include $(top_builddir)/config/mkbind.inc + +.SUFFIXES: .java .class + +.java.class: + -CLASSPATH=$$CLASSPATH:pdflib.jar:. javac $< + + +all:: pdflib.jar + +pdflib.jar:: pdflib.java PDFlibException.java + $(RM) com + mkdir -p com/pdflib + javac PDFlibException.java pdflib.java && mv pdflib.class com/pdflib\ + && mv PDFlibException.class com/pdflib/PDFlibException.class + jar cvf pdflib.jar com/pdflib/pdflib.class \ + com/pdflib/PDFlibException.class + $(RM) com + +javadoc:: + $(RM) javadoc + mkdir javadoc + -javadoc -notree -author -version -d javadoc -public \ + pdflib.java PDFlibException.java + +test:: $(LIBNAME) pdflib.jar $(TESTPROGS) + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java hello + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java image + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java pdfclock + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java chartab + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java invoice + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java businesscard + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java quickreference + +smoke:: test smoketest.class + -CLASSPATH=$$CLASSPATH:pdflib.jar:. $(LIBTOOL_EXE) java smoketest + +install:: $(LIBNAME) pdflib.jar + @-if test -f .libs/libpdf_java.jnilib; then \ + $(LIBTOOL) --mode=install $(INSTALL_DATA) \ + .libs/libpdf_java.jnilib $(LANG_LIBDIR); \ + else \ + $(LIBTOOL) --mode=install $(INSTALL_DATA) \ + $(LIBNAME) $(LANG_LIBDIR); \ + fi + @echo Copy pdflib.jar and javadoc to an appropriate directory, + @echo and include pdflib.jar in your CLASSPATH. + +uninstall:: + @-if test -f .libs/libpdf_java.jnilib; then \ + $(LIBTOOL) --mode=uninstall $(RM) \ + $(LANG_LIBDIR)/libpdf_java.jnilib; \ + else \ + $(LIBTOOL) --mode=uninstall $(RM) \ + $(LANG_LIBDIR)/$(LIBNAME); \ + fi + +clean:: + $(RM) *.class com pdflib.jar javadoc smoke_c_?.pdf + $(RM) hello.pdf image.pdf pdfclock.pdf chartab.pdf invoice.pdf + $(RM) businesscard.pdf quickreference.pdf + +# Automatically generated dependencies diff --git a/src/libs/pdflib/bind/pdflib/java/PDFlibException.java b/src/libs/pdflib/bind/pdflib/java/PDFlibException.java new file mode 100644 index 0000000000..b6b060164a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/PDFlibException.java @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: PDFlibException.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlibException Java class + */ + +package com.pdflib; + +/** PDFlib - A library for generating PDF on the fly + + Exception handling for PDFlib. + @author Rainer Schaaf + @version 5.0.3 +*/ + +public class PDFlibException extends Exception { + public PDFlibException() { + super(); + } + + public PDFlibException(String msg) { + super(msg); + } + + public PDFlibException(String msg, int errnum, String apiname) { + super(msg); + pdf_errnum = errnum; + pdf_apiname = apiname; + } + + /** Map standard getMessage method to get_errmsg. */ + public String get_errmsg() { + return super.getMessage(); + } + + /** Get the error number of the exception. */ + public int get_errnum() { + return pdf_errnum; + } + + /** Get the name of the API function which caused the exception. */ + public String get_apiname() { + return pdf_apiname; + } + + private int pdf_errnum; + private String pdf_apiname; +} diff --git a/src/libs/pdflib/bind/pdflib/java/businesscard.java b/src/libs/pdflib/bind/pdflib/java/businesscard.java new file mode 100644 index 0000000000..7c66ef99f8 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/businesscard.java @@ -0,0 +1,90 @@ +/* $Id: businesscard.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: hello example in Java + */ + +import java.io.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class businesscard +{ + public static void main (String argv[]) + { + int font; + pdflib p = null ; + int i, blockcontainer, page; + String infile = "boilerplate.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary. + * + * Note that this directory must also contain the LuciduxSans font + * outline and metrics files. + */ + String searchpath = "../data"; + String[][] data = { + { "name", "Victor Kraxi" }, + { "business.title", "Chief Paper Officer" }, + { "business.address.line1", "17, Aviation Road" }, + { "business.address.city", "Paperfield" }, + { "business.telephone.voice","phone +1 234 567-89" }, + { "business.telephone.fax", "fax +1 234 567-98" }, + { "business.email", "victor@kraxi.com" }, + { "business.homepage", "www.kraxi.com" }, + }; + + try{ + p = new pdflib(); + + // open new PDF file + if (p.open_file("businesscard.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "businesscard.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title","PDFlib block processing sample (Java)"); + + blockcontainer = p.open_pdi(infile, "", 0); + if (blockcontainer == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + page = p.open_pdi_page(blockcontainer, 1, ""); + if (page == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.begin_page(20, 20); // dummy page size + + // This will adjust the page size to the block container's size. + p.fit_pdi_page(page, 0, 0, "adjustpage"); + + // Fill all text blocks with dynamic data + for (i = 0; i < (int) data.length; i++) { + if (p.fill_textblock(page, data[i][0], data[i][1], + "embedding encoding=winansi") == -1) { + System.err.println("Warning: " + p.get_errmsg()); + } + } + + p.end_page(); // close page + p.close_pdi_page(page); + + p.close(); // close PDF document + p.close_pdi(blockcontainer); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in businesscard sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/chartab.java b/src/libs/pdflib/bind/pdflib/java/chartab.java new file mode 100644 index 0000000000..9f0dc25fcd --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/chartab.java @@ -0,0 +1,124 @@ +/* $Id: chartab.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: character table + */ + +import java.io.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class chartab +{ + /* change these as required */ + static final String fontname = "LuciduxSans-Oblique"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + static final String searchpath = "../data"; + + /* list of encodings to use */ + static final String encodings[] = { "iso8859-1", "iso8859-2", "iso8859-15" }; + static final int ENCODINGS = 3; + static final float FONTSIZE = 16; + static final float TOP = 700; + static final float LEFT = 50; + static final float YINCR = 2*FONTSIZE; + static final float XINCR = 2*FONTSIZE; + + public static void main (String argv[]) + { + + /* whether or not to embed the font */ + int embed = 1; + + String buf; + float x, y; + int row, col, font, page; + + pdflib p = null ; + + try{ + p = new pdflib(); + + /* open new PDF file */ + if (p.open_file("chartab.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("openaction", "fitpage"); + p.set_parameter("fontwarning", "true"); + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "chartab.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Character table (Java)"); + + /* loop over all encodings */ + for (page = 0; page < ENCODINGS; page++) + { + p.begin_page(595, 842); /* start a new page */ + + /* print the heading and generate the bookmark */ + font = p.load_font("Helvetica", "winansi", ""); + p.setfont(font, FONTSIZE); + if (embed == 1) { + buf = fontname + " (" + encodings[page] + ") embedded"; + } else{ + buf = fontname + " (" + encodings[page] + ") not embedded"; + } + + p.show_xy(buf, LEFT - XINCR, TOP + 3 * YINCR); + p.add_bookmark(buf, 0, 0); + + /* print the row and column captions */ + p.setfont(font, 2 * FONTSIZE/3); + + for (row = 0; row < 16; row++) + { + buf ="x" + (Integer.toHexString(row)).toUpperCase(); + p.show_xy(buf, LEFT + row*XINCR, TOP + YINCR); + + buf = (Integer.toHexString(row)).toUpperCase() + "x"; + p.show_xy(buf, LEFT - XINCR, TOP - row * YINCR); + } + + /* print the character table */ + if (embed == 1) { + buf = "embedding"; + } else{ + buf = ""; + } + font = p.load_font(fontname, encodings[page],buf); + p.setfont(font, FONTSIZE); + + y = TOP; + x = LEFT; + + for (row = 0; row < 16; row++) + { + for (col = 0; col < 16; col++) { + buf = String.valueOf((char)(16*row + col)); + p.show_xy(buf, x, y); + x += XINCR; + } + x = LEFT; + y -= YINCR; + } + + p.end_page(); /* close page */ + } + p.close(); /* close PDF document */ + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in chartab sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/hello.java b/src/libs/pdflib/bind/pdflib/java/hello.java new file mode 100644 index 0000000000..a082752c58 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/hello.java @@ -0,0 +1,54 @@ +/* $Id: hello.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: hello example in Java + */ + +import java.io.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class hello +{ + public static void main (String argv[]) + { + int font; + pdflib p = null; + + try{ + p = new pdflib(); + + /* open new PDF file */ + if (p.open_file("hello.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_info("Creator", "hello.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Hello world (Java)!"); + + p.begin_page(595, 842); /* start a new page */ + + font = p.load_font("Helvetica-Bold", "winansi", ""); + + p.setfont(font, 18); + + p.set_text_pos(50, 700); + p.show("Hello world!"); + p.continue_text("(says Java)"); + p.end_page(); /* close page */ + + p.close(); /* close PDF document */ + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in hello sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/image.java b/src/libs/pdflib/bind/pdflib/java/image.java new file mode 100644 index 0000000000..21cec32cc6 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/image.java @@ -0,0 +1,61 @@ +/* $Id: image.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: image example in Java + */ + +import java.io.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class image +{ + public static void main (String argv[]) + { + int image; + float width, height; + pdflib p = null; + String imagefile = "nesrin.jpg"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + + try{ + + p = new pdflib(); + /* open new PDF file */ + if (p.open_file("image.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "image.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "image sample (Java)"); + + image = p.load_image("auto", imagefile, ""); + + if (image == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + /* dummy page size, will be adjusted by PDF_fit_image() */ + p.begin_page(10, 10); + p.fit_image(image, (float) 0.0, (float) 0.0, "adjustpage"); + p.close_image(image); + p.end_page(); /* close page */ + + p.close(); /* close PDF document */ + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in hello sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/invoice.java b/src/libs/pdflib/bind/pdflib/java/invoice.java new file mode 100644 index 0000000000..d38b79e7ef --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/invoice.java @@ -0,0 +1,169 @@ +/* $Id: invoice.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: invoice example in Java + */ + +import java.io.*; +import java.text.*; // DateFormat +import java.util.*; // Date +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class invoice +{ + public static void main (String argv[]) + { + pdflib p = null ; + int i, form, page, regularfont, boldfont; + String infile = "stationery.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + final float col1 = 55; + final float col2 = 100; + final float col3 = 330; + final float col4 = 430; + final float col5 = 530; + float fontsize = 12, leading, y; + float sum, total; + float pagewidth = 595, pageheight = 842; + Date now = new Date(); + DateFormat fulldate = DateFormat.getDateInstance(DateFormat.LONG); + + String closingtext = + "30 days warranty starting at the day of sale. " + + "This warranty covers defects in workmanship only. " + + "Kraxi Systems, Inc. will, at its option, repair or replace the " + + "product under the warranty. This warranty is not transferable. " + + "No returns or exchanges will be accepted for wet products."; + + String[][] data = { + { "Super Kite", "20", "2"}, + { "Turbo Flyer", "40", "5"}, + { "Giga Trash", "180", "1"}, + { "Bare Bone Kit", "50", "3"}, + { "Nitty Gritty", "20", "10"}, + { "Pretty Dark Flyer", "75", "1"}, + { "Free Gift", "0", "1"}, + }; + + String[] months = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + + try{ + p = new pdflib(); + + // open new PDF file + if (p.open_file("invoice.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "invoice.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "PDFlib invoice generation demo (Java)"); + + form = p.open_pdi(infile, "", 0); + if (form == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + page = p.open_pdi_page(form, 1, ""); + if (page == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + boldfont = p.load_font("Helvetica-Bold", "winansi", ""); + regularfont = p.load_font("Helvetica", "winansi", ""); + leading = fontsize + 2; + + // Establish coordinates with the origin in the upper left corner. + p.set_parameter("topdown", "true"); + + p.begin_page(pagewidth, pageheight); // A4 page + + p.fit_pdi_page(page, 0, pageheight, ""); + p.close_pdi_page(page); + + p.setfont(regularfont, fontsize); + + // Print the address + y = 170; + p.set_value("leading", leading); + + p.show_xy("John Q. Doe", col1, y); + p.continue_text("255 Customer Lane"); + p.continue_text("Suite B"); + p.continue_text("12345 User Town"); + p.continue_text("Everland"); + + // Print the header and date + + p.setfont(boldfont, fontsize); + y = 300; + p.show_xy("INVOICE", col1, y); + + p.fit_textline(fulldate.format(now), col5, y, "position {100 0}"); + + // Print the invoice header line + p.setfont(boldfont, fontsize); + + // "position {0 0}" is left-aligned, "position {100 0}" right-aligned + y = 370; + p.fit_textline("ITEM", col1, y, "position {0 0}"); + p.fit_textline("DESCRIPTION", col2, y, "position {0 0}"); + p.fit_textline("QUANTITY", col3, y, "position {100 0}"); + p.fit_textline("PRICE", col4, y, "position {100 0}"); + p.fit_textline("AMOUNT", col5, y, "position {100 0}"); + + // Print the article list + + p.setfont(regularfont, fontsize); + y += 2*leading; + total = 0; + + for (i = 0; i < data.length; i++) { + p.show_xy(Integer.toString(i+1), col1, y); + p.show_xy(data[i][0], col2, y); + p.fit_textline(data[i][2], col3, y, "position {100 0}"); + p.fit_textline(data[i][1], col4, y, "position {100 0}"); + sum = 0; + + sum = Integer.parseInt(data[i][2]) * Integer.parseInt(data[i][1]); + p.fit_textline(Float.toString(sum), col5, y, "position {100 0}"); + + y += leading; + total += sum; + } + + y += leading; + p.setfont(boldfont, fontsize); + p.fit_textline(Float.toString(total), col5, y, "position {100 0}"); + + // Print the closing text + + y += 5*leading; + p.setfont(regularfont, fontsize); + p.set_value("leading", leading); + p.show_boxed(closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", ""); + + p.end_page(); + p.close(); + p.close_pdi(form); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in invoice sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/pdfclock.java b/src/libs/pdflib/bind/pdflib/java/pdfclock.java new file mode 100644 index 0000000000..76d4e7f040 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/pdfclock.java @@ -0,0 +1,121 @@ +/* $Id: pdfclock.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib client: pdfclock example in Java + */ + +import java.io.*; +import java.text.*; // SimpleDateFormat +import java.util.*; // Date +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class pdfclock +{ + public static void main (String argv[]) + { + pdflib p = null; + int tm_hour, tm_min, tm_sec, alpha; + float RADIUS = 200.0f; + float MARGIN = 20.0f; + SimpleDateFormat format; + Date now = new Date(); + + try{ + p = new pdflib(); + /* open new PDF file */ + if (p.open_file("pdfclock.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_info("Creator", "pdfclock.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "PDF clock (Java)"); + + p.begin_page( (int) (2 * (RADIUS + MARGIN)), + (int) (2 * (RADIUS + MARGIN))); + + p.translate(RADIUS + MARGIN, RADIUS + MARGIN); + p.setcolor("fillstroke", "rgb", 0.0f, 0.0f, 1.0f, 0.0f); + p.save(); + + // minute strokes + p.setlinewidth(2.0f); + for (alpha = 0; alpha < 360; alpha += 6) + { + p.rotate(6.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN/3, 0.0f); + p.stroke(); + } + + p.restore(); + p.save(); + + // 5 minute strokes + p.setlinewidth(3.0f); + for (alpha = 0; alpha < 360; alpha += 30) + { + p.rotate(30.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN, 0.0f); + p.stroke(); + } + + format = new SimpleDateFormat("hh"); + tm_hour= Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("mm"); + tm_min = Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("ss"); + tm_sec = Integer.parseInt(format.format(now)); + + // draw hour hand + p.save(); + p.rotate((-((tm_min/60.0f) + tm_hour - 3.0f) * 30.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS/2, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw minute hand + p.save(); + p.rotate((-((tm_sec/60.0f) + tm_min - 15.0f) * 6.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS * 0.8f, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw second hand + p.setcolor("fillstroke", "rgb", 1.0f, 0.0f, 0.0f, 0.0f); + p.setlinewidth(2); + p.save(); + p.rotate(-((tm_sec - 15.0f) * 6.0f)); + p.moveto(-RADIUS/5, 0.0f); + p.lineto(RADIUS, 0.0f); + p.stroke(); + p.restore(); + + // draw little circle at center + p.circle(0f, 0f, RADIUS/30); + p.fill(); + + p.restore(); + p.end_page(); + p.close(); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in pdfclock sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/pdflib.java b/src/libs/pdflib/bind/pdflib/java/pdflib.java new file mode 100644 index 0000000000..43bad11eb4 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/pdflib.java @@ -0,0 +1,1589 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib.java,v 1.1 2004/10/06 17:16:51 laplace Exp $ + * + * PDFlib Java class + */ + +package com.pdflib; + +import java.io.*; + +/** PDFlib -- a library for generating PDF on the fly. + + Note that this is only a syntax summary. It covers several products: + PDFlib Lite, PDFlib, PDFlib+PDI, and PDFlib Personalization Server (PPS). + Not all features are available in all products, although dummies for + all missing API functions are provided. A comparison which + details function availability in different products is available at + http://www.pdflib.com. + + For complete information please refer to the PDFlib API reference + manual which is available in the PDF file PDFlib-manual.pdf in the + PDFlib distribution. + + @author Thomas Merz + @version 5.0.3 +*/ + +public final class pdflib { + + // The initialization code for loading the PDFlib shared library. + // The library name will be transformed into something platform- + // specific by the VM, e.g. libpdf_java.so or pdf_java.dll. + + static { + try { + System.loadLibrary("pdf_java"); + } catch (UnsatisfiedLinkError e) { + System.err.println( + "Cannot load the PDFlib shared library/DLL for Java.\n" + + "Make sure to properly install the native PDFlib library.\n\n" + + "For your information, the current value of java.library.path is:\n" + + System.getProperty("java.library.path") + "\n"); + + throw e; + } + PDF_boot(); + } + + // ------------------------------------------------------------------------ + // public functions + + /* p_annots.c: */ + + /** Add a launch annotation (to a target of arbitrary file type). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_launchlink( + float llx, float lly, float urx, float ury, String filename) + throws PDFlibException + { + PDF_add_launchlink(p, llx, lly, urx, ury, filename); + } + + /** Add a link annotation to a target within the current PDF file. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_locallink( + float llx, float lly, float urx, float ury, int page, String optlist) + throws PDFlibException + { + PDF_add_locallink(p, llx, lly, urx, ury, page, optlist); + } + + /** Add a note annotation. icon is one of of "comment", "insert", "note", + "paragraph", "newparagraph", "key", or "help". + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_note( + float llx, float lly, float urx, float ury, + String contents, String title, String icon, int open) + throws PDFlibException + { + PDF_add_note(p, llx, lly, urx, ury, contents, title, icon, open); + } + + /** Add a file link annotation (to a PDF target). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_pdflink( + float llx, float lly, float urx, float ury, + String filename, int page, String optlist) + throws PDFlibException + { + PDF_add_pdflink(p, llx, lly, urx, ury, filename, page, optlist); + } + + /** Add a weblink annotation to a target URL on the Web. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_weblink( + float llx, float lly, float urx, float ury, String url) + throws PDFlibException + { + PDF_add_weblink(p, llx, lly, urx, ury, url); + } + + /** Add a file attachment annotation. icon is one of "graph", "paperclip", + "pushpin", or "tag". + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void attach_file( + float llx, float lly, float urx, float ury, String filename, + String description, String author, String mimetype, String icon) + throws PDFlibException + { + PDF_attach_file(p, llx, lly, urx, ury, filename, + description, author, mimetype, icon); + } + + /** Set the border color for all kinds of annotations. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_border_color(float red, float green, float blue) + throws PDFlibException + { + PDF_set_border_color(p, red, green, blue); + } + + /** Set the border dash style for all kinds of annotations. + See PDF_setdash(). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_border_dash(float b, float w) + throws PDFlibException + { + PDF_set_border_dash(p, b, w); + } + + /** Set the border style for all kinds of annotations. style is "solid" or + "dashed". + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_border_style(String style, float width) + throws PDFlibException + { + PDF_set_border_style(p, style, width); + } + + /* p_basic.c */ + + /** Add a new page to the document. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void begin_page(float width, float height) + throws PDFlibException + { + PDF_begin_page(p, width, height); + } + + /** Close the generated PDF file, and release all document-related + resources. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void close() + throws PDFlibException + { + PDF_close(p); + } + + /** Delete the PDFlib object, and free all internal resources. + Never throws any PDFlib exception. + */ + public final void delete() + { + PDF_delete(p); + p = (long) 0; + } + + /** Finish the page. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void end_page() + throws PDFlibException + { + PDF_end_page(p); + } + + /** Get the name of the API function which failed. + @return PDFlib API function name + */ + public final String get_apiname() + throws PDFlibException + { + return PDF_get_apiname(p); + } + + /** Get the contents of the PDF output buffer. The result must be used by + the client before calling any other PDFlib function. + @return A byte array containing the PDF output generated so far. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final byte[] get_buffer() + throws PDFlibException + { + return PDF_get_buffer(p); + } + + /** Get the descriptive text of a failed function call. + @return PDFlib error message + */ + public final String get_errmsg() + throws PDFlibException + { + return PDF_get_errmsg(p); + } + + /** Get the the reason code of a failed function call. + @return PDFlib error number + */ + public final int get_errnum() + throws PDFlibException + { + return PDF_get_errnum(p); + } + + /** Create a new PDFlib object. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public pdflib() + throws PDFlibException + { + p = PDF_new(); + } + + /** Create a new PDF file using the supplied file name. + @return -1 on error, 1 on success. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_file(String filename) + throws PDFlibException + { + return PDF_open_file(p, filename); + } + + /* p_block.c */ + + /** Process an image block according to its properties. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int fill_imageblock( + int page, String blockname, int image, String optlist) + throws PDFlibException + { + return PDF_fill_imageblock(p, page, blockname, image, optlist); + } + + /** Process a PDF block according to its properties. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int fill_pdfblock( + int page, String blockname, int contents, String optlist) + throws PDFlibException + { + return PDF_fill_pdfblock(p, page, blockname, contents, optlist); + } + + /** Process a text block according to its properties. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int fill_textblock( + int page, String blockname, String text, String optlist) + throws PDFlibException + { + return PDF_fill_textblock(p, page, blockname, text, optlist); + } + + /* p_color.c */ + + /** Make a named spot color from the current color. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int makespotcolor(String spotname) + throws PDFlibException + { + return PDF_makespotcolor(p, spotname); + } + + /** Set the current color space and color. + fstype is "fill", "stroke", or "fillstroke". + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setcolor( + String fstype, String colorspace, float c1, float c2, float c3, float c4) + throws PDFlibException + { + PDF_setcolor(p, fstype, colorspace, c1, c2, c3, c4); + } + + /** Set the current fill and stroke color. + @deprecated Use setcolor("fillstroke", "gray", g, 0, 0, 0) instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setgray(float g) + throws PDFlibException + { + PDF_setcolor(p, "fillstroke", "gray", g, 0, 0, 0); + } + + /** Set the current fill color to a gray value between 0 and 1 inclusive. + @deprecated Use setcolor("fill", "gray", g, 0, 0, 0) instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setgray_fill(float g) + throws PDFlibException + { + PDF_setcolor(p, "fill", "gray", g, 0, 0, 0); + } + + /** Set the current fill color to the supplied RGB values. + @deprecated Use setcolor("fill", "rgb", red, green, blue, 0) instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setrgbcolor_fill(float red, float green, float blue) + throws PDFlibException + { + PDF_setcolor(p, "fill", "rgb", red, green, blue, 0); + } + + /** Set the current fill and stroke color to the supplied RGB values. + @deprecated Use setcolor("fillstroke", "rgb", red, green, blue, 0) + instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setrgbcolor(float red, float green, float blue) + throws PDFlibException + { + PDF_setcolor(p, "fillstroke", "rgb", red, green, blue, 0); + } + + /** Set the current stroke color to the supplied RGB values. + @deprecated Use setcolor("stroke", "rgb", red, green, blue, 0) instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setrgbcolor_stroke(float red, float green, float blue) + throws PDFlibException + { + PDF_setcolor(p, "stroke", "rgb", red, green, blue, 0); + } + + /** Set the current stroke color to a gray value between 0 and 1 + inclusive. + @deprecated Use setcolor("stroke", "gray", g, 0, 0, 0) instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setgray_stroke(float g) + throws PDFlibException + { + PDF_setcolor(p, "stroke", "gray", g, 0, 0, 0); + } + + /* p_draw.c */ + + /** Draw a circular arc with center (x, y) and radius r from alpha to beta. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void arc(float x, float y, float r, float alpha, float beta) + throws PDFlibException + { + PDF_arc(p, x, y, r, alpha, beta); + } + + /** Draw a clockwise circular arc from alpha to beta degrees. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void arcn(float x, float y, float r, float alpha, float beta) + throws PDFlibException + { + PDF_arcn(p, x, y, r, alpha, beta); + } + + /** Draw a circle with center (x, y) and radius r. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void circle(float x, float y, float r) + throws PDFlibException + { + PDF_circle(p, x, y, r); + } + + /** Use the current path as clipping path. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void clip() + throws PDFlibException + { + PDF_clip(p); + } + + /** Close the current path. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void closepath() + throws PDFlibException + { + PDF_closepath(p); + } + + /** Close the path, fill, and stroke it. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void closepath_fill_stroke() + throws PDFlibException + { + PDF_closepath_fill_stroke(p); + } + + /** Close the path, and stroke it. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void closepath_stroke() + throws PDFlibException + { + PDF_closepath_stroke(p); + } + + /** Draw a Bezier curve from the current point, using 3 more control + points. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void curveto( + float x1, float y1, float x2, float y2, float x3, float y3) + throws PDFlibException + { + PDF_curveto(p, x1, y1, x2, y2, x3, y3); + } + + /** End the current path without filling or stroking it. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void endpath() + throws PDFlibException + { + PDF_endpath(p); + } + + /** Fill the interior of the path with the current fill color. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void fill() + throws PDFlibException + { + PDF_fill(p); + } + + /** Fill and stroke the path with the current fill and stroke color. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void fill_stroke() + throws PDFlibException + { + PDF_fill_stroke(p); + } + + /** Draw a line from the current point to (x, y). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void lineto(float x, float y) + throws PDFlibException + { + PDF_lineto(p, x, y); + } + + /** Set the current point to (x, y). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void moveto(float x, float y) + throws PDFlibException + { + PDF_moveto(p, x, y); + } + + /** Draw a rectangle at lower left (x, y) with width and height. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void rect(float x, float y, float width, float height) + throws PDFlibException + { + PDF_rect(p, x, y, width, height); + } + + /** Stroke the path with the current color and line width,and clear it. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void stroke() + throws PDFlibException + { + PDF_stroke(p); + } + + /* p_encoding.c */ + + /** Add a glyph name to a custom encoding. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void encoding_set_char( + String encoding, int slot, String glyphname, int uv) + throws PDFlibException + { + PDF_encoding_set_char(p, encoding, slot, glyphname, uv); + } + + /* p_font.c */ + + /** Search a font, and prepare it for later use. PDF_load_font() is + recommended. + @return A valid font handle. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int findfont(String fontname, String encoding, int options) + throws PDFlibException + { + return PDF_findfont(p, fontname, encoding, options); + } + + /** Search a font, and prepare it for later use. + @return A valid font handle. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int load_font(String fontname, String encoding, String optlist) + throws PDFlibException + { + return PDF_load_font(p, fontname, encoding, optlist); + } + + /** Set the current font in the given size, + using a font handle returned by PDF_load_font(). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setfont(int font, float fontsize) + throws PDFlibException + { + PDF_setfont(p, font, fontsize); + } + + /* p_gstate.c */ + + /** Concatenate a matrix to the current transformation matrix. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void concat( + float a, float b, float c, float d, float e, float f) + throws PDFlibException + { + PDF_concat(p, a, b, c, d, e, f); + } + + /** Reset all implicit color and graphics state parameters to their + defaults. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void initgraphics() + throws PDFlibException + { + PDF_initgraphics(p); + } + + /** Restore the most recently saved graphics state. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void restore() + throws PDFlibException + { + PDF_restore(p); + } + + /** Rotate the coordinate system by phi degrees. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void rotate(float phi) + throws PDFlibException + { + PDF_rotate(p, phi); + } + + /** Save the current graphics state. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void save() + throws PDFlibException + { + PDF_save(p); + } + + /** Scale the coordinate system by (sx, sy). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void scale(float sx, float sy) + throws PDFlibException + { + PDF_scale(p, sx, sy); + } + + /** Set the current dash pattern to b black and w white units. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setdash(float b, float w) + throws PDFlibException + { + PDF_setdash(p, b, w); + } + + /** Set a more complicated dash pattern defined by an optlist. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setdashpattern(String optlist) + throws PDFlibException + { + PDF_setdashpattern(p, optlist); + } + + /** Set the flatness to a value between 0 and 100 inclusive. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setflat(float flatness) + throws PDFlibException + { + PDF_setflat(p, flatness); + } + + /** Set the linecap parameter to a value between 0 and 2 inclusive. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setlinecap(int linecap) + throws PDFlibException + { + PDF_setlinecap(p, linecap); + } + + /** Set the line join parameter to a value between 0 and 2 inclusive. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setlinejoin(int linejoin) + throws PDFlibException + { + PDF_setlinejoin(p, linejoin); + } + + /** Set the current linewidth to width. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setlinewidth(float width) + throws PDFlibException + { + PDF_setlinewidth(p, width); + } + + /** Explicitly set the current transformation matrix. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setmatrix( + float a, float b, float c, float d, float e, float f) + throws PDFlibException + { + PDF_setmatrix(p, a, b, c, d, e, f); + } + + /** Set the miter limit to a value greater than or equal to 1. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setmiterlimit(float miter) + throws PDFlibException + { + PDF_setmiterlimit(p, miter); + } + + /** Set a dash pattern. + @deprecated Use PDF_setdashpattern() instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void setpolydash(float[] dasharray) + throws PDFlibException + { + PDF_setpolydash(p, dasharray); + } + + /** Skew the coordinate system in x and y direction by alpha and beta + degrees. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void skew(float alpha, float beta) + throws PDFlibException + { + PDF_skew(p, alpha, beta); + } + + /** Translate the origin of the coordinate system to (tx, ty). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void translate(float tx, float ty) + throws PDFlibException + { + PDF_translate(p, tx, ty); + } + + /* p_hyper.c */ + + /** Add a nested bookmark under parent, or a new top-level bookmark if + parent = 0. If open = 1, child bookmarks will + be folded out, and invisible if open = 0. + @return A bookmark descriptor which may be used as parent for + subsequent nested bookmarks. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int add_bookmark(String text, int parent, int open) + throws PDFlibException + { + return PDF_add_bookmark(p, text, parent, open); + } + + /** Create a named destination on an arbitrary page in the current + document. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_nameddest(String name, String optlist) + throws PDFlibException + { + PDF_add_nameddest(p, name, optlist); + } + + /** Fill document information field key with value. key is one of "Subject", + "Title", "Creator", "Author", "Keywords", or a user-defined key. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_info(String key, String value) + throws PDFlibException + { + PDF_set_info(p, key, value); + } + + /* p_icc.c */ + + /** Search an ICC profile, and prepare it for later use. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int load_iccprofile(String profilename, String optlist) + throws PDFlibException + { + return PDF_load_iccprofile(p, profilename, optlist); + } + + /* p_image.c */ + + /** Add an existing image as thumbnail for the current page. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void add_thumbnail(int image) + throws PDFlibException + { + PDF_add_thumbnail(p, image); + } + + /** Close an image retrieved with one of the PDF_open_image*() functions. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void close_image(int image) + throws PDFlibException + { + PDF_close_image(p, image); + } + + /** Place an image or template at (x, y) with various options. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void fit_image(int image, float x, float y, String optlist) + throws PDFlibException + { + PDF_fit_image(p, image, x, y, optlist); + } + + /** Open a (disk-based or virtual) image file with various options. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int load_image( + String imagetype, String filename, String optlist) + throws PDFlibException + { + return PDF_load_image(p, imagetype, filename, optlist); + } + + /** Load a CCITT image file. + @deprecated Use PDF_load_image() instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_CCITT( + String filename, int width, int height, int BitReverse, int K, int BlackIs1) + throws PDFlibException + { + return PDF_open_CCITT(p, filename, width, height, BitReverse, K, + BlackIs1); + } + + /** Open an image from memory. + @deprecated Use PDF_load_image() with virtual files instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_image( + String imagetype, String source, byte[] data, long length, int width, + int height, int components, int bpc, String params) + throws PDFlibException + { + return PDF_open_image(p, imagetype, source, data, length, width, + height, components, bpc, params); + } + + /** Open an image from file. + @deprecated Use PDF_load_image() with virtual files instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_image_file( + String imagetype, String filename, String stringparam, int intparam) + throws PDFlibException + { + return PDF_open_image_file(p, imagetype, filename, stringparam, + intparam); + } + + /** Place an image on the page. + @deprecated Use PDF_fit_image() with virtual files instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void place_image(int image, float x, float y, float scale) + throws PDFlibException + { + PDF_place_image(p, image, x, y, scale); + } + + /* p_params.c */ + + /** Get some PDFlib parameters with string type + @return A string containing the requested parameter. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final String get_parameter(String key, float modifier) + throws PDFlibException + { + return PDF_get_parameter(p, key, modifier); + } + + /** Get the value of some PDFlib parameters with float type. + @return The requested parameter value. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final float get_value(String key, float modifier) + throws PDFlibException + { + return PDF_get_value(p, key, modifier); + } + + /** Set some PDFlib parameters with string type. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_parameter(String key, String value) + throws PDFlibException + { + PDF_set_parameter(p, key, value); + } + + /** Set some PDFlib parameters with float type. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_value(String key, float value) + throws PDFlibException + { + PDF_set_value(p, key, value); + } + + /* p_pattern.c */ + + /** Start a new pattern definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int begin_pattern( + float width, float height, float xstep, float ystep, int painttype) + throws PDFlibException + { + return PDF_begin_pattern(p, width, height, xstep, ystep, painttype); + } + + /** Finish a pattern definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void end_pattern() + throws PDFlibException + { + PDF_end_pattern(p); + } + + /* p_pdi.c */ + + /** Close all open page handles, and close the input PDF document. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void close_pdi(int doc) + throws PDFlibException + { + PDF_close_pdi(p, doc); + } + + /** Close the page handle, and free all page-related resources. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void close_pdi_page(int page) + throws PDFlibException + { + PDF_close_pdi_page(p, page); + } + + /** Place an imported PDF page with the lower left corner at (x, y) with + various options. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void fit_pdi_page(int page, float x, float y, String optlist) + throws PDFlibException + { + PDF_fit_pdi_page(p, page, x, y, optlist); + } + + /** Get the contents of some PDI document parameter with string type. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final String get_pdi_parameter( + String key, int doc, int page, int reserved) + throws PDFlibException + { + return PDF_get_pdi_parameter(p, key, doc, page, reserved); + } + + /** Get the contents of some PDI document parameter with numerical type. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final float get_pdi_value( + String key, int doc, int page, int reserved) + throws PDFlibException + { + return PDF_get_pdi_value(p, key, doc, page, reserved); + } + + /** Open an existing PDF document and prepare it for later use. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_pdi(String filename, String optlist, int reserved) + throws PDFlibException + { + return PDF_open_pdi(p, filename, optlist, reserved); + } + + /** Open a (disk-based or virtual) PDF document and prepare it + for later use. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int open_pdi_page(int doc, int pagenumber, String optlist) + throws PDFlibException + { + return PDF_open_pdi_page(p, doc, pagenumber, optlist); + } + + /** Perform various actions on a PDI document. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final float process_pdi(int doc, int page, String optlist) + throws PDFlibException + { + return PDF_process_pdi(p, doc, page, optlist); + } + + /** Place an imported page on the output page. + @deprecated Use PDF_fit_pdi_page() instead. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void place_pdi_page( + int page, float x, float y, float sx, float sy) + throws PDFlibException + { + PDF_place_pdi_page(p, page, x, y, sx, sy); + } + + /* p_resource.c */ + + /** Create a file in the PDFlib virtual file system (PVF). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void create_pvf(String filename, byte[] data, String optlist) + throws PDFlibException + { + PDF_create_pvf(p, filename, data, optlist); + } + + /** Delete a virtual file. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int delete_pvf(String filename) + throws PDFlibException + { + return PDF_delete_pvf(p, filename); + } + + /* p_shading.c */ + + /** Define a color blend (smooth shading) from the current fill color + to the supplied color. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int shading( + String shtype, float x0, float y0, float x1, float y1, + float c1, float c2, float c3, float c4, String optlist) + throws PDFlibException + { + return PDF_shading(p, shtype, x0, y0, x1, y1, c1, c2, c3, c4, optlist); + } + + /** Define a shading pattern using a shading object. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int shading_pattern(int shading, String optlist) + throws PDFlibException + { + return PDF_shading_pattern(p, shading, optlist); + } + + /** Fill an area with a shading, based on a shading object. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void shfill(int shading) + throws PDFlibException + { + PDF_shfill(p, shading); + } + + /* p_template.c */ + + /** Start a new template definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int begin_template(float width, float height) + throws PDFlibException + { + return PDF_begin_template(p, width, height); + } + + /** Finish a template definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void end_template() + throws PDFlibException + { + PDF_end_template(p); + } + + /* p_text.c */ + + /** Print text at the next line. The spacing between lines is determined + by the "leading" parameter. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void continue_text(String text) + throws PDFlibException + { + PDF_continue_text(p, text); + } + + /** Print text in the current font placed and fitted at (x, y). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void fit_textline( + String text, float x, float y, String optlist) + throws PDFlibException + { + PDF_fit_textline(p, text, x, y, optlist); + } + + /** Set the text output position. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_text_pos(float x, float y) + throws PDFlibException + { + PDF_set_text_pos(p, x, y); + } + + /** Print text in the current font and size at the current position. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void show(String text) + throws PDFlibException + { + PDF_show(p, text); + } + + /** Format text in the current font and size into the supplied text box + according to the requested formatting mode, which must be one of + "left", "right", "center", "justify", or "fulljustify". If width + and height are 0, only a single line is placed at the point + (left, top) in the requested mode. + @return Number of characters which didn't fit in the box. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int show_boxed(String text, float left, float bottom, + float width, float height, String hmode, String feature) + throws PDFlibException + { + return PDF_show_boxed(p, text, left, bottom, width, height, + hmode, feature); + } + + /** Print text in the current font at (x, y). + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void show_xy(String text, float x, float y) + throws PDFlibException + { + PDF_show_xy(p, text, x, y); + } + + /** Return the width of text in an arbitrary font. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final float stringwidth(String text, int font, float fontsize) + throws PDFlibException + { + return PDF_stringwidth(p, text, font, fontsize); + } + + /* p_type3.c */ + + /** Start a type3 font definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void begin_font( + String name, float a, float b, float c, float d, float e, float f, + String optlist) + throws PDFlibException + { + PDF_begin_font(p, name, a, b, c, d, e, f, optlist); + } + + /** Start a type 3 glyph definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void begin_glyph( + String glyphname, float wx, float llx, float lly, float urx, float ury) + throws PDFlibException + { + PDF_begin_glyph(p, glyphname, wx, llx, lly, urx, ury); + } + + /** Terminate a type 3 font definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void end_font() + throws PDFlibException + { + PDF_end_font(p); + } + + /** Terminate a type 3 glyph definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void end_glyph() + throws PDFlibException + { + PDF_end_glyph(p); + } + + /* p_xgstate.c */ + + /** Create a gstate object definition. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final int create_gstate(String optlist) + throws PDFlibException + { + return PDF_create_gstate(p, optlist); + } + + /** Activate a gstate object. + @exception com.pdflib.PDFlibException + PDF output cannot be finished after an exception. + */ + public final void set_gstate(int gstate) + throws PDFlibException + { + PDF_set_gstate(p, gstate); + } + + + // ------------------------------------------------------------------------ + // private functions + + private long p; + + protected final void finalize() + throws PDFlibException + { + PDF_delete(p); + p = (long) 0; + } + + private final static void classFinalize() { + PDF_shutdown(); + } + + /* p_annots.c */ + + private final static native void PDF_add_launchlink(long jp, float jarg1, float jarg2, float jarg3, float jarg4, String jarg5) throws PDFlibException; + + private final static native void PDF_add_locallink(long jp, float jarg1, float jarg2, float jarg3, float jarg4, int jarg5, String jarg6) throws PDFlibException; + + private final static native void PDF_add_note(long jp, float jarg1, float jarg2, float jarg3, float jarg4, String jarg5, String jarg6, String jarg7, int jarg8) throws PDFlibException; + + private final static native void PDF_add_pdflink(long jp, float jarg1, float jarg2, float jarg3, float jarg4, String jarg5, int jarg6, String jarg7) throws PDFlibException; + + private final static native void PDF_add_weblink(long jp, float jarg1, float jarg2, float jarg3, float jarg4, String jarg5) throws PDFlibException; + + private final static native void PDF_attach_file(long jp, float jarg1, float jarg2, float jarg3, float jarg4, String jarg5, String jarg6, String jarg7, String jarg8, String jarg9) throws PDFlibException; + + private final static native void PDF_set_border_color(long jp, float jarg1, float jarg2, float jarg3) throws PDFlibException; + + private final static native void PDF_set_border_dash(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_set_border_style(long jp, String jarg1, float jarg2) throws PDFlibException; + + /* p_basic.c */ + + private final static native void PDF_begin_page(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_boot(); + + private final static native void PDF_close(long jp) throws PDFlibException; + + private final static native synchronized void PDF_delete(long jp); + + private final static native void PDF_end_page(long jp) throws PDFlibException; + + private final static native String PDF_get_apiname(long jp) throws PDFlibException; + + private final static native byte[] PDF_get_buffer(long jp) throws PDFlibException; + + private final static native String PDF_get_errmsg(long jp) throws PDFlibException; + + private final static native int PDF_get_errnum(long jp) throws PDFlibException; + + private final static native synchronized long PDF_new() throws PDFlibException; + + private final static native int PDF_open_file(long jp, String jarg1) throws PDFlibException; + + private final static native void PDF_shutdown(); + + + /* p_block.c */ + + private final static native int PDF_fill_imageblock(long jp, int jpage, String jblockname, int jimage, String joptlist) throws PDFlibException; + + private final static native int PDF_fill_pdfblock(long jp, int jpage, String jblockname, int jcontents, String joptlist) throws PDFlibException; + + private final static native int PDF_fill_textblock(long jp, int jpage, String jblockname, String jtext, String joptlist) throws PDFlibException; + + /* p_color.c */ + + private final static native int PDF_makespotcolor(long jp, String jarg1) throws PDFlibException; + + private final static native void PDF_setcolor(long jp, String jarg1, String jarg2, float jarg3, float jarg4, float jarg5, float jarg6) throws PDFlibException; + + /* p_draw.c */ + + private final static native void PDF_arc(long jp, float jarg1, float jarg2, float jarg3, float jarg4, float jarg5) throws PDFlibException; + + private final static native void PDF_arcn(long jp, float jarg1, float jarg2, float jarg3, float jarg4, float jarg5) throws PDFlibException; + + private final static native void PDF_circle(long jp, float jarg1, float jarg2, float jarg3) throws PDFlibException; + + private final static native void PDF_clip(long jp) throws PDFlibException; + + private final static native void PDF_closepath(long jp) throws PDFlibException; + + private final static native void PDF_closepath_fill_stroke(long jp) throws PDFlibException; + + private final static native void PDF_closepath_stroke(long jp) throws PDFlibException; + + private final static native void PDF_curveto(long jp, float jarg1, float jarg2, float jarg3, float jarg4, float jarg5, float jarg6) throws PDFlibException; + + private final static native void PDF_endpath(long jp) throws PDFlibException; + + private final static native void PDF_fill(long jp) throws PDFlibException; + + private final static native void PDF_fill_stroke(long jp) throws PDFlibException; + + private final static native void PDF_lineto(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_moveto(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_rect(long jp, float jarg1, float jarg2, float jarg3, float jarg4) throws PDFlibException; + + private final static native void PDF_stroke(long jp) throws PDFlibException; + + /* p_encoding.c */ + + private final static native void PDF_encoding_set_char(long jp, String jencoding, int jslot, String jglyphname, int juv) throws PDFlibException; + + /* p_font.c */ + + private final static native int PDF_findfont(long jp, String jarg1, String jarg2, int jarg3) throws PDFlibException; + + private final static native int PDF_load_font(long jp, String jfontname, String jencoding, String joptlist) throws PDFlibException; + + private final static native void PDF_setfont(long jp, int jarg1, float jarg2) throws PDFlibException; + + /* p_gstate.c */ + + private final static native void PDF_concat(long jp, float a, float b, float c, float d, float e, float f) throws PDFlibException; + + private final static native void PDF_initgraphics(long jp) throws PDFlibException; + + private final static native void PDF_restore(long jp) throws PDFlibException; + + private final static native void PDF_rotate(long jp, float jarg1) throws PDFlibException; + + private final static native void PDF_save(long jp) throws PDFlibException; + + private final static native void PDF_scale(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_setdash(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_setdashpattern(long jp, String joptlist) throws PDFlibException; + + private final static native void PDF_setflat(long jp, float jarg1) throws PDFlibException; + + private final static native void PDF_setlinecap(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_setlinejoin(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_setlinewidth(long jp, float jarg1) throws PDFlibException; + + private final static native void PDF_setmatrix(long jp, float jarg1, float jarg2, float jarg3, float jarg4, float jarg5, float jarg6) throws PDFlibException; + + private final static native void PDF_setmiterlimit(long jp, float jarg1) throws PDFlibException; + + private final static native void PDF_setpolydash(long jp, float[] jarg1) throws PDFlibException; + + private final static native void PDF_skew(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_translate(long jp, float jarg1, float jarg2) throws PDFlibException; + + /* p_hyper.c */ + + private final static native int PDF_add_bookmark(long jp, String jarg1, int jarg2, int jarg3) throws PDFlibException; + + private final static native void PDF_add_nameddest(long jp, String jname, String joptlist) throws PDFlibException; + + private final static native void PDF_set_info(long jp, String jarg1, String jarg2) throws PDFlibException; + + /* p_icc.c */ + + private final static native int PDF_load_iccprofile(long jp, String jprofilename, String joptlist) throws PDFlibException; + + /* p_image.c */ + + private final static native void PDF_add_thumbnail(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_close_image(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_fit_image(long jp, int jimage, float jx, float jy, String joptlist) throws PDFlibException; + + private final static native int PDF_load_image(long jp, String jimagetype, String jfilename, String joptlist) throws PDFlibException; + + private final static native int PDF_open_CCITT(long jp, String jarg1, int jarg2, int jarg3, int jarg4, int jarg5, int jarg6) throws PDFlibException; + + private final static native int PDF_open_image(long jp, String jarg1, String jarg2, byte[] jarg3, long jarg4, int jarg5, int jarg6, int jarg7, int jarg8, String jarg9) throws PDFlibException; + + private final static native int PDF_open_image_file(long jp, String jarg1, String jarg2, String jarg3, int jarg4) throws PDFlibException; + + private final static native void PDF_place_image(long jp, int jarg1, float jarg2, float jarg3, float jarg4) throws PDFlibException; + + /* p_params.c */ + + private final static native String PDF_get_parameter(long jp, String key, float mod) throws PDFlibException; + + private final static native float PDF_get_value(long jp, String key, float mod) throws PDFlibException; + + private final static native void PDF_set_parameter(long jp, String jarg1, String jarg2) throws PDFlibException; + + private final static native void PDF_set_value(long jp, String jarg1, float jarg2) throws PDFlibException; + + /* p_pattern.c */ + + private final static native int PDF_begin_pattern(long jp, float jarg1, float jarg2, float jarg3, float jarg4, int jarg5) throws PDFlibException; + + private final static native void PDF_end_pattern(long jp) throws PDFlibException; + + /* p_pdi.c */ + + private final static native void PDF_close_pdi(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_close_pdi_page(long jp, int jarg1) throws PDFlibException; + + private final static native void PDF_fit_pdi_page(long jp, int jpage, float jx, float jy, String joptlist) throws PDFlibException; + + private final static native String PDF_get_pdi_parameter(long jp, String jarg2, int jarg3, int jarg4, int jarg5) throws PDFlibException; + + private final static native float PDF_get_pdi_value(long jp, String jarg1, int jarg2, int jarg3, int jarg4) throws PDFlibException; + + private final static native int PDF_open_pdi(long jp, String jarg1, String jarg2, int jarg3) throws PDFlibException; + + private final static native int PDF_open_pdi_page(long jp, int jarg1, int jarg2, String jarg3) throws PDFlibException; + + private final static native void PDF_place_pdi_page(long jp, int jarg1, float jarg2, float jarg3, float jarg4, float jarg5) throws PDFlibException; + + private final static native int PDF_process_pdi(long jp, int jdoc, int jpage, String joptlist) throws PDFlibException; + + /* p_resource.c */ + + private final static native void PDF_create_pvf(long jp, String jfilename, byte[] jdata, String joptlist) throws PDFlibException; + + private final static native int PDF_delete_pvf(long jp, String jfilename) throws PDFlibException; + + /* p_shading.c */ + + private final static native int PDF_shading(long jp, String jshtype, float jx0, float jy0, float jx1, float jy1, float jc1, float jc2, float jc3, float jc4, String joptlist) throws PDFlibException; + + private final static native int PDF_shading_pattern(long jp, int jshading, String joptlist) throws PDFlibException; + + private final static native void PDF_shfill(long jp, int jshading) throws PDFlibException; + + /* p_template.c */ + + private final static native int PDF_begin_template(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_end_template(long jp) throws PDFlibException; + + /* p_text.c */ + + private final static native void PDF_continue_text(long jp, String jarg1) throws PDFlibException; + + private final static native void PDF_fit_textline(long jp, String jtext, float jx, float jy, String joptlist) throws PDFlibException; + + private final static native void PDF_set_text_pos(long jp, float jarg1, float jarg2) throws PDFlibException; + + private final static native void PDF_show(long jp, String jarg1) throws PDFlibException; + + private final static native int PDF_show_boxed(long jp, String jarg1, float jarg2, float jarg3, float jarg4, float jarg5, String jarg6, String jarg7) throws PDFlibException; + + private final static native void PDF_show_xy(long jp, String jarg1, float jarg2, float jarg3) throws PDFlibException; + + private final static native float PDF_stringwidth(long jp, String jarg1, int jarg2, float jarg3) throws PDFlibException; + + /* p_type3.c */ + + private final static native void PDF_begin_font(long jp, String jname, float ja, float jb, float jc, float jd, float je, float jf, String optlist) throws PDFlibException; + + private final static native void PDF_begin_glyph(long jp, String jname, float jwx, float jllx, float jlly, float jurx, float jury) throws PDFlibException; + + private final static native void PDF_end_font(long jp) throws PDFlibException; + + private final static native void PDF_end_glyph(long jp) throws PDFlibException; + + /* p_xgstate.c */ + + private final static native int PDF_create_gstate(long jp, String joptlist) throws PDFlibException; + + private final static native void PDF_set_gstate(long jp, int jhandle) throws PDFlibException; +} diff --git a/src/libs/pdflib/bind/pdflib/java/pdflib_java.c b/src/libs/pdflib/bind/pdflib/java/pdflib_java.c new file mode 100644 index 0000000000..98850ad763 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/pdflib_java.c @@ -0,0 +1,3092 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib_java.c,v 1.1 2004/10/06 17:16:52 laplace Exp $ + * + * synch'd with pdflib.h 1.151.2.22 + * + * JNI wrapper code for the PDFlib Java binding + * + */ + +#include +#include +#include + +#ifdef OS390 +#define IBM_MVS +#define NEEDSIEEE754 +#define NEEDSLONGLONG +#endif + +#include + +#ifdef OS390 +#include +#endif + +#if defined __ILEC400__ && !defined AS400 +#define AS400 +#endif + +#include "pdflib.h" + +/* figure out whether or not we're running on an EBCDIC-based machine */ +#define ASCII_A 0x41 +#define PLATFORM_A 'A' +#define EBCDIC_A 0xC1 + +#if (ASCII_A != PLATFORM_A && EBCDIC_A == PLATFORM_A) +#define PDFLIB_EBCDIC +#endif + +#ifndef OS390 + +#ifndef int2ll +#define int2ll(a) ((jlong) (a)) +#endif + +#ifndef ll2int +#define ll2int(a) ((int) (a)) +#endif + +#ifndef tofloat +#define tofloat(a) ((jfloat) (a)) +#endif + +#ifndef flt2nat +#define flt2nat(a) ((float) (a)) +#endif + +#endif /* OS390 */ + + +#define NULL_INT NULL +#define PDF_ENV jlong +#define PDF_ENV2PTR(env) *((PDF **) &(env)) + + + +/* Compilers which are not strictly ANSI conforming can set PDF_VOLATILE + * to an empty value. + */ +#ifndef PDF_VOLATILE +#define PDF_VOLATILE volatile +#endif + +/* thread-specific data */ +typedef struct { + jint jdkversion; + jmethodID MID_String_getBytes; /* cached method identifier */ +} pdf_wrapper_data; + +/* This is used in the wrapper functions for thread-safe exception handling */ +#define EXC_STUFF pdf_wrapper_data * PDF_VOLATILE ex + +/* Exception handling */ + +#define PDF_ISNULL(j) (j == (PDF_ENV) 0) + + +#define PDF_JAVA_SANITY_CHECK_VOID(j) \ + if (PDF_ISNULL(j)) { \ + jthrow(jenv, "Must not call any PDFlib method after delete()", \ + 0, "pdflib_java.c"); \ + return; \ + } + +#define PDF_JAVA_SANITY_CHECK(j) \ + if (PDF_ISNULL(j)) { \ + jthrow(jenv, "Must not call any PDFlib method after delete()", \ + 0, "pdflib_java.c"); \ + return _jresult; \ + } + +/* {{{ jthrow */ +static void +jthrow(JNIEnv *jenv, const char *msg, int errnum, const char *apiname) +{ + jclass PDFlibException; + jstring jmsg, japiname; + jmethodID cid; + jthrowable e; + char *classstring; + +#ifndef PDFLIB_EBCDIC + classstring = "com/pdflib/PDFlibException"; + jmsg = (*jenv)->NewStringUTF(jenv, msg); + japiname = (*jenv)->NewStringUTF(jenv, apiname); +#endif /* PDFLIB_EBCDIC */ + + PDFlibException = (*jenv)->FindClass(jenv, classstring); + if (PDFlibException == NULL_INT) { + return; /* Exception thrown */ + } + + /* Get method ID for PDFlibException(String, int, String) constructor */ +#ifndef PDFLIB_EBCDIC + cid = (*jenv)->GetMethodID(jenv, PDFlibException, "", + "(Ljava/lang/String;ILjava/lang/String;)V"); +#endif /* PDFLIB_EBCDIC */ + if (cid == NULL_INT) { + return; /* Exception thrown */ + } + + e = (*jenv)->NewObject(jenv, PDFlibException, cid, jmsg, errnum, japiname); + (*jenv)->Throw(jenv, e); +} +/* }}} */ + +#define pdf_catch PDF_CATCH(p) { \ + jthrow(jenv, PDF_get_errmsg(p), PDF_get_errnum(p), \ + PDF_get_apiname(p)); \ + } + +/* {{{ GetStringPDFChars + * Single-byte sequence for file names e.g.: pick only low bytes from Unicode + * and end with null byte. + */ + +static char * +GetStringPDFChars(PDF *p, JNIEnv *jenv, jstring string) +{ + const jchar *unistring; + char *result; + size_t i, len; + + if (!string) + return NULL; + + len = (size_t) (*jenv)->GetStringLength(jenv, string); + + if (len == (size_t) 0) + return NULL; + + unistring = (*jenv)->GetStringChars(jenv, string, NULL); + + if (!unistring) { + pdf_throw(p, "Java", "GetStringPDFChars", + "JNI internal string allocation failed"); + } + + result = (char *) malloc(len + 1); + + if (!result) { + pdf_throw(p, "Java", "GetStringPDFChars", + "JNI internal string allocation failed"); + } + + /* pick the low-order bytes only */ + for (i = 0; i < len; i++) { + if (unistring[i] > 0xFF) { + pdf_throw(p, "Java", "GetStringPDFChars", + "PDFlib supports only Latin-1 character strings"); + } + result[i] = (char) unistring[i]; + } + + result[i] = '\0'; /* NULL-terminate */ + + (*jenv)->ReleaseStringChars(jenv, string, unistring); + + + return result; +} +/* }}} */ + +#define ReleaseStringPDFChars(jenv, string, chars) \ + if (chars) free(chars); + +#define ReleaseStringJavaChars(jenv, string, chars) \ + if (chars) (*jenv)->ReleaseStringChars(jenv, string, (jchar *) chars); + +/* {{{ GetStringUnicodePDFChars + * Unicode strings (page description text or hyper text strings) + */ +static const jchar * +GetStringUnicodePDFChars(PDF *p, JNIEnv *jenv, jstring string, int *lenP) +{ + const jchar *unistring; + size_t len; + + *lenP = 0; + + if (!string) + return NULL; + + len = (size_t) (*jenv)->GetStringLength(jenv, string); + + if (len == (size_t) 0) + return NULL; + + unistring = (*jenv)->GetStringChars(jenv, string, NULL); + + if (!unistring) { + pdf_throw(p, "Java", "GetStringUnicodePDFChars", + "JNI internal string allocation failed"); + } + + *lenP = (int) (2 * len); + + return unistring; +} +/* }}} */ + +/* {{{ GetStringPDFChars + * Converts a C string to a Java string for + */ + +/* The Unicode byte order mark (BOM) byte parts */ +#define PDF_BOM0 0376 /* '\xFE' */ +#define PDF_BOM1 0377 /* '\xFF' */ + +static jstring +GetNewStringUTF(JNIEnv *jenv, char *cstring) +{ + jstring _jresult = 0; + char *_result = cstring; + + + _jresult = (jstring)(*jenv)->NewStringUTF(jenv, _result); + + + return _jresult; +} +/* }}} */ + + +/* export the PDFlib routines to the shared library */ +#ifdef __MWERKS__ +#pragma export on +#endif + +/* p_annots.c */ + +/* {{{ PDF_add_launchlink */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1launchlink(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jstring jfilename) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE filename = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + + PDF_add_launchlink(p, llx, lly, urx, ury, filename); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); +} +/* }}} */ + +/* {{{ PDF_add_locallink */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1locallink(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jint jpage, jstring joptlist) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + int page; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + page = (int )jpage; + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + PDF_add_locallink(p, llx, lly, urx, ury, page, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_add_note */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1note(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jstring jcontents, jstring jtitle, jstring jicon, jint jopen) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE contents = NULL; + char * PDF_VOLATILE title = NULL; + char * PDF_VOLATILE icon = NULL; + int open; + int clen, tlen; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + contents = (char *)GetStringUnicodePDFChars(p, jenv, jcontents, &clen); + title = (char *)GetStringUnicodePDFChars(p, jenv, jtitle, &tlen); + icon = (char *)GetStringPDFChars(p, jenv, jicon); + open = (int )jopen; + + PDF_add_note2(p, llx, lly, urx, ury, contents, clen, title, tlen, + icon, open); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jcontents, contents); + ReleaseStringJavaChars(jenv, jtitle, title); + ReleaseStringPDFChars(jenv, jicon, icon); +} +/* }}} */ + +/* {{{ PDF_add_pdflink */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1pdflink(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jstring jfilename, jint jpage, jstring joptlist) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE filename = NULL; + int page; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + page = (int )jpage; + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + PDF_add_pdflink(p, llx, lly, urx, ury, filename, page, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_add_weblink */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1weblink(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jstring jurl) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + char *PDF_VOLATILE url = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + url = (char *)GetStringPDFChars(p, jenv, jurl); + + PDF_add_weblink(p, llx, lly, urx, ury, url); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jurl, url); +} +/* }}} */ + +/* {{{ PDF_attach_file */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1attach_1file(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jllx, jfloat jlly, jfloat jurx, jfloat jury, + jstring jfilename, jstring jdescription, jstring jauthor, + jstring jmimetype, jstring jicon) +{ + PDF *p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE filename = NULL; + char * PDF_VOLATILE description = NULL; + char * PDF_VOLATILE author = NULL; + char * PDF_VOLATILE mimetype = NULL; + char * PDF_VOLATILE icon = NULL; + int dlen, alen; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + description = + (char *)GetStringUnicodePDFChars(p, jenv, jdescription, &dlen); + author = (char *)GetStringUnicodePDFChars(p, jenv, jauthor, &alen); + mimetype = (char *)GetStringPDFChars(p, jenv, jmimetype); + icon = (char *)GetStringPDFChars(p, jenv, jicon); + + PDF_attach_file2(p, llx, lly, urx, ury, filename, 0, + description, dlen, author, alen, mimetype, icon); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + ReleaseStringJavaChars(jenv, jdescription, description); + ReleaseStringJavaChars(jenv, jauthor, author); + ReleaseStringPDFChars(jenv, jmimetype, mimetype); + ReleaseStringPDFChars(jenv, jicon, icon); +} +/* }}} */ + +/* {{{ PDF_set_border_color */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1border_1color(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jred, jfloat jgreen, jfloat jblue) +{ + PDF *p; + float red; + float green; + float blue; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + red = flt2nat(jred); + green = flt2nat(jgreen); + blue = flt2nat(jblue); + + PDF_TRY(p) { PDF_set_border_color(p, red, green, blue); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_set_border_dash */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1border_1dash(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jb, jfloat jw) +{ + PDF *p; + float b; + float w; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + b = flt2nat(jb); + w = flt2nat(jw); + + PDF_TRY(p) { PDF_set_border_dash(p, b, w); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_set_border_style */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1border_1style(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jstyle, jfloat jwidth) +{ + PDF *p; + char * PDF_VOLATILE style = NULL; + float width; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + style = (char *)GetStringPDFChars(p, jenv, jstyle); + width = flt2nat(jwidth); + + PDF_set_border_style(p, style, width); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jstyle, style); +} +/* }}} */ + +/* p_basic.c */ + +/* {{{ PDF_boot */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1boot(JNIEnv *jenv, jclass jcls) +{ + /* throws nothing from within the library */ + PDF_boot(); +} +/* }}} */ + +/* {{{ PDF_begin_page */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1begin_1page(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jwidth, jfloat jheight) +{ + PDF *p; + float width; + float height; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + width = flt2nat(jwidth); + height = flt2nat(jheight); + PDF_begin_page(p, width, height); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_close */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1close(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_close(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_delete */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1delete(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + EXC_STUFF; + + /* Different sanity check here since PDF_delete() may be called multiply, + * e.g., once from the finalizer and once explicitly + */ + + if (PDF_ISNULL(jp)) + return; + + p = PDF_ENV2PTR(jp); + + + ex = (pdf_wrapper_data *) (PDF_get_opaque(p)); + free(ex); + + PDF_delete(p); +} +/* }}} */ + +/* {{{ PDF_end_page */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1end_1page(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_end_page(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_get_apiname */ +JNIEXPORT jstring JNICALL +Java_com_pdflib_pdflib_PDF_1get_1apiname(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + jstring PDF_VOLATILE _jresult = 0; + char * PDF_VOLATILE _result = NULL; + PDF *p; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + _result = (char *)PDF_get_apiname(p); + } pdf_catch; + + if(_result) + _jresult = (jstring)GetNewStringUTF(jenv, _result); + return _jresult; +} +/* }}} */ + +/* {{{ PDF_get_buffer */ +JNIEXPORT jbyteArray JNICALL +Java_com_pdflib_pdflib_PDF_1get_1buffer(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + jbyteArray PDF_VOLATILE _jresult = 0; + const unsigned char *buffer; + PDF *p; + long size; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + buffer = (const unsigned char *) PDF_get_buffer(p, &size); + _jresult = (*jenv)->NewByteArray(jenv, (jsize) size); + + if (_jresult == (jbyteArray) NULL) { + pdf_throw(p, "Java", "get_buffer", + "Couldn't allocate PDF output buffer"); + } else { + + (*jenv)->SetByteArrayRegion(jenv, _jresult, + 0, (jsize) size, (jbyte *) buffer); + } + } pdf_catch; + + return _jresult; +} +/* }}} */ + +/* {{{ PDF_get_errnum */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1get_1errnum(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + jint _jresult = 0; + int PDF_VOLATILE _result = 0; + PDF *p; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + _result = PDF_get_errnum(p); + } pdf_catch; + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_get_errmsg */ +JNIEXPORT jstring JNICALL +Java_com_pdflib_pdflib_PDF_1get_1errmsg(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + jstring PDF_VOLATILE _jresult = 0; + char * PDF_VOLATILE _result = NULL; + PDF *p; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + _result = (char *)PDF_get_errmsg(p); + } pdf_catch; + + if(_result) + _jresult = (jstring)GetNewStringUTF(jenv, _result); + return _jresult; +} +/* }}} */ + +/* {{{ PDF_new */ +JNIEXPORT jlong JNICALL +Java_com_pdflib_pdflib_PDF_1new(JNIEnv *jenv, jclass jcls) +{ + jlong _jresult; + PDF * PDF_VOLATILE p = (PDF *) 0; + EXC_STUFF; + char jdkname[64]; + jclass stringClass; + +#ifdef AS400 + int aux = PDF_JAVA_AS400_FIRSTINDEX; + JavaI2L(aux, _jresult); +#else + _jresult = int2ll(0); +#endif + + + if ((ex = malloc(sizeof(pdf_wrapper_data))) == NULL) { + jthrow(jenv, "Couldn't initialize PDFlib (malloc)", 0, "pdflib_java.c"); + return _jresult; + } + + p = (PDF *)PDF_new2(NULL, NULL, NULL, NULL, (void *) ex); + if (p == (PDF *)0) { + jthrow(jenv, "Couldn't initialize PDF object due to memory shortage", + 0, "pdflibp_java.c"); + return _jresult; + } + + PDF_TRY(p) { + ex->jdkversion = (*jenv)->GetVersion(jenv); + + if (((*jenv)->ExceptionOccurred(jenv)) != NULL_INT) { + (*jenv)->ExceptionDescribe(jenv); + return _jresult; + } + + sprintf(jdkname, "JDK %d.%d", + (int) ((ex->jdkversion & 0xFF0000) >> 16), + (int) (ex->jdkversion & 0xFF)); + PDF_set_parameter(p, "binding", jdkname); + + PDF_set_parameter(p, "textformat", "auto2"); + PDF_set_parameter(p, "hypertextformat", "auto2"); + PDF_set_parameter(p, "hypertextencoding", ""); + +/* "java/lang/String */ +#define PDF_java_lang_String \ + "\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67" +#define PDF_getBytes "\x67\x65\x74\x42\x79\x74\x65\x73" /* "getBytes" */ +#define PDF_sig "\x28\x29\x5B\x42" /* "()[B" */ + + stringClass = (*jenv)->FindClass(jenv, PDF_java_lang_String); + + if (stringClass == NULL_INT) { + (*jenv)->ExceptionDescribe(jenv); + jthrow(jenv, + "Couldn't initialize PDFlib (FindClass)", 0, "pdflib_java.c"); +#ifdef AS400 + JavaI2L(0, _jresult); +#else + _jresult = int2ll(0); +#endif + return _jresult; + } + + ex->MID_String_getBytes = + (*jenv)->GetMethodID(jenv, stringClass, PDF_getBytes, PDF_sig); + + if (ex->MID_String_getBytes == NULL_INT) { + (*jenv)->ExceptionDescribe(jenv); + jthrow(jenv, + "Couldn't initialize PDFlib (GetMethodID)", 0, "pdflib_java.c"); + return _jresult; + } + + } pdf_catch; + + +#ifdef AS400 + JavaI2L(aux, _jresult); +#else + *(PDF **)&_jresult = p; +#endif + + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_file */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1file(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfilename) +{ + jint _jresult = -1; + int PDF_VOLATILE _result = -1; + PDF *p; + char * PDF_VOLATILE filename = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + _result = (int )PDF_open_file(p, filename); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_shutdown */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1shutdown(JNIEnv *jenv, jclass jcls) +{ + /* throws nothing */ + PDF_shutdown(); +} +/* }}} */ + +/* p_block.c */ + +/* {{{ PDF_fill_imageblock */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1fill_1imageblock(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage, jstring jblockname, jint jimage, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE blockname = NULL; + char * PDF_VOLATILE optlist = NULL; + int page = (int) jpage; + int image = (int) jimage; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + blockname = (char *)GetStringPDFChars(p, jenv, jblockname); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + _result = (int )PDF_fill_imageblock(p, page, blockname, image, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jblockname, blockname); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_fill_pdfblock */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1fill_1pdfblock(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage, jstring jblockname, jint jcontents, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE blockname = NULL; + char * PDF_VOLATILE optlist = NULL; + int page = (int) jpage; + int contents = (int) jcontents; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + blockname = (char *)GetStringPDFChars(p, jenv, jblockname); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + _result = + (int )PDF_fill_pdfblock(p, page, blockname, contents, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jblockname, blockname); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_fill_textblock */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1fill_1textblock(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage, jstring jblockname, jstring jtext, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + int page = (int) jpage; + char * PDF_VOLATILE blockname = NULL; + char * PDF_VOLATILE text = NULL; + char * PDF_VOLATILE optlist = NULL; + int tlen; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + blockname = (char *)GetStringPDFChars(p, jenv, jblockname); + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &tlen); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + _result = (int )PDF_fill_textblock(p, page, blockname, + text, tlen, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jblockname, blockname); + ReleaseStringJavaChars(jenv, jtext, text); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* p_color.c */ + +/* {{{ PDF_makespotcolor */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1makespotcolor(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jspotname) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE spotname = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + spotname = (char *)GetStringPDFChars(p, jenv, jspotname); + _result = (int )PDF_makespotcolor(p, spotname, 0); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jspotname, spotname); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_setcolor */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setcolor(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfstype, jstring jcolorspace, jfloat jc1, jfloat jc2, + jfloat jc3, jfloat jc4) +{ + PDF *p; + char * PDF_VOLATILE fstype = NULL; + char * PDF_VOLATILE colorspace = NULL; + float c1; + float c2; + float c3; + float c4; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + c1 = flt2nat(jc1); + c2 = flt2nat(jc2); + c3 = flt2nat(jc3); + c4 = flt2nat(jc4); + + PDF_TRY(p) { + fstype = (char *)GetStringPDFChars(p, jenv, jfstype); + colorspace = (char *)GetStringPDFChars(p, jenv, jcolorspace); + PDF_setcolor(p, fstype, colorspace, c1, c2, c3, c4); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfstype, fstype); + ReleaseStringPDFChars(jenv, jcolorspace, colorspace); +} +/* }}} */ + +/* p_draw.c */ + +/* {{{ PDF_arc */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1arc(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy, jfloat jr, jfloat jalpha, + jfloat jbeta) +{ + PDF *p; + float x; + float y; + float r; + float alpha; + float beta; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + r = flt2nat(jr); + alpha = flt2nat(jalpha); + beta = flt2nat(jbeta); + + PDF_arc(p, x, y, r, alpha, beta); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_arcn */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1arcn(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy, jfloat jr, jfloat jalpha, + jfloat jbeta) +{ + PDF *p; + float x; + float y; + float r; + float alpha; + float beta; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + r = flt2nat(jr); + alpha = flt2nat(jalpha); + beta = flt2nat(jbeta); + + PDF_arcn(p, x, y, r, alpha, beta); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_circle */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1circle(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy, jfloat jr) +{ + PDF *p; + float x; + float y; + float r; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + r = flt2nat(jr); + PDF_circle(p,x,y,r); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_clip */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1clip(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_clip(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_closepath */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1closepath(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_closepath(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_closepath_fill_stroke */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1closepath_1fill_1stroke(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_closepath_fill_stroke(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_closepath_stroke */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1closepath_1stroke(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_closepath_stroke(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_curveto */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1curveto(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx1, jfloat jy1, jfloat jx2, jfloat jy2, + jfloat jx3, jfloat jy3) +{ + PDF *p; + float x1; + float y1; + float x2; + float y2; + float x3; + float y3; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x1 = flt2nat(jx1); + y1 = flt2nat(jy1); + x2 = flt2nat(jx2); + y2 = flt2nat(jy2); + x3 = flt2nat(jx3); + y3 = flt2nat(jy3); + + PDF_curveto(p, x1, y1, x2, y2, x3, y3); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_endpath */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1endpath(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_endpath(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_fill */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1fill(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_fill(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_fill_stroke */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1fill_1stroke(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_fill_stroke(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_lineto */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1lineto(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy) +{ + PDF *p; + float x; + float y; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + + PDF_lineto(p, x, y); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_moveto */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1moveto(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy) +{ + PDF *p; + float x; + float y; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + + PDF_moveto(p, x, y); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_rect */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1rect(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy, jfloat jwidth, jfloat jheight) +{ + PDF *p; + float x; + float y; + float width; + float height; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + width = flt2nat(jwidth); + height = flt2nat(jheight); + + PDF_rect(p, x, y, width, height); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_stroke */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1stroke(JNIEnv *jenv, jclass jcls, PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_stroke(p); + } pdf_catch; +} +/* }}} */ + +/* p_encoding.c */ + +/* {{{ PDF_encoding_set_char */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1encoding_1set_1char(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jencoding, jint jslot, jstring jglyphname, jint juv) +{ + PDF *p; + char * PDF_VOLATILE encoding = NULL; + int slot; + char * PDF_VOLATILE glyphname = NULL; + int uv; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + encoding = (char *)GetStringPDFChars(p, jenv, jencoding); + slot = (int)jslot; + glyphname = (char *)GetStringPDFChars(p, jenv, jglyphname); + uv = (int)juv; + + PDF_encoding_set_char(p, encoding, slot, glyphname, uv); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jencoding, encoding); + ReleaseStringPDFChars(jenv, jglyphname, glyphname); +} +/* }}} */ + +/* p_font.c */ + +/* {{{ PDF_findfont */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1findfont(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfontname, jstring jencoding, jint jembed) +{ + jint _jresult = -1; + int PDF_VOLATILE _result = -1; + PDF *p; + char * PDF_VOLATILE fontname = NULL; + char * PDF_VOLATILE encoding = NULL; + int embed; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + fontname = (char *)GetStringPDFChars(p, jenv, jfontname); + encoding = (char *)GetStringPDFChars(p, jenv, jencoding); + embed = (int )jembed; + + _result = (int )PDF_findfont(p, fontname, encoding, embed); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfontname, fontname); + ReleaseStringPDFChars(jenv, jencoding, encoding); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_load_font */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1load_1font(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfontname, jstring jencoding, jstring joptlist) +{ + jint _jresult = -1; + int PDF_VOLATILE _result = -1; + PDF *p; + char * PDF_VOLATILE fontname = NULL; + char * PDF_VOLATILE encoding = NULL; + char * PDF_VOLATILE optlist = NULL; + int len1; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + fontname = (char *)GetStringUnicodePDFChars(p, jenv, jfontname, &len1); + encoding = (char *)GetStringPDFChars(p, jenv, jencoding); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_load_font(p,fontname, len1, encoding, optlist); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jfontname, fontname); + ReleaseStringPDFChars(jenv, jencoding, encoding); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_setfont */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setfont(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jfont, jfloat jfontsize) +{ + PDF *p; + int font; + float fontsize; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + font = (int )jfont; + fontsize = flt2nat(jfontsize); + PDF_setfont(p, font, fontsize); + } pdf_catch; +} +/* }}} */ + +/* p_gstate.c */ + +/* {{{ PDF_concat */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1concat(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat a, jfloat b, jfloat c, jfloat d, jfloat e, jfloat f) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + PDF_concat(p, flt2nat(a), flt2nat(b), flt2nat(c), flt2nat(d), + flt2nat(e), flt2nat(f)); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_initgraphics */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1initgraphics(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_initgraphics(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_restore */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1restore(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_restore(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_rotate */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1rotate(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jphi) +{ + PDF *p; + float phi; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + phi = flt2nat(jphi); + + PDF_TRY(p) { PDF_rotate(p, phi); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_save */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1save(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_save(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_scale */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1scale(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jsx, jfloat jsy) +{ + PDF *p; + float sx; + float sy; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + sx = flt2nat(jsx); + sy = flt2nat(jsy); + + PDF_scale(p, sx, sy); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setdash */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setdash(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jb, jfloat jw) +{ + PDF *p; + float b; + float w; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + b = flt2nat(jb); + w = flt2nat(jw); + + PDF_setdash(p, b, w); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setdashpattern */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setdashpattern(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring joptlist) +{ + PDF *p; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + PDF_setdashpattern(p, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_setflat */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setflat(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jflatness) +{ + PDF *p; + float flatness; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + flatness = flt2nat(jflatness); + + PDF_setflat(p, flatness); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setlinecap */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setlinecap(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jlinecap) +{ + PDF *p; + int linecap; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + linecap = (int )jlinecap; + + PDF_setlinecap(p, linecap); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setlinejoin */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setlinejoin(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jlinejoin) +{ + PDF *p; + int linejoin; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + linejoin = (int )jlinejoin; + + PDF_setlinejoin(p, linejoin); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setlinewidth */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setlinewidth(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jwidth) +{ + PDF *p; + float width; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + width = flt2nat(jwidth); + + PDF_setlinewidth(p, width); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setmatrix */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setmatrix(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat ja, jfloat jb, jfloat jc, jfloat jd, + jfloat je, jfloat jf) +{ + PDF *p; + float a; + float b; + float c; + float d; + float e; + float f; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + a = flt2nat(ja); + b = flt2nat(jb); + c = flt2nat(jc); + d = flt2nat(jd); + e = flt2nat(je); + f = flt2nat(jf); + + PDF_setmatrix(p, a, b, c, d, e, f); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setmiterlimit */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setmiterlimit(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jmiter) +{ + PDF *p; + float miter; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + miter = flt2nat(jmiter); + + PDF_setmiterlimit(p, miter); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_setpolydash */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1setpolydash(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloatArray jdasharray) +{ + PDF *p; + float carray[MAX_DASH_LENGTH]; + jfloat* javaarray; + int i; + jsize PDF_VOLATILE length; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + length = (*jenv)->GetArrayLength(jenv, jdasharray); + if (length > MAX_DASH_LENGTH) + length = MAX_DASH_LENGTH; + + javaarray = (*jenv)->GetFloatArrayElements(jenv, jdasharray, 0); + + for(i=0; i < length; i++) + carray[i] = flt2nat(javaarray[i]); + + PDF_setpolydash(p, carray, length); + (*jenv)->ReleaseFloatArrayElements(jenv, jdasharray, javaarray, 0); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_skew */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1skew(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jalpha, jfloat jbeta) +{ + PDF *p; + float alpha; + float beta; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + alpha = flt2nat(jalpha); + beta = flt2nat(jbeta); + + PDF_skew(p, alpha, beta); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_translate */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1translate(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jtx, jfloat jty) +{ + PDF *p; + float tx; + float ty; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + tx = flt2nat(jtx); + ty = flt2nat(jty); + + PDF_translate(p, tx, ty); + } pdf_catch; +} +/* }}} */ + +/* p_hyper.c */ + +/* {{{ PDF_add_bookmark */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1add_1bookmark(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext, jint jparent, jint jopen) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE text = NULL; + int parent; + int open; + int len1; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + parent = (int )jparent; + open = (int )jopen; + + _result = (int )PDF_add_bookmark2(p, text, len1, parent, open); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_add_nameddest */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1nameddest(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jname, jstring joptlist) +{ + PDF *p; + char * PDF_VOLATILE name = NULL; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + name = (char *)GetStringPDFChars(p, jenv, jname); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + PDF_add_nameddest(p, name, 0, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jname, name); + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_set_info */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1info(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jstring jvaluex) +{ + PDF *p; + char * PDF_VOLATILE key = NULL; + char * PDF_VOLATILE value = NULL; + int len2; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + key = (char *)GetStringPDFChars(p, jenv, jkey); + value = (char *)GetStringUnicodePDFChars(p, jenv, jvaluex, &len2); + + PDF_set_info2(p, key, value, len2); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + ReleaseStringJavaChars(jenv, jvaluex, value); +} +/* }}} */ + +/* p_icc.c */ + +/* {{{ PDF_load_iccprofile */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1load_1iccprofile(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jprofilename, jstring joptlist) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE profilename = NULL; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + profilename = (char *)GetStringPDFChars(p, jenv, jprofilename); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_load_iccprofile(p, profilename, 0, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jprofilename, profilename); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* p_image.c */ + +/* {{{ PDF_add_thumbnail */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1add_1thumbnail(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jimage) +{ + PDF *p; + int image; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + image = (int )jimage; + + PDF_add_thumbnail(p, image); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_close_image */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1close_1image(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jimage) +{ + PDF *p; + int image; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + image = (int )jimage; + + PDF_close_image(p, image); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_fit_image */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1fit_1image(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jimage, jfloat jx, jfloat jy, jstring joptlist) +{ + PDF *p; + int image; + float x; + float y; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + optlist = (char *) GetStringPDFChars(p, jenv, joptlist); + image = (int)jimage; + x = flt2nat(jx); + y = flt2nat(jy); + PDF_fit_image(p, image, x, y, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_load_image */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1load_1image(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jimagetype, jstring jfilename, jstring joptlist) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE imagetype = NULL; + char * PDF_VOLATILE filename = NULL; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + imagetype = (char *)GetStringPDFChars(p, jenv, jimagetype); + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_load_image(p, imagetype, filename, 0, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jimagetype, imagetype); + ReleaseStringPDFChars(jenv, jfilename, filename); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_CCITT */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1CCITT(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfilename, jint jwidth, jint jheight, jint jBitReverse, + jint jK, jint jBlackIs1) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE filename = NULL; + int width; + int height; + int BitReverse; + int K; + int BlackIs1; + + PDF_JAVA_SANITY_CHECK(jp); + + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + width = (int )jwidth; + height = (int )jheight; + BitReverse = (int )jBitReverse; + K = (int )jK; + BlackIs1 = (int )jBlackIs1; + + _result = (int )PDF_open_CCITT(p, filename, width, height, BitReverse, + K, BlackIs1); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_image */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1image(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jimagetype, jstring jsource, jbyteArray jdata, + jlong jlength, jint jwidth, jint jheight, jint jcomponents, + jint jbpc, jstring jparams) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE imagetype = NULL; + char * PDF_VOLATILE source = NULL; + char * PDF_VOLATILE data = NULL; +#ifdef OS390 + int ilength; +#endif + long length; + int width; + int height; + int components; + int bpc; + char * PDF_VOLATILE params = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + data = (char *) + (*jenv)->GetByteArrayElements(jenv, jdata, (jboolean *) NULL); + imagetype = (char *)GetStringPDFChars(p, jenv, jimagetype); + source = (char *)GetStringPDFChars(p, jenv, jsource); + +#ifdef AS400 + /* deal with the AS/400's idea of a jlong... */ + JavaL2I(jlength, length); +#elif OS390 + ilength = ll2int(jlength); + length = (long )ilength; +#else + length = (long )jlength; +#endif + + width = (int )jwidth; + height = (int )jheight; + components = (int )jcomponents; + bpc = (int )jbpc; + params = (char *)GetStringPDFChars(p, jenv, jparams); + + _result = (int )PDF_open_image(p, imagetype, source, data, length, + width, height, components, bpc, params); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jimagetype, imagetype); + ReleaseStringPDFChars(jenv, jsource, source); + (*jenv)->ReleaseByteArrayElements(jenv, jdata, (jbyte*) data, JNI_ABORT); + ReleaseStringPDFChars(jenv, jparams, params); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_image_file */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1image_1file(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jimagetype, jstring jfilename, jstring jstringparam, + jint jintparam) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE imagetype = NULL; + char * PDF_VOLATILE filename = NULL; + char * PDF_VOLATILE stringparam = NULL; + int intparam; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + imagetype = (char *)GetStringPDFChars(p, jenv, jimagetype); + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + stringparam = (char *)GetStringPDFChars(p, jenv, jstringparam); + intparam = (int )jintparam; + + _result = (int )PDF_open_image_file(p, imagetype, filename, + stringparam, intparam); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jimagetype, imagetype); + ReleaseStringPDFChars(jenv, jfilename, filename); + ReleaseStringPDFChars(jenv, jstringparam, stringparam); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_place_image */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1place_1image(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jimage, jfloat jx, jfloat jy, jfloat jscale) +{ + PDF *p; + int image; + float x; + float y; + float scale; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + image = (int )jimage; + x = flt2nat(jx); + y = flt2nat(jy); + scale = flt2nat(jscale); + + PDF_place_image(p, image, x, y, scale); + } pdf_catch; +} +/* }}} */ + +/* p_params.c */ + +/* {{{ PDF_get_parameter */ +JNIEXPORT jstring JNICALL +Java_com_pdflib_pdflib_PDF_1get_1parameter(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jfloat jmodifier) +{ + jstring PDF_VOLATILE _jresult = 0; + char * PDF_VOLATILE _result = NULL; + char * PDF_VOLATILE key = NULL; + float modifier; + PDF *p; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + key = (char *) GetStringPDFChars(p, jenv, jkey); + modifier = flt2nat(jmodifier); + + _result = (char *)PDF_get_parameter(p, key, modifier); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + + if(_result) + _jresult = (jstring)GetNewStringUTF(jenv, _result); + return _jresult; +} +/* }}} */ + +/* {{{ PDF_get_value */ +JNIEXPORT jfloat JNICALL +Java_com_pdflib_pdflib_PDF_1get_1value(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jfloat jvaluex) +{ + jfloat _jresult = tofloat(0); + float PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE key = NULL; + float value; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + key = (char *) GetStringPDFChars(p, jenv, jkey); + value = flt2nat(jvaluex); + + _result = (float )PDF_get_value(p, key, value); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + + _jresult = tofloat(_result); + return _jresult; +} +/* }}} */ + +/* {{{ PDF_set_parameter */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1parameter(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jstring jvaluex) +{ + PDF *p; + char * PDF_VOLATILE key = NULL; + char * PDF_VOLATILE value = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + key = (char *)GetStringPDFChars(p, jenv, jkey); + value = (char *)GetStringPDFChars(p, jenv, jvaluex); + + PDF_set_parameter(p, key, value); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + ReleaseStringPDFChars(jenv, jvaluex, value); +} +/* }}} */ + +/* {{{ PDF_set_value */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1value(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jfloat jvaluex) +{ + PDF *p; + char * PDF_VOLATILE key = NULL; + float value; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + key = (char *) GetStringPDFChars(p, jenv, jkey); + value = flt2nat(jvaluex); + + PDF_set_value(p, key, value); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); +} +/* }}} */ + +/* p_pattern.c */ + +/* {{{ PDF_begin_pattern */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1begin_1pattern(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jwidth, jfloat jheight, jfloat jxstep, jfloat jystep, + jint jpainttype) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + float width; + float height; + float xstep; + float ystep; + int painttype; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + width = flt2nat(jwidth); + height = flt2nat(jheight); + xstep = flt2nat(jxstep); + ystep = flt2nat(jystep); + painttype = (int)jpainttype; + + _result = (int )PDF_begin_pattern(p, width, height, xstep, + ystep, painttype); + } pdf_catch; + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_end_pattern */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1end_1pattern(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_end_pattern(p); + } pdf_catch; +} +/* }}} */ + +/* p_pdi.c */ +/* {{{ PDF_close_pdi */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1close_1pdi(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jdoc) +{ + PDF *p; + int doc; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + doc = (int )jdoc; + + PDF_close_pdi(p, doc); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_close_pdi_page */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1close_1pdi_1page(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage) +{ + PDF *p; + int page; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + page = (int )jpage; + + PDF_close_pdi_page(p, page); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_fit_pdi_page */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1fit_1pdi_1page(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage, jfloat jx, jfloat jy, jstring joptlist) +{ + PDF *p; + int page; + float x; + float y; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + page = (int) jpage; + x = flt2nat(jx); + y = flt2nat(jy); + optlist = (char *) GetStringPDFChars(p, jenv, joptlist); + + PDF_fit_pdi_page(p, page, x, y, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_get_pdi_parameter */ +JNIEXPORT jstring JNICALL +Java_com_pdflib_pdflib_PDF_1get_1pdi_1parameter(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jint jdoc, jint jpage, jint jreserved) +{ + PDF *p; + jstring PDF_VOLATILE _jresult = 0; + char * PDF_VOLATILE _result = NULL; + char * PDF_VOLATILE key = NULL; + int doc; + int page; + int reserved; + int len; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + doc = (int )jdoc; + page = (int )jpage; + reserved = (int )jreserved; + key = (char *)GetStringPDFChars(p, jenv, jkey); + + _result = (char *) + PDF_get_pdi_parameter(p, key, doc, page, reserved, &len); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + + /* TODO: return a Unicode string based on _result and len */ + if(_result != NULL) + _jresult = (jstring)GetNewStringUTF(jenv, _result); + return _jresult; +} +/* }}} */ + +/* {{{ PDF_get_pdi_value */ +JNIEXPORT jfloat JNICALL +Java_com_pdflib_pdflib_PDF_1get_1pdi_1value(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jkey, jint jdoc, jint jpage, jint jreserved) +{ + PDF *p; + jfloat _jresult = tofloat(0); + jfloat PDF_VOLATILE _result = tofloat(0); + char * PDF_VOLATILE key = NULL; + int doc; + int page; + int reserved; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + doc = (int )jdoc; + page = (int )jpage; + reserved = (int )jreserved; + key = (char *)GetStringPDFChars(p, jenv, jkey); + + _result = tofloat(PDF_get_pdi_value(p, key, doc, page, reserved)); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jkey, key); + + _jresult = _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_pdi */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1pdi(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfilename, jstring joptlist, jint jreserved) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE filename = NULL; + char * PDF_VOLATILE optlist = NULL; + int reserved; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + reserved = (int )jreserved; + + _result = (int )PDF_open_pdi(p, filename, optlist, reserved); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_open_pdi_page */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1open_1pdi_1page(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jdoc, jint jpagenumber, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + int doc; + int pagenumber; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + doc = (int )jdoc; + pagenumber = (int )jpagenumber; + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_open_pdi_page(p, doc, pagenumber, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_place_pdi_page */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1place_1pdi_1page(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jpage, jfloat jx, jfloat jy, jfloat jsx, jfloat jsy) +{ + PDF *p; + int page; + float x; + float y; + float sx; + float sy; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + page = (int )jpage; + x = flt2nat(jx); + y = flt2nat(jy); + sx = flt2nat(jsx); + sy = flt2nat(jsy); + + PDF_place_pdi_page(p, page, x, y, sx, sy); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_process_pdi */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1process_1pdi(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jdoc, jint jpage, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + int doc; + int page; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + doc = (int )jdoc; + page = (int )jpage; + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_process_pdi(p, doc, page, optlist); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* p_resource.c */ + +/* {{{ PDF_create_pvf */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1create_1pvf(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfilename, jbyteArray jdata, jstring joptlist) +{ + PDF *p; + char * PDF_VOLATILE filename = NULL; + char * PDF_VOLATILE data = NULL; + char * PDF_VOLATILE optlist = NULL; + size_t dlen; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + filename = (char *) GetStringPDFChars(p, jenv, jfilename); + dlen = (*jenv)->GetArrayLength(jenv, jdata); + data = (char *) + (*jenv)->GetByteArrayElements(jenv, jdata, (jboolean *) NULL); + optlist = (char *) GetStringPDFChars(p, jenv, joptlist); + + /* TODO: append "copy" to existing optlist, if optlist changes */ + PDF_create_pvf(p, filename, 0, data, dlen, "copy"); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + (*jenv)->ReleaseByteArrayElements(jenv, jdata, (jbyte*) data, JNI_ABORT); + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_delete_pvf */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1delete_1pvf(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfilename) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE filename = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + filename = (char *)GetStringPDFChars(p, jenv, jfilename); + + _result = (int )PDF_delete_pvf(p, filename, 0); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfilename, filename); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* p_shading.c */ + +/* {{{ PDF_shading */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1shading(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jshtype, jfloat jx0, jfloat jy0, jfloat jx1, jfloat jy1, + jfloat jc1, jfloat jc2, jfloat jc3, jfloat jc4, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE shtype = NULL; + char * PDF_VOLATILE optlist = NULL; + float x0, y0, x1, y1, c1, c2, c3, c4; + + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + shtype = (char *)GetStringPDFChars(p, jenv, jshtype); + x0 = flt2nat(jx0); + y0 = flt2nat(jy0); + x1 = flt2nat(jx1); + y1 = flt2nat(jy1); + c1 = flt2nat(jc1); + c2 = flt2nat(jc2); + c3 = flt2nat(jc3); + c4 = flt2nat(jc4); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_shading(p, shtype, x0, y0, x1, y1, c1, c2, c3, c4, + optlist); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, jshtype, shtype); + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_shading_pattern */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1shading_1pattern(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jshading, jstring joptlist) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + char * PDF_VOLATILE optlist = NULL; + int shading; + + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + shading = (int)jshading; + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = (int )PDF_shading_pattern(p, shading, optlist); + + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_shfill */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1shfill(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jshading) +{ + PDF *p; + int shading; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + shading = (int )jshading; + + PDF_shfill(p, shading); + } pdf_catch; +} +/* }}} */ + +/* p_template.c */ + +/* {{{ PDF_begin_template */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1begin_1template(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jwidth, jfloat jheight) +{ + PDF *p; + jint _jresult = 0; + int PDF_VOLATILE _result = -1; + float width; + float height; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + width = flt2nat(jwidth); + height = flt2nat(jheight); + + _result = (int )PDF_begin_template(p, width, height); + } pdf_catch; + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_end_template */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1end_1template(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_end_template(p); + } pdf_catch; +} +/* }}} */ + +/* p_text.c */ + +/* {{{ PDF_continue_text */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1continue_1text(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext) +{ + PDF *p; + char * PDF_VOLATILE text = NULL; + int len1; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + + PDF_continue_text2(p, text, len1); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); +} +/* }}} */ + +/* {{{ PDF_fit_textline */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1fit_1textline(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext, jfloat jx, jfloat jy, jstring joptlist) +{ + PDF *p; + char * PDF_VOLATILE text = NULL; + float x; + float y; + char * PDF_VOLATILE optlist = NULL; + int len; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len); + x = flt2nat(jx); + y = flt2nat(jy); + optlist = (char *) GetStringPDFChars(p, jenv, joptlist); + + PDF_fit_textline(p, text, len, x, y, optlist); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_set_text_pos */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1text_1pos(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jfloat jx, jfloat jy) +{ + PDF *p; + float x; + float y; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + x = flt2nat(jx); + y = flt2nat(jy); + + PDF_set_text_pos(p, x, y); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_show */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1show(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext) +{ + PDF *p; + char * PDF_VOLATILE text = NULL; + int len1; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + + PDF_show2(p, text, len1); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); +} +/* }}} */ + +/* {{{ PDF_show_boxed */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1show_1boxed(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext, jfloat jleft, jfloat jtop, jfloat jwidth, + jfloat jheight, jstring jhmode, jstring jfeature) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE text = NULL; + float left; + float top; + float width; + float height; + char * PDF_VOLATILE hmode = NULL; + char * PDF_VOLATILE feature = NULL; + int len1; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + left = flt2nat(jleft); + top = flt2nat(jtop); + width = flt2nat(jwidth); + height = flt2nat(jheight); + hmode = (char *)GetStringPDFChars(p, jenv, jhmode); + feature = (char *)GetStringPDFChars(p, jenv, jfeature); + + _result = PDF_show_boxed2(p, text, len1, left, top, width, height, + hmode, feature); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); + ReleaseStringPDFChars(jenv, jhmode, hmode); + ReleaseStringPDFChars(jenv, jfeature, feature); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_show_xy */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1show_1xy(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext, jfloat jx, jfloat jy) +{ + PDF *p; + char * PDF_VOLATILE text = NULL; + float x; + float y; + int len1; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + x = flt2nat(jx); + y = flt2nat(jy); + + PDF_show_xy2(p, text, len1, x, y); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); +} +/* }}} */ + +/* {{{ PDF_stringwidth */ +JNIEXPORT jfloat JNICALL +Java_com_pdflib_pdflib_PDF_1stringwidth(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jtext, jint jfont, jfloat jfontsize) +{ + jfloat _jresult = tofloat(0); + float PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE text = NULL; + int font; + float fontsize; + int len1; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + text = (char *)GetStringUnicodePDFChars(p, jenv, jtext, &len1); + font = (int )jfont; + fontsize = flt2nat(jfontsize); + + _result = (float )PDF_stringwidth2(p, text, len1, font, fontsize); + } pdf_catch; + + ReleaseStringJavaChars(jenv, jtext, text); + + _jresult = tofloat(_result); + return _jresult; +} +/* }}} */ + +/* p_type3.c */ + +/* {{{ PDF_begin_font */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1begin_1font(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jfontname, jfloat ja, jfloat jb, jfloat jc, + jfloat jd, jfloat je, jfloat jf, jstring joptlist) +{ + PDF *p; + char * PDF_VOLATILE fontname = NULL; + float a; + float b; + float c; + float d; + float e; + float f; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + fontname = (char *)GetStringPDFChars(p, jenv, jfontname); + a = flt2nat(ja); + b = flt2nat(jb); + c = flt2nat(jc); + d = flt2nat(jd); + e = flt2nat(je); + f = flt2nat(jf); + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + PDF_begin_font(p, fontname, 0, a, b, c, d, e, f, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jfontname, fontname); + ReleaseStringPDFChars(jenv, joptlist, optlist); +} +/* }}} */ + +/* {{{ PDF_begin_glyph */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1begin_1glyph(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring jglyphname, jfloat jwx, jfloat jllx, jfloat jlly, + jfloat jurx, jfloat jury) +{ + PDF *p; + char * PDF_VOLATILE glyphname = NULL; + float wx; + float llx; + float lly; + float urx; + float ury; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + glyphname = (char *)GetStringPDFChars(p, jenv, jglyphname); + wx = flt2nat(jwx); + llx = flt2nat(jllx); + lly = flt2nat(jlly); + urx = flt2nat(jurx); + ury = flt2nat(jury); + + PDF_begin_glyph(p, glyphname, wx, llx, lly, urx, ury); + } pdf_catch; + + ReleaseStringPDFChars(jenv, jglyphname, glyphname); +} +/* }}} */ + +/* {{{ PDF_end_font */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1end_1font(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_end_font(p); + } pdf_catch; +} +/* }}} */ + +/* {{{ PDF_end_glyph */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1end_1glyph(JNIEnv *jenv, jclass jcls, + PDF_ENV jp) +{ + PDF *p; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { PDF_end_glyph(p); + } pdf_catch; +} +/* }}} */ + +/* p_xgstate.c */ + +/* {{{ PDF_create_gstate */ +JNIEXPORT jint JNICALL +Java_com_pdflib_pdflib_PDF_1create_1gstate(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jstring joptlist) +{ + jint _jresult = 0; + int PDF_VOLATILE _result; + PDF *p; + char * PDF_VOLATILE optlist = NULL; + + PDF_JAVA_SANITY_CHECK(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + optlist = (char *)GetStringPDFChars(p, jenv, joptlist); + + _result = PDF_create_gstate(p, optlist); + } pdf_catch; + + ReleaseStringPDFChars(jenv, joptlist, optlist); + + _jresult = (jint) _result; + return _jresult; +} +/* }}} */ + +/* {{{ PDF_set_gstate */ +JNIEXPORT void JNICALL +Java_com_pdflib_pdflib_PDF_1set_1gstate(JNIEnv *jenv, jclass jcls, + PDF_ENV jp, jint jgstate) +{ + PDF *p; + int gstate; + + PDF_JAVA_SANITY_CHECK_VOID(jp); + p = PDF_ENV2PTR(jp); + + PDF_TRY(p) { + gstate = (int)jgstate; + + PDF_set_gstate(p, gstate); + } pdf_catch; +} +/* }}} */ + +/* + * vim600: sw=4 fdm=marker + */ diff --git a/src/libs/pdflib/bind/pdflib/java/quickreference.java b/src/libs/pdflib/bind/pdflib/java/quickreference.java new file mode 100644 index 0000000000..a83f5cd206 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/quickreference.java @@ -0,0 +1,97 @@ +/* $Id: quickreference.java,v 1.1 2004/10/06 17:16:52 laplace Exp $ + * + * PDFlib/PDI client: mini imposition demo + */ + +import java.io.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class quickreference +{ + public static void main (String argv[]) + { + int manual, page; + int font, row, col; + final int maxrow = 2, maxcol = 2; + int i, startpage = 1, endpage = 4; + final float width = 500, height = 770; + int pageno; + pdflib p = null; + String infile = "reference.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + + try{ + p = new pdflib(); + + if (p.open_file("quickreference.pdf") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "quickreference.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "imposition demo (Java)"); + + manual = p.open_pdi(infile, "", 0); + if (manual == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + row = 0; + col = 0; + + p.set_parameter("topdown", "true"); + + for (pageno = startpage; pageno <= endpage; pageno++) { + if (row == 0 && col == 0) { + p.begin_page(width, height); + font = p.load_font("Helvetica-Bold", "winansi", ""); + p.setfont(font, 18); + p.set_text_pos(24, 24); + p.show("PDFlib Quick Reference"); + } + + page = p.open_pdi_page(manual, pageno, ""); + + if (page == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.fit_pdi_page(manual, width/maxcol*col, + (row + 1) * height/maxrow, "scale " + (float)1/maxrow); + p.close_pdi_page(page); + + col++; + if (col == maxcol) { + col = 0; + row++; + } + if (row == maxrow) { + row = 0; + p.end_page(); + } + } + + // finish the last partial page + if (row != 0 || col != 0) + p.end_page(); + + p.close(); + p.close_pdi(manual); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in quickreference sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +}