adultpdf.com Inc

# Image To PDF COM/SDK v3.1
(support Server/Client)
User Manual

#
Coordinate System

Before you can put any headers or text onto a PDF page, it's important that you understand the PDF Coordinate System UNITS Adobe defines a PDF file as using "User" space where 72 units in user space is equal to 1 inch. An 8 1/2" x 11" piece of paper would therefore be 612 units by 792 units.

##### ORIGIN AND POSITIONING

The origin (0,0) of a PDF document is in the top left hand corner, with Y increasing downwards and X increasing to the right. See the figure below:

#
Introduction

ImageToPDF is a application which can directly convert dozens of image formats, such as TIF, JPG, GIF, PNG, BMP, PSD, WMF, EMF, PDF, PCX, PIC and so on, into PDF format. ImageToPDF can automatically skew-correct B/W images by employing special techniques to insure high quality output after conversion. ImageToPDF can operate Adobe Acrobat independently and it has faster processing speed. If your application doesn't require OCR (Optical Character Recognition) functionality, ImageToPDF provides a very convenient, simple way to compose electronic books which can then be issued to the Web. You can scan paper documents directly to image files and then convert them to PDF using ImageToPDF.

Handles multipage-image files correctly by incorporating all images sequentially into PDF.
This is new software programs and utilities convert TIFF files (black and white and color) into exceptionally high quality PDF files with an excellent compression at a impressive speed and performance.
ImageToPDF is perfect for high-volume document archive/database systems that require unattended batch image conversions (TIFF or other images) to PDF format.

# Features

> > - Supports TIFF, JPG, PNG, PCD, PSD, TGA, BMP, DCX, EMF, WMF, text, etc. image formats.
> > - Supports virtually all TIFF compressions, including ZIP, LZW, CCITT G4/G3,JPEG, Packbits.
> > - Outstanding compression.
> > - Can combine multiple image files into one PDF file.
> > - Can merge and split single or multipage images files to pdf.
> > - Supports Multipage tiff file to PDF conversion.
> > - Does NOT need Adobe Acrobat software.
> > - Supports single file processing, single directory processing, multi-level directory processing and many other processing modes
> > - Can set automatic skew-correction (of B/W images).
> > - More mode convert. when batch converting, can multiple image files to a single PDF file, or each image file may be converted into individual PDF files.
> > - Make use of effective compression processing to minimize space occupied by the created PDF files; for example, an A4 size file with a B/W image the output size is about 40KB to 50KB per page; color and gray-scale images are also compressed and optimized.
> > - Page layout setting.
> > - Password protection for PDF files with 40 or 128 bit encryption.
> > - Set file permissions to restrict printing, copying, and future modifications to the document.
> > - Specify any resolution(DPI) in the generated PDF file.
> > - Optimized to increase speed.
> > - Set the document info (title, subject, author and keywords, creator).
> > - Append to existing PDFs.
> > - Supports watermark, bookmark, viewer setting.
> > - Images can be from memory or disk.
> > - Page orientation.

# Functions description

Note:
[SDK] = SDK function name
[COM] = COM function name

## [SDK] ApCreate
[COM] ApcCreate

long ApCreate(char * Filename)

### Description

Create a PDF file.

### Parameters

Filename

It is created file name.

### Return Value

Each of these functions returns a PDF File id for the Created file. A return value of 0 indicates an error, otherwise is succeed.

| follow is likely to cause of error information
| Parameter error.
| Create the PDF file failed.

## [SDK] ApOpen
[COM] ApcOpen

long ApOpen(char * Filename)

### Description

Open a PDF file.for append.

### Parameters

Filename

It is opened file name.

### Return Value

Each of these functions returns a PDF File id for the opened file. A return value of 0 indicates an error, otherwise is succeed.

| following is likely to be the cause of error information
| Parameter error.
| Open the PDF file failed.
| Encrypted PDF file.
| Version too low (must above PDF-1.1)
| Other abnormity.

## [SDK] ApClose
[COM]ApcClose

void ApClose(long id)

### Description

Close the opened PDF file.

### Parameters

id

Returned by ApCreate and ApOpen function.

### Return Value

None

## [SDK] ApAddImage
[COM]ApcAddImage

long ApAddImage(long id, char *filename)

### Description

Insert image file into an opened PDF file, supports bmp,dib,emf,gif,icon,jbig,jp2,jpeg,

pcd,pcx,pict,png,pnm,psd,rle,tga,tiff,wbmp,wmf,xbm and xpm format, this function also support multi-page TIFF file, if you want specify a page range in the multi-page TIFF file, you must call ApSetFunction (code = 101) to set the page range before you use this function, please refer to the ApSetFunction function for get more information.

### Parameters

id

Returned by ApCreate or ApOpen function.

filename

File name of image.

### Return Value

A return value of 0 indicates an error, otherwise is succeed. If its return is –1, it indicates the width or height is larger than 14400 pixel.

## [SDK] ApAddImageData
[COM]ApcAddImageData

long ApAddImageData(long id, char *data, long width, long height, long color)

### Description

Insert memory bitmap into PDF file.

### Parameters

id

Returned by ApCreate or ApOpen function.

data

Bitmap bits.

width

Specifies the width of the bitmap, in pixels.

height

Specifies the height of the bitmap, in pixels.

color

Specifies the number of bits per pixel.
1 : The bitmap is monochrome
8 : The bitmap has a maximum of 256 gray colors
24 : The bitmap has a maximum of 2^24 colors

### Return Value

Nonzero if it is successful; otherwise, it is zero.

### Remarks

The width of bitmap data must be aligning by 32 bits.

## [SDK] ApAddTextEx
[COM]ApcAddTextEx

long ApAddTextEx(long id, long x,long y, char *string,long color)

### Description

The ApAddTextEx function writes a character string at the specified location, using the currently selected font, text color, if x = y = -1, indicates the text string will be drawing at current text position, default text position is (64, 64). About font, etc, please refer to the ApSetFunction function for more information.

### Parameters

id

Returned by ApCreate or ApOpen function.

x

Specifies the logical x-coordinate of the reference point that the system uses to align the string, the x-coordinate will move automatically.

y

Specifies the logical y-coordinate of the reference point that the system uses to align the string, the y-coordinate will move automatically.

string

Pointer to the string to be drawn, this string may include “\n” symbol

color

Set text color, you may use RGB macro to combine this value.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApAddText
[COM]ApcAddText

long ApAddText(long id, long x, long y, long width,long height, char *string, long color ,long bkcolor, long lFormat)

### Description

The ApAddText function writes a character string in the specified rectangle , using the currently selected font, text color. About font, etc, please refer to the ApSetFunction function for more information.

### Parameters

id

Returned by ApCreate or ApOpen function.

x

Specifies the logical x-coordinate of the reference point that the system uses to align the string, the x-coordinate will move automatically.

y

Specifies the logical y-coordinate of the reference point that the system uses to align the string, the y-coordinate will move automatically.

width and height

Specifies rectangle width and height.

string

Pointer to the string to be drawn, this string may include “\n” symbol.

color

Set text color, you may use RGB macro to combine this value.

bkcolor

Set rectangle fill color, you may use RGB macro to combine this value.

If this value equal –1 then no fill color.

lFormat

Specifies the method of formatting the text. this parameter can be one or more of the following values.
0: Aligns text to the left.
1: Centers text horizontally in the rectangle.
2: Aligns text to the right.
16(hex: 10): Breaks words.
1024(hex: 400): Determines the width and height of the rectangle.
Note: It modifie the width and height, and return the width and height of the formatted text but does not draw the text. follow is special call :
ApAddText(id,x,y, (long)&width,(long)&height, string,color,bkcolor, 1024)

2048(hex: 800): Auto calculate the width and height of string. and draw the text.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApAddTxt
[COM]ApcAddTxt

long ApAddTxt ( long id, char *filename,long color ,

long PageWidth, long PageHeight, long AutoNewLine, long AutoWidthAdjust,

long LeftMargin,long RightMargin,long TopMargin,long BottomMargin,

long TabSize);

### Description

Insert txt file into an opened PDF file, supports .txt format, this function support multi-page txt file.

### Parameters

id

Returned by ApCreate or ApOpen function.

filename

Text filename

color

Color of text.

PageWidth, PageHeight

Specifies page size. range is 10~14400.

PageWidth and PageHeight special usage see following table
When PageWidth and PageHeight equal | page size
0 | A3 (842,1190)
1 | A4 (594,792)
2 | A5 (421,595)
3 | B5 (501,709)
4 | Letter (612,792)
5 | legal (612,1008)

AutoNewLine (1/0)

Line Auto-Newline, (enable / disable)=(1/0)

AutoWidthAdjust (1/0)

Page Width Auto-Adjust, (enable / disable)=(1/0)

LeftMargin,RightMargin,TopMargin,BottomMargin

Set page margin.

TabSize

Set Tab space size.
default is 4 if TabSize equal 0.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApAddLine
[COM]ApcAddLine

long ApAddLine(long id,long sx,long sy,long ex,long ey,long width,long color)

### Description

The ApAddLine function draws a line from the (sx, sy) position up to (ex, ey), using the specified width and color.

### Parameters

id

Returned by ApCreate or ApOpen function.

sx

Start x-coordinate.

sy

Start y-coordinate.

ex

End x-coordinate.

ey

End y-coordinate.

width

Specifies the line width in pixel.

color

Specifies the color of the text as an RGB color value.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApAddRect
[COM]ApcAddRect

long ApAddRect(long id,long sx,long sy,long ex,long ey, long side_width,long side_color, long flagFill,long fill_color)

### Description

Draw a rectangle.

### Parameters

id

Returned by ApCreate or ApOpen function.

sx

Start x-coordinate.

sy

Start y-coordinate.

ex

End x-coordinate.

ey

End y-coordinate.

side_width

Specifies the line width in pixel.

side_color

Specifies the color of the text as an RGB color value.

flagFIll

Whether fill this rectangle or not.

fill_color

The color used to fill the rectangle, in RGB format.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApSetFunction
[COM]ApcSetFunction

long ApSetFunction(long id, long Code, long para1, long para2, char *para3,char *para4)

### Description

Set some options before you use Adds functions.

### Parameters

id

Returned by ApCreate or ApOpen function.

code

Specifies the function index, this parameter must be one of the following values.

Code | meaning
101 | set multi-page
104 | set position and size of image
105 | set encrypt info
106 | set font info
109 | add new page or close current page
110 | add bookmark
121 | set viewer preferences
122 | set page orientation
123 | set re-compression
12 6 | set skew correct
12 8 | set Jpeg Quality

#### Code = 101 (Set multi-page options)

Set multipage options, this code can be used before call ApAddImage function.

para1

Begin page number.

para2

Page count begin from para1, if para1 and para2 all equal 0, the page range will be reset to default setting (from first to last page).

para3 and para4

Ignore

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 104 (Set image options)

Set image x, y, width and height options in PDF page, if the width and height not equal image original information, this image will be stretched automatically, this code can be used before call ApAddImage and ApAddImageData function.

para1

X position.

para2

Y position.

para3

Specifies the bitmap width, in pixels, e.g. para3 equal "200".

para4

Specifies the bitmap height, in pixels, e.g. para4 equal "200".

Remarks

if para3 and para4 equal 0 then keep image original size.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 105 (Set encrypts info)

Set encrypts information. this code can be used after call ApCreate function.

para1

Encryption Level, it will equal 40 or 128, indicates 40-bit RC4 or 128-bit RC4.

para2

Document permissions:
Bit1: 1 allows printing, 0 is not.
Bit2: 1 allows content copying or extraction disable accessibility.
Bit3: 1 allows changing the document, 0 is not.
Other Bits ignored.

para3

Owner password, it may equal NULL

para4

Open document password, it may equal NULL.
The encryption setting will be restored if para1 para2 para3 para4 all equal 0.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 106 (Set font info)

Set font name and font size, this code can be used before call ApAddText and ApAddTextEx and ApAddTxt function.. this function support system font.
If para1 equal 1 then use system font, while parameters Para3 specify system font name.
Incorrect system font lead abnormity.

Para1

Font code, see following table

Para1 | Font name
100 | Times-Roman
101 | Times-Bold
102 | Times-Italic
103 | Times-Bold-Italic
200 | Courier
201 | Courier-Bold
202 | Courier-Oblique
203 | Courier-Bold-Oblique
300 | Helvetica
301 | Helvetica-Bold
302 | Helvetica-Oblique
303 | Helvetica-Bold-Oblique
400 | Symbol

font code table (table one)

para2

Font size. e.g. para2 equal 24

para3

specify system font name if para1 equal 1 ,otherwise ignore.

para4

Ignore

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 109 (add new page or close current page)

Create a blank page or close current page. this code can be used before call ApAddImage, ApAddImageData, ApAddText, ApAddTextEx, ApAddRect, ApAddLine function, but you needn’t call the code before call these. please refer to examlple for more information.

para1 and para2

specify a new page size and other parameters will be ignored.
para1=para2=1 : A3
para1=para2=2 : A4
para1=para2=3 : A5
para1=para2=4 : B5
para1=para2=5 : letter
para1=para2=6 : legal

The para1 is the page width and para2 is the height, you can specify any value in pixels, the range is from 10 pixels to 14400 pixels.
If para1 = para2 = 0, current page will be closed.

para3 and para4

Ignore

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 110 (Add bookmark)

Add bookmark into current page, one page only use one bookmark.

para3

Bookmark content.

Otherwise parameters ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 121 (Set viewer preferences)

Set viewer preferences
Describe one:
A name object specifying how the document should be displayed when opened.
Parameter: para1 equal:

> > > 1: Document outline and thumbnail images are invisible.
> > > 2: Document outline is visible.
> > > 4: Thumbnail images are visible.
> > > 8: Full-screen mode, this mode will hide menu bar, toolbar, and any other windows.

Describe two:
Specify an action to be performed when the document is opened.
Parameter: para1 equal:

64(hex: 40): Display the page designated with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller one of the two, centering the page within the window in the other dimension.
128(hex: 80): Display the page designated with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window.

> > > 256(hex: 100): Display the page designated with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window.

512(hex: 200): Display the page designated with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the bounding box within the window in other dimension.

Describe three:
A viewer preference specifying the way the document is to be displayed on the screen.
Parameter: para1 equal:

> > > 4096(hex: 1000): A flag specifying whether to hide the viewer application's tool bars when the document is active.
> > > 8192(hex: 2000): A flag specifying whether to hide the viewer application's menu bar when the document is active.
> > > 16384(hex: 4000): A flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
> > > 32768(hex: 8000): A flag specifying whether to resize the document's window to fit the size of the first displayed page.
> > > 65536(hex: 10000): A flag specifying whether to position the document's window in the center of the screen.
> > > 131072(hex: 20000): A flag specifying whether the window's title bar should display the document title taken from the document information.

para2

Specifies a destination page to be displayed.

Otherwise parameters ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 122 (Choose page orientation)

Choose page orientation.

para1

page orientation angle, (90,180,270).
para1=90 , page landscape left.
para1=180, page reverse direction.
para1=270, page landscape right.

Otherwise parameters ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 123 (set re-compression)

Set re-compression arithmetic of image, including ZIP, LZW, CCITT G4/G3, JPEG, Packbits.

para1

Bits color of image.
para1=1, B/W image.
para1=2, gray or 256 color image.
para1=3, 24bits color image.

para2

Ignore.

para3

Compression arithmetic. this parameter rest with para1.
if para1 is 1 then
re-compress black-and-white images with "lzw","zip","g3","g4".
if para1 is 2 then
re-compress gray images with "lzw","zip","packbits","jpeg" .
if para1 is 3 then
re-compress color images with "lzw","zip","packbits","jpeg" .

para4

Ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 12 6 (set skew correct)

Set skew correct for black and white of TIFF files.

para1

Must be 1.

para2, para 3, para 4

Ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

#### Code = 12 8 (set Jpeg Quality)

Set Jpeg Quality for jpg files and jpg arithmetic of TIFF files.

para1

Must be (10~100). default vaule is 75.

para2, para 3, para 4

Ignore.

Return Value

Nonzero if it is successful; otherwise, it is zero.

## [SDK] ApGetFunction
[COM]ApcGetFunction

long ApGetFunction(long id, long Code, long para1, long para2, char *para3, char *para4)

### Description

Get special information from the setting.

### Parameters

id

Returned by ApCreate or ApOpen function.

Code

Specifies the function index, this parameter must be one of the following values

Code | meaning
201 | get page count of image
202 | get width of image
203 | get height of image
204 | get dpi-x of image
205 | get dpi-y of image
206 | get page count of pdf
209 | get current page size of pdf
250 | get width of string
251 | get height of string
211 | get bits of color

#### Code = 201 (Get image page count)

Get page count from specify image file.

para3

Indicate file name of image file.

Otherwise parameters ignore.

Return Value

Page number in this image file, 0 is failed.

####

#### Code = 202 (get width of image)

Get images width and it can get height too.

> para1

> [Out parameters] save images width, it may equal NULL.
> usage: (long)& width if width is variable
> (long) width if width is pointer

> para2

> [Out parameters] save images height, it may equal NULL.
> usage: (long)&height if the height is variable
> (long)height if the height is pointer

> para3

> Indicate file name of image file.

> para4

> Specifies image file page number, e.g. first page is ‘1’, it may equal NULL.

> Return Value

> Image width if it is successful; otherwise, it is zero.

#### Code = 203 (get height of image)

Get images height and it can get width too.

> para1

> [Out parameters] save images width, it may equal NULL.
> usage: (long)& width if width is variable
> (long) width if width is pointer

> para2

> [Out parameters] save images height, it may equal NULL.
> usage: (long)&height if the height is variable
> (long)height if the height is pointer

> para3

> Indicate file name of image file.

> para4

> Specifies image file page number, e.g. first page is ‘1’, it may equal NULL.

> Return Value

> Image height if it is successful; otherwise, it is zero.

#### Code = 204 (Get images DPI x-resolution)

Get images DPI resolution

> para1

> [Out parameters] save images DPI x-resolution, it may equal NULL.
> usage: (long)& xdpi if xdpi is variable
> (long) xdpi if xdpi is pointer

> para2

> [Out parameters] save images DPI y-resolution, it may equal NULL.
> usage: (long)& ydpi if ydpi is variable
> (long) ydpi if ydpi is pointer

> para3

> Indicate file name of image file.

> para4

> Specifies image file page number, e.g. first page is ‘1’, it may equal NULL.

> Return Value

> Image DPI x-resolution if it is successful; otherwise, it is zero.

#### Code = 205 (Get images DPI y-resolution)

Get images DPI resolution

> para1

> [Out parameters] save images DPI x-resolution, it may equal NULL.
> usage: (long)& xdpi if xdpi is variable
> (long) xdpi if xdpi is pointer

> para2

> [Out parameters] save images DPI y-resolution, it may equal NULL.
> usage: (long)& ydpi if ydpi is variable
> (long) ydpi if ydpi is pointer

> para3

> Indicate file name of image file.

> para4

> Specifies image file page number, e.g. first page is ‘1’, it may equal NULL.

> Return Value

> Image DPI y-resolution if it is successful; otherwise, it is zero.

####

#### Code = 206 (Get PDF page count)

Get PDF file page count.

> All parameters ignore.

> Return Value

> Page count if it is successful; otherwise, it is zero.

#### Code = 209 (Get PDF current page size)

Get PDF file current page size.

> para1

> [Out parameters] save page width, it may equal NULL.
> usage: (long)& width if width is variable
> (long) width if width is pointer

> para2

> [Out parameters] save page height, it may equal NULL.
> usage: (long)& height if the height is variable
> (long) height if the height is pointer

> para3

> If Para3 equal “width” or NULL then return value is page width.
> If Para3 equal “height” then return value is page height.

> para4

> Ignore.

> Return Value

> Page width or height if it is successful; otherwise, it is zero.

#### Code = 250 (Get string width)

Get string width with indicate font and size.

> para1

> Specifies the font name index, see font code table (table one).
> Use current font name if para1 equal 0.

> para2

> Font size.
> Use current font size if para2 equal 0.

> para3

> Indicate string.

> para4

> Ignore.

> Return Value

> String width if it is successful; otherwise, it is zero.

#### Code = 251 (Get string Height)

Get string Height with indicate font and size.

> para1

> Specifies the font name index, see font code table (table one).
> Use current font name if para1 equal 0.

> para2

> Font size.
> Use current font size if para2 equal 0.

> para3

> Indicate string.

> para4

> Ignore.

> Return Value

> String Height if it is successful; otherwise, it is zero.

#### Code = 211 (get bits of color)

Get bits color of image.

para1 , para2 and para4

Ignore.

para3

Indicate file name of image file.

Return Value

Color bits if it is successful; otherwise, it is zero.

## [SDK] ApAddInfo
[COM]ApcAddInfo

long ApAddInfo (long id, char * Title, char * Subject, char * Author, char * Keywords, char * Creator)

### Description

Set PDF file information.

### Parameters

id

Returned by ApCreate or ApOpen function.

Title

Set title to PDF file , it may equal NULL.

Subject

Set subject to PDF file, it may equal NULL.

Author

Set author to PDF file, it may equal NULL.

Keywords

Set Keywords to PDF file, it may equal NULL.

Creator

Set Creator to PDF file, it may equal NULL.

### Return Value

Nonzero if it is successful; otherwise, it is zero.

# Example

> SDK examlple: Please reference folder “example_for_VC”,“example_for_C#”,“example_for_VB”,
> “example_for_VB.net”,“example_for_CB”,” example_for_delphi”.
> COM example(client/server): Please reference folder “example_for_asp”,“example_for_asp.net”,“example_for_jsp”.
> Download address:
> http://www.adultpdf.com/products/image2pdf/imgtopdf_cs.zip

# Limitations in the trial version

Insert a watermark string in the every page in the PDF file

# Requirements to system

Windows 98/ME/NT/2000/XP/2003 OS.

# Contact

> The TiffToPDF converter command line info and order page
> http://www.adultpdf.com/products/image2pdf/index.html
> https://www.regnow.com/softsell/nph-softsell.cgi?item=13446-50
> https://www.regnow.com/softsell/nph-softsell.cgi?item=13446-51

> W eb site (more other softwares)
> http://www.adultpdf.com/

# Technical Support

If you have any technical questions, suggests, bug reports, please contact us at support@adultpdf.com
If you have any ideas and suggestions on how could improve our software, we would love to hear your thoughts.

Copyright @ 2000-2007 Adultpdf.com Inc. All rights reserved.