DynaPDF Manual - Page 284

Previous Page 283   Index   Next Page 285

Function Reference
Page 284 of 839
CreateNewPDF
Syntax:
LBOOL pdfCreateNewPDF(
const PPDF* IPDF,
// Instance pointer
const char* OutPDF) // File name of the output file or NULL
This function creates a new PDF file. If the parameter OutPDF is an empty string the PDF file is
created in memory. This function resets also the internal error flag if it was set before.
A memory based PDF file is available after CloseFile() or CloseFileEx() was called. To get the file
buffer call the function GetBuffer(). Note that the internal used resources must be freed manually if
a PDF was created in memory. See also GetBuffer().
It is also possible to open the output file with OpenOutputFile() right before CloseFile() is called.
The advantage is that the entire PDF file can be processed before opening the output file. If an error
occurred during processing, the creation of the output file can be discarded so that no empty file
will be left on disk.
Remarks:
This function is implemented in an Ansi and Unicode compatible version. On Windows operating
systems Unicode file names are supported on NT based systems only (Win NT, 2000, XP, and so on).
Non-Windows operating systems use UTF-8 to encode Unicode file paths. Therefore, the Ansi
version should be used to open the file. If the Unicode version is used instead the file path is
converted to UTF-8 and passed to the Ansi version of the function.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Examples (C):
Example 1: Create a PDF file in memory:
// First we declare an error callback function that is called if an
// error occurred.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
{
printf("%s\n", ErrMessage);
return 0;
}
int main(int argc, char* argv[])
{
FILE* f; char* buffer; UI32 bufSize;
PPDF* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
// No need to check return values.
 

Previous topic: CreateNamedDest

Next topic: CreateOCG