From: Eduardo Cavazos Date: Sat, 15 Mar 2008 00:55:58 +0000 (-0600) Subject: move pdf to unmaintained X-Git-Tag: 0.94~3738^2~93 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=7ae8324c38fa6f67e43ee9c2978c7a2d78d519d0 move pdf to unmaintained --- diff --git a/extra/pdf/authors.txt b/extra/pdf/authors.txt deleted file mode 100644 index 7c29e7c401..0000000000 --- a/extra/pdf/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Elie Chaftari diff --git a/extra/pdf/libhpdf/libhpdf.factor b/extra/pdf/libhpdf/libhpdf.factor deleted file mode 100644 index a40b7cddee..0000000000 --- a/extra/pdf/libhpdf/libhpdf.factor +++ /dev/null @@ -1,180 +0,0 @@ -! Copyright (C) 2007 Elie CHAFTARI -! See http://factorcode.org/license.txt for BSD license. -! -! Tested with libharu2 2.0.8 on Mac OS X 10.4.9 PowerPC -! -! export LD_LIBRARY_PATH=/opt/local/lib - -USING: alien alien.syntax combinators system ; - -IN: pdf.libhpdf - -<< "libhpdf" { - { [ win32? ] [ "libhpdf.dll" "stdcall" ] } - { [ macosx? ] [ "libhpdf.dylib" "cdecl" ] } - { [ unix? ] [ "$LD_LIBRARY_PATH/libhpdf.so" "cdecl" ] } -} cond add-library >> - -! compression mode -: HPDF_COMP_NONE HEX: 00 ; inline ! No contents are compressed -: HPDF_COMP_TEXT HEX: 01 ; inline ! Compress contents stream of page -: HPDF_COMP_IMAGE HEX: 02 ; inline ! Compress streams of image objects -: HPDF_COMP_METADATA HEX: 04 ; inline ! Compress other data (fonts, cmaps...) -: HPDF_COMP_ALL HEX: 0F ; inline ! All stream data are compressed -: HPDF_COMP_MASK HEX: FF ; inline - -! page mode -C-ENUM: - HPDF_PAGE_MODE_USE_NONE - HPDF_PAGE_MODE_USE_OUTLINE - HPDF_PAGE_MODE_USE_THUMBS - HPDF_PAGE_MODE_FULL_SCREEN - HPDF_PAGE_MODE_EOF -; - -: error-code ( -- seq ) { - { HEX: 1001 "HPDF_ARRAY_COUNT_ERR\nInternal error. The consistency of the data was lost." } - { HEX: 1002 "HPDF_ARRAY_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } - { HEX: 1003 "HPDF_ARRAY_ITEM_UNEXPECTED_TYPE\nInternal error. The consistency of the data was lost." } - { HEX: 1004 "HPDF_BINARY_LENGTH_ERR\nThe length of the data exceeds HPDF_LIMIT_MAX_STRING_LEN." } - { HEX: 1005 "HPDF_CANNOT_GET_PALLET\nCannot get a pallet data from PNG image." } - { HEX: 1007 "HPDF_DICT_COUNT_ERR\nThe count of elements of a dictionary exceeds HPDF_LIMIT_MAX_DICT_ELEMENT" } - { HEX: 1008 "HPDF_DICT_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } - { HEX: 1009 "HPDF_DICT_ITEM_UNEXPECTED_TYPE\nInternal error. The consistency of the data was lost." } - { HEX: 100A "HPDF_DICT_STREAM_LENGTH_NOT_FOUND\nInternal error. The consistency of the data was lost." } - { HEX: 100B "HPDF_DOC_ENCRYPTDICT_NOT_FOUND\nHPDF_SetPermission() OR HPDF_SetEncryptMode() was called before a password is set." } - { HEX: 100C "HPDF_DOC_INVALID_OBJECT\nInternal error. The consistency of the data was lost." } - { HEX: 100E "HPDF_DUPLICATE_REGISTRATION\nTried to register a font that has been registered." } - { HEX: 100F "HPDF_EXCEED_JWW_CODE_NUM_LIMIT\nCannot register a character to the japanese word wrap characters list." } - { HEX: 1011 "HPDF_ENCRYPT_INVALID_PASSWORD\nTried to set the owner password to NULL. owner password and user password is the same." } - { HEX: 1013 "HPDF_ERR_UNKNOWN_CLASS\nInternal error. The consistency of the data was lost." } - { HEX: 1014 "HPDF_EXCEED_GSTATE_LIMIT\nThe depth of the stack exceeded HPDF_LIMIT_MAX_GSTATE." } - { HEX: 1015 "HPDF_FAILED_TO_ALLOC_MEM\nMemory allocation failed." } - { HEX: 1016 "HPDF_FILE_IO_ERROR\nFile processing failed. (A detailed code is set.)" } - { HEX: 1017 "HPDF_FILE_OPEN_ERROR\nCannot open a file. (A detailed code is set.)" } - { HEX: 1019 "HPDF_FONT_EXISTS\nTried to load a font that has already been registered." } - { HEX: 101A "HPDF_FONT_INVALID_WIDTHS_TABLE\nThe format of a font-file is invalid . Internal error. The consistency of the data was lost." } - { HEX: 101B "HPDF_INVALID_AFM_HEADER\nCannot recognize a header of an afm file." } - { HEX: 101C "HPDF_INVALID_ANNOTATION\nThe specified annotation handle is invalid." } - { HEX: 101E "HPDF_INVALID_BIT_PER_COMPONENT\nBit-per-component of a image which was set as mask-image is invalid." } - { HEX: 101F "HPDF_INVALID_CHAR_MATRICS_DATA\nCannot recognize char-matrics-data of an afm file." } - { HEX: 1020 "HPDF_INVALID_COLOR_SPACE\n1. The color_space parameter of HPDF_LoadRawImage is invalid.\n2. Color-space of a image which was set as mask-image is invalid.\n3. The function which is invalid in the present color-space was invoked." } - { HEX: 1021 "HPDF_INVALID_COMPRESSION_MODE\nInvalid value was set when invoking HPDF_SetCommpressionMode()." } - { HEX: 1022 "HPDF_INVALID_DATE_TIME\nAn invalid date-time value was set." } - { HEX: 1023 "HPDF_INVALID_DESTINATION\nAn invalid destination handle was set." } - { HEX: 1025 "HPDF_INVALID_DOCUMENT\nAn invalid document handle is set." } - { HEX: 1026 "HPDF_INVALID_DOCUMENT_STATE\nThe function which is invalid in the present state was invoked." } - { HEX: 1027 "HPDF_INVALID_ENCODER\nAn invalid encoder handle was set." } - { HEX: 1028 "HPDF_INVALID_ENCODER_TYPE\nA combination between font and encoder is wrong." } - { HEX: 102B "HPDF_INVALID_ENCODING_NAME\nAn Invalid encoding name is specified." } - { HEX: 102C "HPDF_INVALID_ENCRYPT_KEY_LEN\nThe lengh of the key of encryption is invalid." } - { HEX: 102D "HPDF_INVALID_FONTDEF_DATA\n1. An invalid font handle was set.\n2. Unsupported font format." } - { HEX: 102E "HPDF_INVALID_FONTDEF_TYPE\nInternal error. The consistency of the data was lost." } - { HEX: 102F "HPDF_INVALID_FONT_NAME\nA font which has the specified name is not found." } - { HEX: 1030 "HPDF_INVALID_IMAGE\nUnsupported image format." } - { HEX: 1031 "HPDF_INVALID_JPEG_DATA\nUnsupported image format." } - { HEX: 1032 "HPDF_INVALID_N_DATA\nCannot read a postscript-name from an afm file." } - { HEX: 1033 "HPDF_INVALID_OBJECT\n1. An invalid object is set.\n2. Internal error. The consistency of the data was lost." } - { HEX: 1034 "HPDF_INVALID_OBJ_ID\nInternal error. The consistency of the data was lost." } - { HEX: 1035 "HPDF_INVALID_OPERATION\nInvoked HPDF_Image_SetColorMask() against the image-object which was set a mask-image." } - { HEX: 1036 "HPDF_INVALID_OUTLINE\nAn invalid outline-handle was specified." } - { HEX: 1037 "HPDF_INVALID_PAGE\nAn invalid page-handle was specified." } - { HEX: 1038 "HPDF_INVALID_PAGES\nAn invalid pages-handle was specified. (internal error)" } - { HEX: 1039 "HPDF_INVALID_PARAMETER\nAn invalid value is set." } - { HEX: 103B "HPDF_INVALID_PNG_IMAGE\nInvalid PNG image format." } - { HEX: 103C "HPDF_INVALID_STREAM\nInternal error. The consistency of the data was lost." } - { HEX: 103D "HPDF_MISSING_FILE_NAME_ENTRY\nInternal error. The \"_FILE_NAME\" entry for delayed loading is missing." } - { HEX: 103F "HPDF_INVALID_TTC_FILE\nInvalid .TTC file format." } - { HEX: 1040 "HPDF_INVALID_TTC_INDEX\nThe index parameter was exceed the number of included fonts" } - { HEX: 1041 "HPDF_INVALID_WX_DATA\nCannot read a width-data from an afm file." } - { HEX: 1042 "HPDF_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } - { HEX: 1043 "HPDF_LIBPNG_ERROR\nAn error has returned from PNGLIB while loading an image." } - { HEX: 1044 "HPDF_NAME_INVALID_VALUE\nInternal error. The consistency of the data was lost." } - { HEX: 1045 "HPDF_NAME_OUT_OF_RANGE\nInternal error. The consistency of the data was lost." } - { HEX: 1049 "HPDF_PAGES_MISSING_KIDS_ENTRY\nInternal error. The consistency of the data was lost." } - { HEX: 104A "HPDF_PAGE_CANNOT_FIND_OBJECT\nInternal error. The consistency of the data was lost." } - { HEX: 104B "HPDF_PAGE_CANNOT_GET_ROOT_PAGES\nInternal error. The consistency of the data was lost." } - { HEX: 104C "HPDF_PAGE_CANNOT_RESTORE_GSTATE\nThere are no graphics-states to be restored." } - { HEX: 104D "HPDF_PAGE_CANNOT_SET_PARENT\nInternal error. The consistency of the data was lost." } - { HEX: 104E "HPDF_PAGE_FONT_NOT_FOUND\nThe current font is not set." } - { HEX: 104F "HPDF_PAGE_INVALID_FONT\nAn invalid font-handle was specified." } - { HEX: 1050 "HPDF_PAGE_INVALID_FONT_SIZE\nAn invalid font-size was set." } - { HEX: 1051 "HPDF_PAGE_INVALID_GMODE\nSee Graphics mode." } - { HEX: 1052 "HPDF_PAGE_INVALID_INDEX\nInternal error. The consistency of the data was lost." } - { HEX: 1053 "HPDF_PAGE_INVALID_ROTATE_VALUE\nThe specified value is not a multiple of 90." } - { HEX: 1054 "HPDF_PAGE_INVALID_SIZE\nAn invalid page-size was set." } - { HEX: 1055 "HPDF_PAGE_INVALID_XOBJECT\nAn invalid image-handle was set." } - { HEX: 1056 "HPDF_PAGE_OUT_OF_RANGE\nThe specified value is out of range." } - { HEX: 1057 "HPDF_REAL_OUT_OF_RANGE\nThe specified value is out of range." } - { HEX: 1058 "HPDF_STREAM_EOF\nUnexpected EOF marker was detected." } - { HEX: 1059 "HPDF_STREAM_READLN_CONTINUE\nInternal error. The consistency of the data was lost." } - { HEX: 105B "HPDF_STRING_OUT_OF_RANGE\nThe length of the specified text is too long." } - { HEX: 105C "HPDF_THIS_FUNC_WAS_SKIPPED\nThe execution of a function was skipped because of other errors." } - { HEX: 105D "HPDF_TTF_CANNOT_EMBEDDING_FONT\nThis font cannot be embedded. (restricted by license.)" } - { HEX: 105E "HPDF_TTF_INVALID_CMAP\nUnsupported ttf format. (cannot find unicode cmap.)" } - { HEX: 105F "HPDF_TTF_INVALID_FOMAT\nUnsupported ttf format." } - { HEX: 1060 "HPDF_TTF_MISSING_TABLE\nUnsupported ttf format. (cannot find a necessary table.)" } - { HEX: 1061 "HPDF_UNSUPPORTED_FONT_TYPE\nInternal error. The consistency of the data was lost." } - { HEX: 1062 "HPDF_UNSUPPORTED_FUNC\n1. The library is not configured to use PNGLIB.\n2. Internal error. The consistency of the data was lost." } - { HEX: 1063 "HPDF_UNSUPPORTED_JPEG_FORMAT\nUnsupported Jpeg format." } - { HEX: 1064 "HPDF_UNSUPPORTED_TYPE1_FONT\nFailed to parse .PFB file." } - { HEX: 1065 "HPDF_XREF_COUNT_ERR\nInternal error. The consistency of the data was lost." } - { HEX: 1066 "HPDF_ZLIB_ERROR\nAn error has occurred while executing a function of Zlib." } - { HEX: 1067 "HPDF_INVALID_PAGE_INDEX\nAn error returned from Zlib." } - { HEX: 1068 "HPDF_INVALID_URI\nAn invalid URI was set." } - { HEX: 1069 "HPDF_PAGELAYOUT_OUT_OF_RANGE\nAn invalid page-layout was set." } - { HEX: 1070 "HPDF_PAGEMODE_OUT_OF_RANGE\nAn invalid page-mode was set." } - { HEX: 1071 "HPDF_PAGENUM_STYLE_OUT_OF_RANGE\nAn invalid page-num-style was set." } - { HEX: 1072 "HPDF_ANNOT_INVALID_ICON\nAn invalid icon was set." } - { HEX: 1073 "HPDF_ANNOT_INVALID_BORDER_STYLE\nAn invalid border-style was set." } - { HEX: 1074 "HPDF_PAGE_INVALID_DIRECTION\nAn invalid page-direction was set." } - { HEX: 1075 "HPDF_INVALID_FONT\nAn invalid font-handle was specified." } -} ; - -LIBRARY: libhpdf - -! =============================================== -! hpdf.h -! =============================================== - -FUNCTION: void* HPDF_New ( void* user_error_fn, void* user_data ) ; - -FUNCTION: void* HPDF_Free ( void* pdf ) ; - -FUNCTION: ulong HPDF_SetCompressionMode ( void* pdf, uint mode ) ; - -FUNCTION: ulong HPDF_SetPageMode ( void* pdf, uint mode ) ; - -FUNCTION: void* HPDF_AddPage ( void* pdf ) ; - -FUNCTION: ulong HPDF_SaveToFile ( void* pdf, char* file_name ) ; - -FUNCTION: float HPDF_Page_GetHeight ( void* page ) ; - -FUNCTION: float HPDF_Page_GetWidth ( void* page ) ; - -FUNCTION: ulong HPDF_Page_SetLineWidth ( void* page, float line_width ) ; - -FUNCTION: ulong HPDF_Page_Rectangle ( void* page, float x, float y, - float width, float height ) ; - -FUNCTION: ulong HPDF_Page_Stroke ( void* page ) ; - -FUNCTION: void* HPDF_GetFont ( void* pdf, char* font_name, - char* encoding_name ) ; - -FUNCTION: ulong HPDF_Page_SetFontAndSize ( void* page, void* font, - float size ) ; - -FUNCTION: float HPDF_Page_TextWidth ( void* page, char* text ) ; - -FUNCTION: ulong HPDF_Page_BeginText ( void* page ) ; - -FUNCTION: ulong HPDF_Page_TextOut ( void* page, float xpos, float ypos, - char* text ) ; - -FUNCTION: ulong HPDF_Page_EndText ( void* page ) ; - -FUNCTION: ulong HPDF_Page_MoveTextPos ( void* page, float x, float y ) ; - -FUNCTION: ulong HPDF_Page_ShowText ( void* page, char* text ) ; diff --git a/extra/pdf/pdf-tests.factor b/extra/pdf/pdf-tests.factor deleted file mode 100755 index 290773a89d..0000000000 --- a/extra/pdf/pdf-tests.factor +++ /dev/null @@ -1,98 +0,0 @@ -USING: io.files kernel math namespaces pdf pdf.libhpdf prettyprint sequences ; -IN: pdf.tests - -SYMBOL: font - -SYMBOL: width -SYMBOL: height -SYMBOL: twidth - -: font-list ( -- seq ) { - "Courier" - "Courier-Bold" - "Courier-Oblique" - "Courier-BoldOblique" - "Helvetica" - "Helvetica-Bold" - "Helvetica-Oblique" - "Helvetica-BoldOblique" - "Times-Roman" - "Times-Bold" - "Times-Italic" - "Times-BoldItalic" - "Symbol" - "ZapfDingbats" -} ; - -[ - ! HPDF_COMP_ALL set-compression-mode - - ! HPDF_PAGE_MODE_USE_OUTLINE set-page-mode - - ! Add a new page object - add-page - - get-page-height height set - - get-page-width width set - - ! Print the lines of the page - 1 set-page-line-width - - 50 50 width get 100 - height get 110 - page-rectangle - - page-stroke - - ! Print the title of the page (with positioning center) - "Helvetica" f get-font font set - - font get 24 set-page-font-and-size - - "Font Demo" page-text-width twidth set - - [ - width get twidth get - 2 / height get 50 - "Font Demo" page-text-out - - ] with-text - - ! Print subtitle - [ - font get 16 set-page-font-and-size - - 60 height get 80 - "" page-text-out - - ] with-text - - ! Print font list - [ - 60 height get 105 - page-move-text-pos - - SYMBOL: fontname - - font-list [ - - fontname set - - fontname get f get-font font set - - ! print a label of text - font get 9 set-page-font-and-size - - fontname get page-show-text - - 0 -18 page-move-text-pos - - ! print a sample text - font get 20 set-page-font-and-size - - "abcdefgABCDEFG12345!#$%&+-@?" page-show-text - - 0 -20 page-move-text-pos - - ] each - - ] with-text - - "font_test.pdf" temp-file save-to-file - -] with-pdf diff --git a/extra/pdf/pdf.factor b/extra/pdf/pdf.factor deleted file mode 100644 index 98c94e5de1..0000000000 --- a/extra/pdf/pdf.factor +++ /dev/null @@ -1,97 +0,0 @@ -! Copyright (C) 2007 Elie CHAFTARI -! See http://factorcode.org/license.txt for BSD license. -! -! Tested with libharu2 2.0.8 on Mac OS X 10.4.9 PowerPC - -USING: assocs continuations hashtables kernel math namespaces pdf.libhpdf ; - -IN: pdf - -SYMBOL: pdf -SYMBOL: page - -! ========================================================= -! Error handling routines -! ========================================================= - -: check-status ( status -- ) - dup zero? [ - drop - ] [ - error-code >hashtable at throw - ] if ; - -! ========================================================= -! Document handling routines -! ========================================================= - -: new-pdf ( error-handler user-data -- ) - HPDF_New pdf set ; - -: free-pdf ( -- ) - pdf get HPDF_Free drop ; - -: with-pdf ( quot -- ) - [ f f new-pdf [ free-pdf ] [ ] cleanup ] with-scope ; inline - -: set-compression-mode ( mode -- ) - pdf get swap HPDF_SetCompressionMode check-status ; - -: set-page-mode ( mode -- ) - pdf get swap HPDF_SetPageMode check-status ; - -: add-page ( -- ) - pdf get HPDF_AddPage page set ; - -: save-to-file ( filename -- ) - pdf get swap HPDF_SaveToFile check-status ; - -: get-font ( fontname encoding -- font ) - pdf get -rot HPDF_GetFont ; - -! ========================================================= -! Page Handling routines -! ========================================================= - -: get-page-height ( -- height ) - page get HPDF_Page_GetHeight ; - -: get-page-width ( -- width ) - page get HPDF_Page_GetWidth ; - -: page-text-width ( text -- width ) - page get swap HPDF_Page_TextWidth ; - -! ========================================================= -! Graphics routines -! ========================================================= - -: set-page-line-width ( linewidth -- ) - page get swap HPDF_Page_SetLineWidth check-status ; - -: page-rectangle ( x y width height -- ) - >r >r >r >r page get r> r> r> r> HPDF_Page_Rectangle check-status ; - -: page-stroke ( -- ) - page get HPDF_Page_Stroke check-status ; - -: set-page-font-and-size ( font size -- ) - page get -rot HPDF_Page_SetFontAndSize check-status ; - -: page-begin-text ( -- ) - page get HPDF_Page_BeginText check-status ; - -: page-text-out ( xpos ypos text -- ) - page get -roll HPDF_Page_TextOut check-status ; - -: page-end-text ( -- ) - page get HPDF_Page_EndText check-status ; - -: with-text ( -- ) - [ page-begin-text [ page-end-text ] [ ] cleanup ] with-scope ; inline - -: page-move-text-pos ( x y -- ) - page get -rot HPDF_Page_MoveTextPos check-status ; - -: page-show-text ( text -- ) - page get swap HPDF_Page_ShowText check-status ; diff --git a/extra/pdf/readme.txt b/extra/pdf/readme.txt deleted file mode 100644 index fd52944520..0000000000 --- a/extra/pdf/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To build libharu as a shared dylib on Mac OS X, modify the Makefile after calling ./configure --shared Here are the relevant sections and the lines to be changed: ... CC=cc PREFIX=/usr/local LIBNAME=libhpdf.a SONAME=libhpdf.dylib SOVER1=.1 SOVER2=.0.0 LIBTARGET=libhpdf.dylib CFLAGS=-Iinclude -fPIC -fno-common -c ... $(SONAME): $(OBJS) $(CC) -dynamiclib -o $(SONAME)$(SOVER1)$(SOVER2) $(OBJS) $(LDFLAGS) -Wl ln -sf $(SONAME)$(SOVER1)$(SOVER2) $(SONAME)$(SOVER1) ln -sf $(SONAME)$(SOVER1) $(SONAME) - -Now you can build and install: - -make clean -make -make install - -Test PDF files from pdf-tests.factor are generated in the test folder. \ No newline at end of file diff --git a/unmaintained/pdf/authors.txt b/unmaintained/pdf/authors.txt new file mode 100644 index 0000000000..7c29e7c401 --- /dev/null +++ b/unmaintained/pdf/authors.txt @@ -0,0 +1 @@ +Elie Chaftari diff --git a/unmaintained/pdf/libhpdf/libhpdf.factor b/unmaintained/pdf/libhpdf/libhpdf.factor new file mode 100644 index 0000000000..a40b7cddee --- /dev/null +++ b/unmaintained/pdf/libhpdf/libhpdf.factor @@ -0,0 +1,180 @@ +! Copyright (C) 2007 Elie CHAFTARI +! See http://factorcode.org/license.txt for BSD license. +! +! Tested with libharu2 2.0.8 on Mac OS X 10.4.9 PowerPC +! +! export LD_LIBRARY_PATH=/opt/local/lib + +USING: alien alien.syntax combinators system ; + +IN: pdf.libhpdf + +<< "libhpdf" { + { [ win32? ] [ "libhpdf.dll" "stdcall" ] } + { [ macosx? ] [ "libhpdf.dylib" "cdecl" ] } + { [ unix? ] [ "$LD_LIBRARY_PATH/libhpdf.so" "cdecl" ] } +} cond add-library >> + +! compression mode +: HPDF_COMP_NONE HEX: 00 ; inline ! No contents are compressed +: HPDF_COMP_TEXT HEX: 01 ; inline ! Compress contents stream of page +: HPDF_COMP_IMAGE HEX: 02 ; inline ! Compress streams of image objects +: HPDF_COMP_METADATA HEX: 04 ; inline ! Compress other data (fonts, cmaps...) +: HPDF_COMP_ALL HEX: 0F ; inline ! All stream data are compressed +: HPDF_COMP_MASK HEX: FF ; inline + +! page mode +C-ENUM: + HPDF_PAGE_MODE_USE_NONE + HPDF_PAGE_MODE_USE_OUTLINE + HPDF_PAGE_MODE_USE_THUMBS + HPDF_PAGE_MODE_FULL_SCREEN + HPDF_PAGE_MODE_EOF +; + +: error-code ( -- seq ) { + { HEX: 1001 "HPDF_ARRAY_COUNT_ERR\nInternal error. The consistency of the data was lost." } + { HEX: 1002 "HPDF_ARRAY_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } + { HEX: 1003 "HPDF_ARRAY_ITEM_UNEXPECTED_TYPE\nInternal error. The consistency of the data was lost." } + { HEX: 1004 "HPDF_BINARY_LENGTH_ERR\nThe length of the data exceeds HPDF_LIMIT_MAX_STRING_LEN." } + { HEX: 1005 "HPDF_CANNOT_GET_PALLET\nCannot get a pallet data from PNG image." } + { HEX: 1007 "HPDF_DICT_COUNT_ERR\nThe count of elements of a dictionary exceeds HPDF_LIMIT_MAX_DICT_ELEMENT" } + { HEX: 1008 "HPDF_DICT_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } + { HEX: 1009 "HPDF_DICT_ITEM_UNEXPECTED_TYPE\nInternal error. The consistency of the data was lost." } + { HEX: 100A "HPDF_DICT_STREAM_LENGTH_NOT_FOUND\nInternal error. The consistency of the data was lost." } + { HEX: 100B "HPDF_DOC_ENCRYPTDICT_NOT_FOUND\nHPDF_SetPermission() OR HPDF_SetEncryptMode() was called before a password is set." } + { HEX: 100C "HPDF_DOC_INVALID_OBJECT\nInternal error. The consistency of the data was lost." } + { HEX: 100E "HPDF_DUPLICATE_REGISTRATION\nTried to register a font that has been registered." } + { HEX: 100F "HPDF_EXCEED_JWW_CODE_NUM_LIMIT\nCannot register a character to the japanese word wrap characters list." } + { HEX: 1011 "HPDF_ENCRYPT_INVALID_PASSWORD\nTried to set the owner password to NULL. owner password and user password is the same." } + { HEX: 1013 "HPDF_ERR_UNKNOWN_CLASS\nInternal error. The consistency of the data was lost." } + { HEX: 1014 "HPDF_EXCEED_GSTATE_LIMIT\nThe depth of the stack exceeded HPDF_LIMIT_MAX_GSTATE." } + { HEX: 1015 "HPDF_FAILED_TO_ALLOC_MEM\nMemory allocation failed." } + { HEX: 1016 "HPDF_FILE_IO_ERROR\nFile processing failed. (A detailed code is set.)" } + { HEX: 1017 "HPDF_FILE_OPEN_ERROR\nCannot open a file. (A detailed code is set.)" } + { HEX: 1019 "HPDF_FONT_EXISTS\nTried to load a font that has already been registered." } + { HEX: 101A "HPDF_FONT_INVALID_WIDTHS_TABLE\nThe format of a font-file is invalid . Internal error. The consistency of the data was lost." } + { HEX: 101B "HPDF_INVALID_AFM_HEADER\nCannot recognize a header of an afm file." } + { HEX: 101C "HPDF_INVALID_ANNOTATION\nThe specified annotation handle is invalid." } + { HEX: 101E "HPDF_INVALID_BIT_PER_COMPONENT\nBit-per-component of a image which was set as mask-image is invalid." } + { HEX: 101F "HPDF_INVALID_CHAR_MATRICS_DATA\nCannot recognize char-matrics-data of an afm file." } + { HEX: 1020 "HPDF_INVALID_COLOR_SPACE\n1. The color_space parameter of HPDF_LoadRawImage is invalid.\n2. Color-space of a image which was set as mask-image is invalid.\n3. The function which is invalid in the present color-space was invoked." } + { HEX: 1021 "HPDF_INVALID_COMPRESSION_MODE\nInvalid value was set when invoking HPDF_SetCommpressionMode()." } + { HEX: 1022 "HPDF_INVALID_DATE_TIME\nAn invalid date-time value was set." } + { HEX: 1023 "HPDF_INVALID_DESTINATION\nAn invalid destination handle was set." } + { HEX: 1025 "HPDF_INVALID_DOCUMENT\nAn invalid document handle is set." } + { HEX: 1026 "HPDF_INVALID_DOCUMENT_STATE\nThe function which is invalid in the present state was invoked." } + { HEX: 1027 "HPDF_INVALID_ENCODER\nAn invalid encoder handle was set." } + { HEX: 1028 "HPDF_INVALID_ENCODER_TYPE\nA combination between font and encoder is wrong." } + { HEX: 102B "HPDF_INVALID_ENCODING_NAME\nAn Invalid encoding name is specified." } + { HEX: 102C "HPDF_INVALID_ENCRYPT_KEY_LEN\nThe lengh of the key of encryption is invalid." } + { HEX: 102D "HPDF_INVALID_FONTDEF_DATA\n1. An invalid font handle was set.\n2. Unsupported font format." } + { HEX: 102E "HPDF_INVALID_FONTDEF_TYPE\nInternal error. The consistency of the data was lost." } + { HEX: 102F "HPDF_INVALID_FONT_NAME\nA font which has the specified name is not found." } + { HEX: 1030 "HPDF_INVALID_IMAGE\nUnsupported image format." } + { HEX: 1031 "HPDF_INVALID_JPEG_DATA\nUnsupported image format." } + { HEX: 1032 "HPDF_INVALID_N_DATA\nCannot read a postscript-name from an afm file." } + { HEX: 1033 "HPDF_INVALID_OBJECT\n1. An invalid object is set.\n2. Internal error. The consistency of the data was lost." } + { HEX: 1034 "HPDF_INVALID_OBJ_ID\nInternal error. The consistency of the data was lost." } + { HEX: 1035 "HPDF_INVALID_OPERATION\nInvoked HPDF_Image_SetColorMask() against the image-object which was set a mask-image." } + { HEX: 1036 "HPDF_INVALID_OUTLINE\nAn invalid outline-handle was specified." } + { HEX: 1037 "HPDF_INVALID_PAGE\nAn invalid page-handle was specified." } + { HEX: 1038 "HPDF_INVALID_PAGES\nAn invalid pages-handle was specified. (internal error)" } + { HEX: 1039 "HPDF_INVALID_PARAMETER\nAn invalid value is set." } + { HEX: 103B "HPDF_INVALID_PNG_IMAGE\nInvalid PNG image format." } + { HEX: 103C "HPDF_INVALID_STREAM\nInternal error. The consistency of the data was lost." } + { HEX: 103D "HPDF_MISSING_FILE_NAME_ENTRY\nInternal error. The \"_FILE_NAME\" entry for delayed loading is missing." } + { HEX: 103F "HPDF_INVALID_TTC_FILE\nInvalid .TTC file format." } + { HEX: 1040 "HPDF_INVALID_TTC_INDEX\nThe index parameter was exceed the number of included fonts" } + { HEX: 1041 "HPDF_INVALID_WX_DATA\nCannot read a width-data from an afm file." } + { HEX: 1042 "HPDF_ITEM_NOT_FOUND\nInternal error. The consistency of the data was lost." } + { HEX: 1043 "HPDF_LIBPNG_ERROR\nAn error has returned from PNGLIB while loading an image." } + { HEX: 1044 "HPDF_NAME_INVALID_VALUE\nInternal error. The consistency of the data was lost." } + { HEX: 1045 "HPDF_NAME_OUT_OF_RANGE\nInternal error. The consistency of the data was lost." } + { HEX: 1049 "HPDF_PAGES_MISSING_KIDS_ENTRY\nInternal error. The consistency of the data was lost." } + { HEX: 104A "HPDF_PAGE_CANNOT_FIND_OBJECT\nInternal error. The consistency of the data was lost." } + { HEX: 104B "HPDF_PAGE_CANNOT_GET_ROOT_PAGES\nInternal error. The consistency of the data was lost." } + { HEX: 104C "HPDF_PAGE_CANNOT_RESTORE_GSTATE\nThere are no graphics-states to be restored." } + { HEX: 104D "HPDF_PAGE_CANNOT_SET_PARENT\nInternal error. The consistency of the data was lost." } + { HEX: 104E "HPDF_PAGE_FONT_NOT_FOUND\nThe current font is not set." } + { HEX: 104F "HPDF_PAGE_INVALID_FONT\nAn invalid font-handle was specified." } + { HEX: 1050 "HPDF_PAGE_INVALID_FONT_SIZE\nAn invalid font-size was set." } + { HEX: 1051 "HPDF_PAGE_INVALID_GMODE\nSee Graphics mode." } + { HEX: 1052 "HPDF_PAGE_INVALID_INDEX\nInternal error. The consistency of the data was lost." } + { HEX: 1053 "HPDF_PAGE_INVALID_ROTATE_VALUE\nThe specified value is not a multiple of 90." } + { HEX: 1054 "HPDF_PAGE_INVALID_SIZE\nAn invalid page-size was set." } + { HEX: 1055 "HPDF_PAGE_INVALID_XOBJECT\nAn invalid image-handle was set." } + { HEX: 1056 "HPDF_PAGE_OUT_OF_RANGE\nThe specified value is out of range." } + { HEX: 1057 "HPDF_REAL_OUT_OF_RANGE\nThe specified value is out of range." } + { HEX: 1058 "HPDF_STREAM_EOF\nUnexpected EOF marker was detected." } + { HEX: 1059 "HPDF_STREAM_READLN_CONTINUE\nInternal error. The consistency of the data was lost." } + { HEX: 105B "HPDF_STRING_OUT_OF_RANGE\nThe length of the specified text is too long." } + { HEX: 105C "HPDF_THIS_FUNC_WAS_SKIPPED\nThe execution of a function was skipped because of other errors." } + { HEX: 105D "HPDF_TTF_CANNOT_EMBEDDING_FONT\nThis font cannot be embedded. (restricted by license.)" } + { HEX: 105E "HPDF_TTF_INVALID_CMAP\nUnsupported ttf format. (cannot find unicode cmap.)" } + { HEX: 105F "HPDF_TTF_INVALID_FOMAT\nUnsupported ttf format." } + { HEX: 1060 "HPDF_TTF_MISSING_TABLE\nUnsupported ttf format. (cannot find a necessary table.)" } + { HEX: 1061 "HPDF_UNSUPPORTED_FONT_TYPE\nInternal error. The consistency of the data was lost." } + { HEX: 1062 "HPDF_UNSUPPORTED_FUNC\n1. The library is not configured to use PNGLIB.\n2. Internal error. The consistency of the data was lost." } + { HEX: 1063 "HPDF_UNSUPPORTED_JPEG_FORMAT\nUnsupported Jpeg format." } + { HEX: 1064 "HPDF_UNSUPPORTED_TYPE1_FONT\nFailed to parse .PFB file." } + { HEX: 1065 "HPDF_XREF_COUNT_ERR\nInternal error. The consistency of the data was lost." } + { HEX: 1066 "HPDF_ZLIB_ERROR\nAn error has occurred while executing a function of Zlib." } + { HEX: 1067 "HPDF_INVALID_PAGE_INDEX\nAn error returned from Zlib." } + { HEX: 1068 "HPDF_INVALID_URI\nAn invalid URI was set." } + { HEX: 1069 "HPDF_PAGELAYOUT_OUT_OF_RANGE\nAn invalid page-layout was set." } + { HEX: 1070 "HPDF_PAGEMODE_OUT_OF_RANGE\nAn invalid page-mode was set." } + { HEX: 1071 "HPDF_PAGENUM_STYLE_OUT_OF_RANGE\nAn invalid page-num-style was set." } + { HEX: 1072 "HPDF_ANNOT_INVALID_ICON\nAn invalid icon was set." } + { HEX: 1073 "HPDF_ANNOT_INVALID_BORDER_STYLE\nAn invalid border-style was set." } + { HEX: 1074 "HPDF_PAGE_INVALID_DIRECTION\nAn invalid page-direction was set." } + { HEX: 1075 "HPDF_INVALID_FONT\nAn invalid font-handle was specified." } +} ; + +LIBRARY: libhpdf + +! =============================================== +! hpdf.h +! =============================================== + +FUNCTION: void* HPDF_New ( void* user_error_fn, void* user_data ) ; + +FUNCTION: void* HPDF_Free ( void* pdf ) ; + +FUNCTION: ulong HPDF_SetCompressionMode ( void* pdf, uint mode ) ; + +FUNCTION: ulong HPDF_SetPageMode ( void* pdf, uint mode ) ; + +FUNCTION: void* HPDF_AddPage ( void* pdf ) ; + +FUNCTION: ulong HPDF_SaveToFile ( void* pdf, char* file_name ) ; + +FUNCTION: float HPDF_Page_GetHeight ( void* page ) ; + +FUNCTION: float HPDF_Page_GetWidth ( void* page ) ; + +FUNCTION: ulong HPDF_Page_SetLineWidth ( void* page, float line_width ) ; + +FUNCTION: ulong HPDF_Page_Rectangle ( void* page, float x, float y, + float width, float height ) ; + +FUNCTION: ulong HPDF_Page_Stroke ( void* page ) ; + +FUNCTION: void* HPDF_GetFont ( void* pdf, char* font_name, + char* encoding_name ) ; + +FUNCTION: ulong HPDF_Page_SetFontAndSize ( void* page, void* font, + float size ) ; + +FUNCTION: float HPDF_Page_TextWidth ( void* page, char* text ) ; + +FUNCTION: ulong HPDF_Page_BeginText ( void* page ) ; + +FUNCTION: ulong HPDF_Page_TextOut ( void* page, float xpos, float ypos, + char* text ) ; + +FUNCTION: ulong HPDF_Page_EndText ( void* page ) ; + +FUNCTION: ulong HPDF_Page_MoveTextPos ( void* page, float x, float y ) ; + +FUNCTION: ulong HPDF_Page_ShowText ( void* page, char* text ) ; diff --git a/unmaintained/pdf/pdf-tests.factor b/unmaintained/pdf/pdf-tests.factor new file mode 100755 index 0000000000..290773a89d --- /dev/null +++ b/unmaintained/pdf/pdf-tests.factor @@ -0,0 +1,98 @@ +USING: io.files kernel math namespaces pdf pdf.libhpdf prettyprint sequences ; +IN: pdf.tests + +SYMBOL: font + +SYMBOL: width +SYMBOL: height +SYMBOL: twidth + +: font-list ( -- seq ) { + "Courier" + "Courier-Bold" + "Courier-Oblique" + "Courier-BoldOblique" + "Helvetica" + "Helvetica-Bold" + "Helvetica-Oblique" + "Helvetica-BoldOblique" + "Times-Roman" + "Times-Bold" + "Times-Italic" + "Times-BoldItalic" + "Symbol" + "ZapfDingbats" +} ; + +[ + ! HPDF_COMP_ALL set-compression-mode + + ! HPDF_PAGE_MODE_USE_OUTLINE set-page-mode + + ! Add a new page object + add-page + + get-page-height height set + + get-page-width width set + + ! Print the lines of the page + 1 set-page-line-width + + 50 50 width get 100 - height get 110 - page-rectangle + + page-stroke + + ! Print the title of the page (with positioning center) + "Helvetica" f get-font font set + + font get 24 set-page-font-and-size + + "Font Demo" page-text-width twidth set + + [ + width get twidth get - 2 / height get 50 - "Font Demo" page-text-out + + ] with-text + + ! Print subtitle + [ + font get 16 set-page-font-and-size + + 60 height get 80 - "" page-text-out + + ] with-text + + ! Print font list + [ + 60 height get 105 - page-move-text-pos + + SYMBOL: fontname + + font-list [ + + fontname set + + fontname get f get-font font set + + ! print a label of text + font get 9 set-page-font-and-size + + fontname get page-show-text + + 0 -18 page-move-text-pos + + ! print a sample text + font get 20 set-page-font-and-size + + "abcdefgABCDEFG12345!#$%&+-@?" page-show-text + + 0 -20 page-move-text-pos + + ] each + + ] with-text + + "font_test.pdf" temp-file save-to-file + +] with-pdf diff --git a/unmaintained/pdf/pdf.factor b/unmaintained/pdf/pdf.factor new file mode 100644 index 0000000000..98c94e5de1 --- /dev/null +++ b/unmaintained/pdf/pdf.factor @@ -0,0 +1,97 @@ +! Copyright (C) 2007 Elie CHAFTARI +! See http://factorcode.org/license.txt for BSD license. +! +! Tested with libharu2 2.0.8 on Mac OS X 10.4.9 PowerPC + +USING: assocs continuations hashtables kernel math namespaces pdf.libhpdf ; + +IN: pdf + +SYMBOL: pdf +SYMBOL: page + +! ========================================================= +! Error handling routines +! ========================================================= + +: check-status ( status -- ) + dup zero? [ + drop + ] [ + error-code >hashtable at throw + ] if ; + +! ========================================================= +! Document handling routines +! ========================================================= + +: new-pdf ( error-handler user-data -- ) + HPDF_New pdf set ; + +: free-pdf ( -- ) + pdf get HPDF_Free drop ; + +: with-pdf ( quot -- ) + [ f f new-pdf [ free-pdf ] [ ] cleanup ] with-scope ; inline + +: set-compression-mode ( mode -- ) + pdf get swap HPDF_SetCompressionMode check-status ; + +: set-page-mode ( mode -- ) + pdf get swap HPDF_SetPageMode check-status ; + +: add-page ( -- ) + pdf get HPDF_AddPage page set ; + +: save-to-file ( filename -- ) + pdf get swap HPDF_SaveToFile check-status ; + +: get-font ( fontname encoding -- font ) + pdf get -rot HPDF_GetFont ; + +! ========================================================= +! Page Handling routines +! ========================================================= + +: get-page-height ( -- height ) + page get HPDF_Page_GetHeight ; + +: get-page-width ( -- width ) + page get HPDF_Page_GetWidth ; + +: page-text-width ( text -- width ) + page get swap HPDF_Page_TextWidth ; + +! ========================================================= +! Graphics routines +! ========================================================= + +: set-page-line-width ( linewidth -- ) + page get swap HPDF_Page_SetLineWidth check-status ; + +: page-rectangle ( x y width height -- ) + >r >r >r >r page get r> r> r> r> HPDF_Page_Rectangle check-status ; + +: page-stroke ( -- ) + page get HPDF_Page_Stroke check-status ; + +: set-page-font-and-size ( font size -- ) + page get -rot HPDF_Page_SetFontAndSize check-status ; + +: page-begin-text ( -- ) + page get HPDF_Page_BeginText check-status ; + +: page-text-out ( xpos ypos text -- ) + page get -roll HPDF_Page_TextOut check-status ; + +: page-end-text ( -- ) + page get HPDF_Page_EndText check-status ; + +: with-text ( -- ) + [ page-begin-text [ page-end-text ] [ ] cleanup ] with-scope ; inline + +: page-move-text-pos ( x y -- ) + page get -rot HPDF_Page_MoveTextPos check-status ; + +: page-show-text ( text -- ) + page get swap HPDF_Page_ShowText check-status ; diff --git a/unmaintained/pdf/readme.txt b/unmaintained/pdf/readme.txt new file mode 100644 index 0000000000..fd52944520 --- /dev/null +++ b/unmaintained/pdf/readme.txt @@ -0,0 +1,9 @@ +To build libharu as a shared dylib on Mac OS X, modify the Makefile after calling ./configure --shared Here are the relevant sections and the lines to be changed: ... CC=cc PREFIX=/usr/local LIBNAME=libhpdf.a SONAME=libhpdf.dylib SOVER1=.1 SOVER2=.0.0 LIBTARGET=libhpdf.dylib CFLAGS=-Iinclude -fPIC -fno-common -c ... $(SONAME): $(OBJS) $(CC) -dynamiclib -o $(SONAME)$(SOVER1)$(SOVER2) $(OBJS) $(LDFLAGS) -Wl ln -sf $(SONAME)$(SOVER1)$(SOVER2) $(SONAME)$(SOVER1) ln -sf $(SONAME)$(SOVER1) $(SONAME) + +Now you can build and install: + +make clean +make +make install + +Test PDF files from pdf-tests.factor are generated in the test folder. \ No newline at end of file