tclhpdfDoc(1) 0.1.0 "tclhpdf Doc Handler"
tclhpdfDoc - tclhpdf Doc Handler
TABLE OF CONTENTS
SYNOPSIS
DESCRIPTION
COMMANDS
REFERENCE
SEE ALSO
KEYWORDS
COPYRIGHT
The Doc handler command have subcommands to control pdf document.
- hpdfDocObj newDoc
-
newDoc creates new document. If document object already has a document, the current document is revoked.
- hpdfDocObj freeDoc
-
- hpdfDocObj freeDocAll
-
freeDoc, freeDocAll revokes the current document. freeDoc keeps loaded resource (such as fonts and encodings) and these resources are recycled when new document required these resources. freeDocAll revokes the current document and all resources.
- hpdfDocObj hasDoc
-
hasDoc returns 1, if current document object has valid document.
- hpdfDocObj saveToStream
-
saveToStream saves the current document to a temporary stream of a document object.
- hpdfDocObj getStreamSize
-
getStreamSize gets the size of the temporary stream of the document.
- hpdfDocObj readFromStream
-
readFromStream copies the data from the temporary stream of the document into the buffer.
- hpdfDocObj resetStream
-
resetStream rewinds the temporary stream of the document.
- hpdfDocObj saveToFile filename
-
saveToFile saves the current document to a file.
- hpdfDocObj setPagesConfiguration page_par_pages
-
In the default setting, a doc object has one "Pages" object as root of pages. All "Page" objects are created as a kid of the "Pages" object.
Since a "Pages" object can own only 8191 kids objects, the maximum number of pages are 8191 page.
Additionally, the state that there are a lot of "Page" object under one "Pages" object is not good, because it causes performance degradation of a viewer application.
An application can change the setting of a pages tree by invoking setPagesConfiguration. If page_per_pages parameter is set to more than zero, a two-tier pages tree is created. A root "Pages" object can own 8191 "Pages" object, and each lower "Pages" object can own page_per_pages "Page" objects. As a result, the maximum number of pages becomes 8191 * page_per_pages page.
An application cannot invoke setPageConfiguration after a page is added to document.
- hpdfDocObj getPageLayout
-
getPageLayout returns the current setting for page layout.
- hpdfDocObj setPageLayout layout
-
setPageLayout sets how the page should be displayed. If this attribute is not set, the setting of a viewer application is used.
The following values are available for layout.
- single
-
Only one page is displayed.
- one_column
-
Display the pages in one column.
- two_column_left
-
Display the pages in two column.
The page of the odd number is displayed left.
- two_column_right
-
Display the pages in two column.
The page of the odd number is displayed right.
- hpdfDocObj getPageMode
-
getPageMode returns the current setting for page mode.
- hpdfDocObj setPageMode mode
-
setPageMode sets how the document should be displayed.
The following values are available for mode.
- none
-
Display the document with neither outline nor thumbnail.
- outline
-
Display the document with outline pain.
- thumbs
-
Display the document with thumbnail pain.
- fullscreen
-
Display the document with full screen mode.
- hpdfDocObj getViewerPreference
-
getViewerPreference gets pdf viewer preference setting.
- hpdfDocObj setViewerPreference flags
-
setViewerPreference sets pdf viewer preference setting.
The following values are available for flags.
- hide_toolbar
-
Hide pdf viewer toolbar.
- hide_menubar
-
Hide pdf viewer menubar.
- hide_window_ui
-
Hide pdf viewer window ui.
- fit_window
-
Fit pdf viewer window.
- center_window
-
Move pdf viewer window center.
- hpdfDocObj setOpenAction hpdfDestinationObj
-
setOpenAction set the first page appears when a document is opened.
- hpdfDocObj getPageByIndex index
-
getPageByIndex returns the handle of a page object by pecified index.
- hpdfDocObj getCurrentPage
-
getPageLayout returns the handle of current page object.
- hpdfDocObj addPage
-
addPage creates a new page and adds it after the last page of a document. It returns the handle of a new page object.
- hpdfDocObj insertPage hpdfPageObj
-
insertPage creates a new page and inserts it just before the specified page. It returns the handle of a new page object.
- hpdfDocObj getFont fontname ?encodingname?
-
getFont gets the handle of a corresponding font object by specified name and encoding. It returns hpdfFontObj.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj loadType1FontFromFile afmfilename pfmfilename
-
loadType1FontFromFile loads a type1 font from an external file and register it to a document object. It returns hpdfFontObj.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj loadTTFontFromFile filename embedding
-
loadTTFontFromFile loads a TrueType font from an external file and register it to a document object. It returns hpdfFontObj.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj loadTTFontFromFile2 filename index embedding
-
loadTTFontFromFile2 loads a TrueType font from an TrueType collection file and register it to a document object. It returns hpdfFontObj.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj addPageLabel pagenum style firstpage prefix
-
addPageLabel adds a page labeling range for the document.
The following values are available for style.
- decimal
-
Page label is displayed by Arabic numerals.
- upper_roman
-
Page label is displayed by Uppercase roman numerals.
- lower_roman
-
Page label is displayed by Lowercase roman numerals.
- upper_letters
-
Page label is displayed by Uppercase letters (using A to Z).
- lower_letters
-
Page label is displayed by Lowercase letters (using a to z).
- hpdfDocObj useJPFonts
-
useJPFonts enables Japanese fonts. After useJPFonts is involed, an application can use the following Japanese fonts.
- MS-Mincyo
- MS-Mincyo,Bold
- MS-Mincyo,Italic
- MS-Mincyo,BoldItalic
- MS-Gothic
- MS-Gothic,Bold
- MS-Gothic,Italic
- MS-Gothic,BoldItalic
- MS-PMincyo
- MS-PMincyo,Bold
- MS-PMincyo,Italic
- MS-PMincyo,BoldItalic
- MS-PGothic
- MS-PGothic,Bold
- MS-PGothic,Italic
- MS-PGothic,BoldItalic
- hpdfDocObj useKRFonts
-
useKRFonts enables Korean fonts. After useKRFonts is involed, an application can use the following Korean fonts.
- DotumChe
- DotumChe,Bold
- DotumChe,Italic
- DotumChe,BoldItalic
- Dotum
- Dotum,Bold
- Dotum,Italic
- Dotum,BoldItalic
- BatangChe
- BatangChe,Bold
- BatangChe,Italic
- BatangChe,BoldItalic
- Batang
- Batang,Bold
- Batang,Italic
- Batang,BoldItalic
- hpdfDocObj useCNSFonts
-
useCNSFonts enables simplified Chinese fonts. After useCNSFonts is involed, an application can use the following simplified Chinese fonts.
- SimSun
- SimSun,Bold
- SimSun,Italic
- SimSun,BoldItalic
- SimHei
- SimHei,Bold
- SimHei,Italic
- SimHei,BoldItalic
- hpdfDocObj useCNTFonts
-
useCNTFonts enables traditional Chinese fonts. After useCNTFonts is involed, an application can use the following traditional Chinese fonts.
- MingLiU
- MingLiU,Bold
- MingLiU,Italic
- MingLiU,BoldItalic
- hpdfDocObj createOutline parent title ?encoder?
-
createOutline creates a new outline object and returns it.
parent is the handle of an outline object which comes to the parent of the created outline object. If this parameter is empty string, The outline is created as a root outline.
title is the caption of the outline object.
encoder is the handle of an encoding object applied to the title. If empty string is set or omitted, default value is used.
- hpdfDocObj getEncoder encodingname
-
getEncoder gets the handle of a corresponding encoder object by specified encoding name.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj getCurrentEncoder
-
etCurrentEncoder gets the handle of the current encoder of the document object.
The current encoder is set by invoking setCurrentEncoder and it is used to processing a text when an application invoks setInfoAttr The default value of it is empty string.
See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj setCurrentEncoder encodingname
-
setCurrentEncoder sets the current encoder for the document.
encodingname is the name of an encoding. See also "Fonts and Encodings" in original libharu document.
- hpdfDocObj useJPEncodings
-
useJPEncodings enables Japanese encodings. After useJPEncodings is involed, an application can use the following Japanese encodings.
- 90ms-RKSJ-H
- 90ms-RKSJ-V
- 90msp-RKSJ-H
- EUC-H
- EUC-V
- hpdfDocObj useKREncodings
-
useKREncodings enables Korean encodings. After useKREncodings is involed, an application can use the following Korean encodings.
- KSC-EUC-H
- KSC-EUC-V
- KSCms-UHC-H
- KSCms-UHC-HW-H
- KSCms-UHC-HW-V
- hpdfDocObj useCNSEncodings
-
useCNSEncodings enables simplified Chinese encodings. After useCNSEncodings is involed, an application can use the following simplified Chinese encodings.
- GB-EUC-H
- GB-EUC-V
- GBK-EUC-H
- GBK-EUC-V
- hpdfDocObj useCNTEncodings
-
useCNTEncodings enables traditional Chinese encodings. After useCNTEncodings is involed, an application can use the following traditional Chinese encodings.
- GB-EUC-H
- GB-EUC-V
- GBK-EUC-H
- GBK-EUC-V
- hpdfDocObj loadPngImageFromFile filename
-
loadPngImageFromFile loads an external png image file.
It returns the handle of an image object.
- hpdfDocObj loadPngImageFromFile2 filename
-
loadPngImageFromFile2 loads an external png image file.
It returns the handle of an image object.
Unlike loadPngImageFromFile, loadPngImageFromFile2 does not load whole data immediately. (only size and color properties is loaded).
The main data is loaded just before the image object is written to PDF, and the loaded data is deleted immediately.
- hpdfDocObj loadJpegImageFromFile filename
-
loadJpegImageFromFile loads an external jpeg image file.
It returns the handle of an image object.
- hpdfDocObj loadRawImageFromFile filename width heifht colorspace
-
loadRawImageFromFile loads an image which has "raw" image format. This method loads the data without any conversion. So it is usually faster than the other functions.
filename is a path to a image file.
width is the width of an image file.
height is the height of an image file.
colorspace allows gray, rgb or cmyk.
loadRawImageFromFile can load 3 types of format described below.
- 8 bit gray scale image.
The gray scale describes one pixel by one byte. And the size of the image data is same as width * height.
The sequence of the data is as follows.
|
1 2 3 4
6 7 8 9
11 12 13 14
|
- 24bit RGB color image.
The 24bit RGB color image describes one pixel by 3 byte (each one byte describes a value of either red, green or blue). And the size of the image is same as width * height * 3.
The sequence of the data is as follows.
|
1 1 1 2 2 2 3 3 3 4 4 4
6 6 6 7 7 7 8 8 8 9 9 9
11 11 11 12 12 12 13 13 13 14 14 14
|
- 36bit CMYK color image.
The 36bit CMYK color image describes one pixel by 4 byte (each one byte describes a value of either Cyan Magenta Yellow Black). And the size of the image is same as width * height * 4.
The sequence of the data is as follows.
|
1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4
6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9
11 11 11 11 12 12 12 12 13 13 13 13 14 14 14 14
|
- hpdfDocObj loadRawImageFromMem buf width height colorspace bits_per_component
-
loadRawImageFromMem loads an image which has "raw" image format from buffer.
This method loads the data without any conversion. So it is usually faster than the other functions.
The formats that loadRawImageFromMem can load is the same as loadRawImageFromFile.
buf is the image data.
width is the width of an image file.
height is the height of an image file.
colorspace allows gray, rgb or cmyk.
bits_per_component is the bit size of each color component. The valid value is either 1, 2, 4, 8.
- hpdfDocObj setInfoAttr type value
-
setInfoAttr sets the text of the info dictionary. setInfoAttr uses the current encoding of the document. If it is not set, the default value will be used.
type allows author, creator, title, subject or keywords.
value is a text to set the infomation.
- hpdfDocObj getInfoAttr type
-
getInfoAttr gets the string value from info dictionary.
type allows creation_date, mod_date, author, creator, title, subject or keywords.
- hpdfDocObj setInfoDateAttr type year month day hour min sec tzind tzhour tzmin
-
setInfoDateAttr sets the datetime value to the info dictionary. I tried to use tclclock values, but tcl8.4 could not handle timezone well, so I give up to map tcl clock value.
type allows creation_date and mod_date.
year is year.
month must be between 1 and 12.
day must be between 1 and ether of 28, 29, 30, 31. (It is different by the month.)
hour must be between 0 to 23.
min must be between 0 to 59.
sec must be between 0 to 59.
tzind is the relationship of local time to Universal Time. " ", +, ?, and Z are available.
tzhour is the timezone hour. If tzind is not space, 0 to 23 is valid. Otherwise, this value is ignored.
tzmin is the timezone min. If ind is not space, 0 to 59 is valid. Otherwise, this value is ignored.
|
# 2007-09-22 16:37:45 +09:00
$pdf setInfoDateAttr 2007 9 22 16 37 45 + 9 0
|
- hpdfDocObj setPassword ownerpass ?userpass?
-
setPassword sets the pasword for the document.
If the password is set, contents in the document are encrypted.
owner_password is the password for the owner of the document. The owner can change the permission of the document. Empty string and the same value as user password are not allowed.
user_password is the password for the user of the document. The user_password is allowed to be set to empty string.
If type of owner_password and user_password values are bytearray, this function use the value as it is (bytearray). But if the type is not bytearray (string or any), the values are assumed as tcl native string(utf-8) and convert to external encoding(encoding system), then pass to hpdf functions. This may be a little confusion, but it is convenient to set another encoding strings.
- hpdfDocObj setPermission permission
-
setPermission set the flags of the permission for the document.
The following values are available for permission.
- read
-
user can read the document.
- print
-
user can print the document.
- edit_all
-
user can edit the contents of the document other than annotations, form fields.
- copy
-
user can copy the text and the graphics of the document.
- edit
-
user can add or modify the annotations and form fields of the document.
- hpdfDocObj setEncryptionMode mode keylen
-
setEncryptionMode set the type of encryption.
As the side effect, setEncryptionMode ups the version of PDF to 1.4 when the mode is set to r3.
mode specify which operations are permitted. This parameter is set by logical addition of the following values.
- r2 :
Use "Revision 2" algorithm.
The length of key is automatically set to 5(40bit).
- r3 :
Use "Revision 3" algorithm.
Between 5(40bit) and 16(128bit) can be specified for length of the key.
keylen specify the byte length of an encryption key. This parameter is valid only when "mode" parameter is set to r3. Between 5(40bit) and 16(128bit) can be specified for length of the key.
- hpdfDocObj setCompressionMode mode
-
setCompressionMode set the mode of compression.
The following values are available for mode.
- none
-
All contents are not compressed.
- text
-
Compress the contents stream of the page.
- image
-
Compress the streams of the image objects.
- metadata
-
Other stream datas (fonts, cmaps and so on) are compressed.
- all
-
All stream datas are compressed.
- hpdfDocObj createExtGState
-
createExtGState create hpdfExtGStateObj and return it.
tclhpdf, tclhpdfAnnotation, tclhpdfDescription, tclhpdfDoc, tclhpdfEncoder, tclhpdfExtGState, tclhpdfFont, tclhpdfImage, tclhpdfOutline, tclhpdfPage
pdf
Copyright © 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
Copyright © 2007 OHTSUKA, yoshio <ohtsuka.yoshio@gmail.com>