Adds a page to the document handle using information from the DOCWRTPAGE structure.
#include "l_bitmap.h"
L_LTDOCWRT_API L_INT EXT_FUNCTION L_DocWriterAddPage(hDocument, PageType, pPage)
Handle to an existing Document. This handle is obtained by calling the L_DocWriterInit function.
Specifies the document page type.
Pointer to a DOCWRTPAGE structure that contains information about the added page.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
Calls STATUSCALLBACK to follow the conversion process.
Before using the LEADTOOLS Document Writers SDK, unlock it using L_SetLicenseFile. If you want to use the PDF format you must also unlock PDF support with L_SetLicenseFile.
Win32, x64.
This example creates a PDF file.
L_INT L_DocWriterAddPageExample(L_VOID)
{
DOCWRTPDFOPTIONS pdf;
L_INT nRet = 0;
L_DOUBLE dTextScale = 0.5;
DOCUMENTWRITER_HANDLE hDocument;
DOCWRTEMFPAGE Page;
BITMAPHANDLE OverlayBitmap;
memset(&pdf, 0, sizeof(DOCWRTPDFOPTIONS));
memset(&Page, 0, sizeof(DOCWRTDOCOPTIONS));
pdf.bImageOverText = TRUE;
pdf.FontEmbed = DOCWRTFONTEMBED_ALL;
pdf.PdfProfile = DOCWRTPDFPROFILE_PDF;
pdf.bLinearized = FALSE;
pdf.pwszTitle = "Add your title here";
pdf.pwszSubject = "Add your subject here";
pdf.pwszKeywords = "Add your keywords here";
pdf.pwszAuthor = "Add author name here";
pdf.bProtected = TRUE;
pdf.pszUserPassword = "User password";
pdf.pszOwnerPassword = "Owner password";
pdf.EncryptionMode = (DOCWRTPDFENCRYPTIONMODE)DOCWRTPDFENCRYPTIONMODE_RC128BIT;
pdf.bPrintEnabled = FALSE;
pdf.bHighQualityPrintEnabled = TRUE;
pdf.bCopyEnabled = FALSE;
pdf.bEditEnabled = TRUE;
pdf.bAnnotationsEnabled = TRUE;
pdf.bAssemblyEnabled = FALSE;
pdf.uFlags = 0;
pdf.Options.uStructSize = sizeof(pdf);
// Use default resolution
pdf.Options.nDocumentResolution = 0;
pdf.Options.PageRestriction = (DOCWRTPAGERESTRICTION)DOCWRTPAGERESTRICTION_RELAXED;
// Setup empty page size (Letter size)
pdf.Options.dEmptyPageWidth = 8.5;
pdf.Options.dEmptyPageHeight = 11;
pdf.Options.nEmptyPageResolution = 300;
pdf.Options.bMaintainAspectRatio = FALSE;
nRet = L_DocWriterInit(&hDocument,
MAKE_IMAGE_PATH("Output.pdf"),
DOCUMENTFORMAT_PDF,
&pdf,
NULL,
NULL);
if (nRet != SUCCESS)
return nRet;
nRet = L_LoadBitmap(MAKE_IMAGE_PATH("Ocr1.emf"),
&OverlayBitmap,
sizeof(BITMAPHANDLE),
0,
ORDER_BGR,
NULL,
NULL);
if (nRet != SUCCESS)
return nRet;
Page.hEmf = GetEnhMetaFile(MAKE_IMAGE_PATH("Ocr1.emf"));
Page.pdwTextScale = &dTextScale;
Page.pOverlayBitmap = &OverlayBitmap;
nRet = L_DocWriterAddPage(hDocument, DOCWRTPAGETYPE_EMF, (L_VOID*)&Page);
if (nRet != SUCCESS)
return nRet;
nRet = L_DocWriterFinish(hDocument);
if (nRet != SUCCESS)
return nRet;
if (OverlayBitmap.Flags.Allocated)
L_FreeBitmap(&OverlayBitmap);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document