Software License Agreement

WinPDF Converter

For Win32

Version 1.0

2004

ALL RIGHTS RESERVED BY

SUB SYSTEMS, INC.

3017 Covington Place

Round Rock, TX 78681

512-733-2525

Software License Agreement

This license agreement allows the purchaser the right to use the software contained in this package. The purchaser has the right to modify and link the DLL functions into their application. Such an application is free of distribution royalties with these conditions: the target application is not a stand-alone PDF Converter; the target application uses this product for one operating system platform only. Sub Systems, Inc. reserves the right to prosecute anybody found to be making illegal copies of this software.

This product is licensed per developer basis only. Each developer working with this package needs to purchase a separate license.

Sub Systems, Inc. offers a 30 day money back guarantee with the product. Must call for an RMA number before returning the product.


Desclaimer

This software is designed keeping the safety and the reliability concerns as the main considerations. Every effort has been made to make the product reliable and error free. However, Sub Systems, Inc. makes no warranties against any damage, direct or indirect, resulting from the use of the software or the manual and can not be held responsible for the same.

Windows 95/98/NT/2000/XP, Visual C++, MFC, and Visual Basic are the trademarks of Microsoft Corp. (for ease of reading Windows refer to MS Windows)

Delphi is the trademark of Borland International.


Getting Started

This chapter describes the contents of the software diskettes and provides a step by step process of incorporating WinPDF Converter into your application.

In This Chapter

Files

Incorporating the DLL into Your Application

Sample Conversion Code


Files

The package contains the DLL and header files. The package also includes a set of files to construct a demo program. The demo program shows by example the process of linking the DLL to your program. DLL Demo Files: The following demo files are included in the c_demo.zip file.
DEMO.C | Source code for the demo program
DEMO.H | Include file for the demo program
DEMO.RC | Resource source file for the demo program
DEMO.DEF | Definition file for linking the demo program
DEMO.EXE | Executable demo program
DEMO_DLG.H | Dialog Identifiers for the demo program
DEMO_DLG.DLG | Dialog templates for the demo program
DEMO_DLG.RES | Compiled dialogs for the demo program
PDC.H | The include file to include into a C/C++ application module that calls the PDC routine. It contains the constant definitions and the prototypes for the API functions.
PDC32.DLL | The DLL file
PDC32.LIB | Import library for the PDC32 DLL


Incorporating the DLL into Your Application

This product can be used in two ways. You can use this product with TE Developer's Kit to convert the current document into the PDF format. You can also use this product directly within your application to generate PDF output.

When using WinPDF Converter with TE Developer's Kit

Copy the pdc32.dll file to the folder which contains the ter32.dll file. Then please follow the help file for TE Developer's Kit, topic: Application Interface Functions -> PDF Output.

TE provides an automatic interface with WinPDf Converter. You would not need to refer to this help file any further.

When using WinPDf Converter directly within your application

A C/C++ application should include the PDC.h file into the application module that needs to call the PDC32 dll. It also should include the PDC32.LIB as the linker library. Please also make sure that the pdc32.dll file is copied to a directory available at the run-time.

The PDF file generation process is simply as following:

PdcStartDoc(...)

for each page:

HDC hDC=PdcStartPage(...)

// make necessary Windows SDK functions call to draw the page using text, images, and objects functions.

PdcEndPage(..)

PdcEndDoc(..)

Please refer to the next topic for a sample code.

.


Sample Conversion Code

1. First you would create a new document session. Here is an example:

 DocId=PdcStartDoc(LicKey,OutFile,"Mike","Sub Systems, Inc",
                "PDF Generation Test",
                "PDF Generation Test","test,subsys",
                "12/31/2004","12/31/2004",0);

The first argument is used to pass your product license key. Your product license key is available in a file called key.txt. This file is available in your distribution zip file set.

This function returns the Document Id. You would use the Document Id to call other conversion functions.

Once the document id is created, you would use the PdcStartPage and PdcEndPage functions to create each page. The GUI statements to define the content of the page are included between these two function.

2. Start a new page:

  HDC hDC;
  PageWidth=8.5*1440;    // assume a letter size paper
                       //paper size specified in twips units
  PageHeight=11*1440;
  hDC=PdcStartPage(DocId,PageWidth,PageHeight)

3. Use the Windows GUI functions to create the contents of the page

  SelectObject(hDC,GetStockObject(BLACK_PEN));
  MoveToEx(hDC,2000,2900,NULL);
  LineTo(hDC,10000,2900);

  hPrevFont=SelectObject(hDC,hMedFont);
  SetTextColor(hDC,0xFF0000);      // write in red
  pText="Customer Name: ";
  TextOut(hDC,2000,3000,pText,strlen(pText));
  SelectObject(hDC,hPrevFont);   // restore

  hPrevFont=SelectObject(hDC,hMedBoldFont);
  pText="Affront Dog Collars";
  TextOut(hDC,3800,3000,pText,strlen(pText));
  SelectObject(hDC,hPrevFont);   // restore

  MoveToEx(hDC,2000,3400,NULL);
  LineTo(hDC,10000,3400);

You can use Windows GUI functions to draw text, line, rectangle, ellipse, images, etc. You can also use the map mode function to draw the content in a different unit.

4. End the page.

  PdcEndPage(DocId);

The steps 2 to 4 can be repeated to create a multi-page report.

5. After the PDF generation process, end the session by calling the PdcEndDoc function. This function assembles the final document and frees up the memory used by the session.

PdcEndDoc(DocId)

Please refer to the demo.c file for a working source code example.


Application Interface functions

These API functions allow you to generate a PDF document. Your application must include the PDC.H file (c/c++).

The following is a description of the PDC API functions in an alphabetic order:

In This Chapter

PdcEndDoc

PdcEndPage

PdcGetLastMessage

PdcStartDoc

PdcStartPage

PdcResetLastMessage

PdcSetFlags


PdcEndDoc

Terminate the current document. BOOL PdcEndDoc(id)
DWORD id; | Document Id.
Description: This function is called after all pages are drawn. Return Value: The function returns TRUE when successful.


PdcEndPage

Terminate the current page. BOOL PdcEndPage(id)
DWORD id; | Document Id.
Description: This function is called after the page drawing for the current page is completed. Return Value: The function returns TRUE when successful.


PdcGetLastMessage

Get the last message. int PdcGetLastMessage(id, PdcMessage, DebugMessage);
DWORD id; | Document Id.
LPBYTE PdcMessage; | Returns the default user message text in English
LPBYTE DebugMsg; | Returns any debug message associated with the last message. The debug message need not be displayed to the user.
Return Value: This function returns the last message generated by the editor. This value is valid only if saving of the messages is enabled by setting the RFLAG_RETURN_MSG_ID flag. This flag is set using the PdcSetFlags function.


PdcStartDoc

Begin the PDF generation process. int PdcStartDoct(LicKey,OutFile, author, producer, title, subject, keywords, date, ModDate, flags)
LPBYTE LicKey; | // The license key is available in the key.txt file.
LPBYTE OutFile; | // The name of the PDF output file.
LPBYTE author; | // The optional author name for the document. Pass a blank string as default.
LPBYTE producer; | // The optional producer name for the document. Pass a blank string as default.
LPBYTE title; | // The optional title for the document. Pass a blank string as default.
LPBYTE subject; | // The optional subject string for the document . Pass a blank string as default.
LPBYTE keywords; | // The optional keywords for the document. Pass a blank string as default.
LPBYTE date; | // The optional creation date for the document. Pass a blank string as default.
LPBYTE ModDate; | // The optional modification date for the document. Pass a blank string as default.
DWORD flags; | // This flag is currently not used, and should be set to 0.
Description: This function begins PDF document creation. Return Value: This function returns a non-zero Document Id for the output process. The Document Id value is needed for passing to other Pdf APIs. This function returns 0 to indicate an error condition.


PdcStartPage

Start a new page. BOOL PdcStartPage(id, PageWidth, PageHeight)
DWORD id; | Document Id.
int PageWidth; | Page width in twips units (1 inch = 1440 twips).
int PageHeight; | Page height in twips units.
Description: This function is called to start a new page. Return Value: The function returns TRUE when successful.


PdcResetLastMessage

Reset the last editor message. BOOL PdcResetLastMessage(id)
DWORD id; | Document Id.
Description: This function can be called before calling any other function to reset the last error message. Return Value: The function returns TRUE when successful.

See Also

PdcGetLastMessage

PdcSetFlags


PdcSetFlags

Set certain flags or retrieve the values of the flags. DWORD PdcSetFlags(id, set, flags)
DWORD id; |  | Document Id.
BOOL set; |  | TRUE to set the given flags, FALSE to reset the given flags
DWORD flags; |  | Flags (bits) to set or reset. Currently, the following flag values are available:
 | RFLAG_RETURN_MSG_ID |  | Do not display the error messages. Save the error code to be later retrieved using the PdcGetLastMessage function.
 | RFLAG_FIRST_MESSAGE_ONLY |  | Display the first message. Other messages would be suppressed.
Return value: This function returns the new value of all the flags. Call this function with the 'flags' parameter set to zero to retrieve flag values without modifying it.