adultpdf.com Inc


Text To PDF COM/SDK v2.2 
(for 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

  Ap Text To PDF ( txt2pdf ) is a program to convert ASCII texts into PDF format with a minimum loss of formatting information. supports batch convert, encryption, page  orientation, font setting , document info, bookmark and viewer preferences,etc.

 

 

Features

 

 

 

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.

follow is likely to 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 created or opened PDF file.

    Parameters

id

       Returned by apCreate and ApOpen function.

    Return Value

              None

 

 

 

[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, indicate 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 get 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 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] apAddText  
[COM]apcAddTextEx

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 get 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 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. 
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 text file into an opened PDF file, supports .txt file format, this function support multi-page txt file.

    Parameters

id

       Returned by ApCreate or ApOpen function.

       filename 

              Text file name.

       color

              Color of text.

       PageWidth, PageHeight

              Specifies page size. range is 10~14400.

PageWidth and PageHeight special usage see following table

If 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

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     
   


              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, 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 ApAddText, ApAddTextEx and ApAddTxt function. It 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 get 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 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 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 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.

                            Otherwise parameters 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

206

get page count of pdf 

209

get current page size of pdf 

250

get width of string

251

get height of string

 

                  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 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] 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(for client):  Please reference directory “example_for_VC”, “example_for_VB”, “example_for_VB.net”,
“example_for_
CB”,” example_for_delphi”.
COM example(for server): Please reference directory “example_for_asp”,"example_for_asp.net", "example_for_jsp".
Download address:
http://www.adultpdf.com/products/txttopdf/txttopdfs.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 TextToPDF COM/SDK info and order page
http://www.adultpdf.com/products/txttopdf/index.html
http://www.regsoft.net/purchase.php3?productid=77223
http://www.regsoft.net/purchase.php3?productid=77224

Web site (more other software)
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 ideas and suggestions on how could improve our software, we would love to hear your thoughts.

 

 

Other Products

Copyright @ 2000-2006 adultpdf.com Inc. All rights reserved.