AdultPdf.Com Inc


Image To PDF COM/SDK v2.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:




Features

1.  Specify page size.
2.  Use Base 13 fonts and system fonts.
3.  Convert JPEG to PDF.
4.  Convert TIFF to PDF.
5.  Convert Text to PDF.
6.  Supports tiff,jpeg,bmp,dib,emf,gif,icon,jbig,jp2,pcd,pcx,pict,png,pnm,psd,rle,tga,txt,wmf,xbm and xpm format.
7.  40-bit encryption.
8.  128-bit encryption.
9.  Append to existing PDF file.
10.Add bookmarks.
11.Add PDF information.
12.Images can be from memory or disk.
13.Set viewer preferences.
14.Handle millions of pages.
15.Arbitrary placement of images onto new PDF pages.
16.Page orientation.



Functions description

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

[SDK] AdultPdfCreate  
[
COM] AdultPdfCreateEx

long AdultPdfCreate(char * Filename)

    Description

Create a PDF file.

    Parameters

Filename 

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.

 

 

 

[SDK] AdultPdfOpen  
[
COM] AdultPdfOpenEx

long AdultPdfOpen(char * Filename)

    Description

Open a PDF file.for append

    Parameters

Filename 

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.

 

 

 

[SDK] AdultPdfClose  
[
COM]AdultPdfCloseEx

void AdultPdfClose(long id)

    Description

Close the opened PDF file.

    Parameters

id

       Returned by AdultPdfCreate and AdultPdfOpen function.

    Return Value

              None

 

 

 

[SDK] AdultPdfAddImage  
[
COM]AdultPdfAddImageEx

long AdultPdfAddImage(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 AdultPdfSetFunction (code = 101) to set the page range before you use this function, please refer to the AdultPdfSetFunction function for get more information.

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen function.

       filename 

              Image filename

    Return Value

If this function return –1, indicate width or height large than 14400 pixel), A return value of 0 indicates an error, otherwise is succeed.

 

 

 

[SDK] AdultPdfAddImageData  
[COM]AdultPdfAddImageDataEx

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

    Description

Insert memory bitmap into PDF file.

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen 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] AdultPdfAddTextEx  
[
COM]AdultPdfAddText2Ex

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

    Description

The AdultPdfAddTextEx function writes a character string at the specified location, using the currently selected font, text color, if x = y = -1, indicate the text string will be drawing at current text position, default text position is (64, 64).

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen function.

              x

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

              y

Specifies the logical y-coordinate of the reference point that the system uses to align the string, the y-coordinate will moved 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] AdultPdfAddText  
[COM]AdultPdfAddText1Ex

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

    Description

The AdultPdfAddText function writes a character string in the specified rectangle , using the currently selected font, text color.

    Parameters

                    id

       Returned by AdultPdfCreate or AdultPdfOpen function.

              x

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

              y

Specifies the logical y-coordinate of the reference point that the system uses to align the string, the y-coordinate will moved 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. function modifies the width and height. 
                                                And returns the width and height of the formatted text but does not draw the text.

                 special call  e.g. AdultPdfAddText(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] AdultPdfAddTxt  
[COM]AdultPdfAddTxtEx

long AdultPdfAddTxt (  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 AdultPdfCreate or AdultPdfOpen function.

       filename 

              Text filename

       color

              Text color

       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] AdultPdfAddLine  
[COM]AdultPdfAddLineEx

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

    Description

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

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen 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] AdultPdfAddRect  
[COM]AdultPdfAddRectEx

long AdultPdfAddRect(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 AdultPdfCreate or AdultPdfOpen 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] AdultPdfSetFunction  
[COM]AdultPdfSetFunctionEx

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

    Description

              Set some options before you use some special functions.

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen function.

code      

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

              #define AdultPdf_Set_MultiPage                 101

              #define AdultPdf_Set_ImagePosAndSize     104

              #define AdultPdf_Set_Encrypt                   105

              #define AdultPdf_Set_Font                        106

              #define AdultPdf_Set_NewOrClosePage      109

              #define AdultPdf_Set_BookMark                110

              #define AdultPdf_Set_ViewerPreferences    121

              #define AdultPdf_Set_Orientation               122

 

Code = 101 (Set multi-page options)

Set multi-page options, this code can be used before call AdultPdfAddImage function.

para1

Begin page number.

                            para2

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

                            Para3

                                   Ignore

                            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 AdultPdfAddImage and AdultPdfAddImageData 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 AdultPdfCreate function.

Para1

Encryption Level, it will equal 40 or 128, indicate 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 AdultPdfAddText and AdultPdfAddTextEx and AdultPdfAddTxt function.. this function support system font.

                            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)

                  If  Para1 equal 1 then use system font, while parameters Para3 specify system font name.  Incorrect system font lead abnormity.

Para2

                                   Font size

                            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 (Create or close page.)

                            Create a blank page or close current page.

                            This code can be used before call AdultPdfAddImage,AdultPdfAddImageData,

AdultPdfAddText,AdultPdfAddTextEx,AdultPdfAddRect,AdultPdfAddLine function, But you needn’t call the code before call these.

 

                            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 page width and para2 is 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

                                   Ignore

                            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 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 the 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.

                            para2

                                   Ignore

                            Para3

                                   Ignore

                            Para4

                                   Ignore

Return Value

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

 

 

 

[SDK] AdultPdfGetFunction  
[COM]AdultPdfGetFunctionEx

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

    Description

              Get special information from the setting.

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen function.

Code      

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

              #define AdultPdf_Get_ImagePageCount             201

              #define AdultPdf_Get_ImageSizeW                   202

              #define AdultPdf_Get_ImageSizeH                    203

              #define AdultPdf_Get_ImageDpiX                     204

              #define AdultPdf_Get_ImageDpiY                     205

              #define AdultPdf_Get_PdfPageCount                 206

              #define AdultPdf_Get_PdfCurrentPageSize         209

              #define AdultPdf_Get_StringWidth                    250

              #define AdultPdf_Get_StringHeight                    251

Code = 201 (Get image page count)

Get page count from specify image file.

Para1

       Ignore

Para2

       Ignore

Para3

Image filename

Para4

       Ignore

Return Value

                     Page number in this image file, 0 is failed

              Code = 202 (Get image width)

                     Get images width and height.

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 height is variable

(long)height if height is pointer

Para3

Image filename

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 image height)

                     Get images width and height.

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 height is variable

(long)height if height is pointer

Para3

Image filename

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

Image filename

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

Image filename

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.

Para1

Ignore

Para2

Ignore

Para3

Ignore

Para4

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 height is variable

(long) height if 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.

 

 

[SDK] AdultPdfAddInfo  
[COM]AdultPdfAddInfoEx

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

    Description

              Set PDF file information.

    Parameters

id

       Returned by AdultPdfCreate or AdultPdfOpen 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 directory “create_for_VC”, “create_for_VB”,” append_for_VC”,” append_for_VB”.
            COM example(server): Please reference directory “for asp”.

Limitations in the trial version

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

 

Contact

Homepage

http://www.adultpdf.com/
            http://www.adultpdf.com/products/image2pdf/index.htm

E-mail

mailto:support@adultpdf.com

 

Copyright @ 2000-2003 AdultPDF.com Inc. All rights reserved.