Search:     Advanced search
Browse by category:
Glossary | Contact Us



How to set programmatically the page related settings (page size, layout) via novaPDF SDK

Add comment
Votes: 1
Comments: 0
The page related settings have a different behavior than the other settings (save, compression, fonts, security,...). While the last are specific to the novaPDF printer driver , the page related settings are used for all printer drivers and can be set by system calls (check the DEVMODE Windows structure).

For example, if you start to print a document from an application, you can usually set the page size, page layout, scale and resolution from a Page setup dialog in that specific application. These settings (read from the application that initiates the printing) are shown on the Page tab on novaPDF printer and they are used also when generating the PDF document.

To change this behavior and use the specific settings set by the novaPDF printer interface (or novaPDF SDK ) in the registry, you can check the Profile settings override paper settings option from the printing application check box on the Profiles tab. This flag is saved separately for each profile. To change programmatically the flag add the next line:
pNova.SetOptionLong2(NOVAPDF_PAPER_OVERRIDE, 1, PROFILE_NAME);

But a better approach is to change page settings in this DEVMODE structure, because in this way both the printing application and the printer driver will be informed about this new page. It is better that the application knows this page, so it sends the information formatted to this size.

Here is the Hello World C++ sample, modified to set page width and height:

HANDLE hPrinter;
PDEVMODEW pDevmode = NULL;
PRINTER_DEFAULTS pd = { NULL, NULL, PRINTER_ACCESS_USE };
//start print job
if (OpenPrinter(PRINTER_NAME, &hPrinter, &pd))
{
//get default printer DEVMODE
int nSize = DocumentProperties(NULL, hPrinter, PRINTER_NAME, NULL, NULL, 0);
pDevmode = (PDEVMODEW)LocalAlloc(LPTR, nSize);
DocumentProperties(NULL, hPrinter, PRINTER_NAME, pDevmode, NULL, DM_OUT_DEFAULT);
//set page size in DEVMODE
pDevmode->dmPaperSize = DMPAPER_USER;
pDevmode->dmPaperLength = 1000;
pDevmode->dmPaperWidth = 1000;
pDevmode->dmFields = DM_PAPERSIZE | DM_PAPERLENGTH | DM_PAPERWIDTH;
DocumentProperties(NULL, hPrinter, PRINTER_NAME, pDevmode, pDevmode, DM_IN_BUFFER | DM_OUT_BUFFER);

//Print a page (use modified DEVMODE)
HDC hDC = CreateDC(L"", PRINTER_NAME, NULL, pDevmode);
DOCINFO docInfo = {sizeof(DOCINFO)};
// PDF document name and path
docInfo.lpszDocName = PDF_FILE_NAME;
StartDoc(hDC,&docInfo);
StartPage(hDC);
// Draw text on page
TextOut(hDC, 100, 80, PDF_TEXT, (int) wcslen(PDF_TEXT));
EndPage(hDC);
EndDoc(hDC);
DeleteDC(hDC);
//print job sent to printer
LocalFree(pDevmode);
ClosePrinter(hPrinter);
}
Others in this Category
document [novaPDF SDK] How to generate a pdf file without the Save As dialog
document [novaPDF SDK] - Is there an option not to open the uninstall feedback page when novaPDF is uninstalled?
document [novaPDF SDK] - Do I have to open or activate a profile before trying to set an option for the printer driver?
document How to install (or uninstall) novaPDF silently
document [novaPDF SDK] - If I set an option value via COM, will that be persistent, or will the option be reverted when the program terminates?
» More articles



RSS

© 2002-2008 Softland. All Rights Reserved.
PDF Creator novaPDF
Create PDF for a paperless office
home Home   contact usContact us   partnershipsPartnerships   bookmarkBookmark   Site updated: 12-Mar-2008
DownloadsDownload

Download, install and use novaPDF. Latest version: 5.4 build 255

Download PDF creator
promotionsSpecial Offers

Current discounts:
- up to 25% for Desktop Editions
- up to 25% for Server Editions
- 20% Academic Discount
- up to 16% for Developer Tools

buyBuy Now
Professional edition $39.95
(Save $10)
Standard edition $29.95
(Save $10)
Lite edition $19.95
(Save $5)
Buy Now
newsLatest News

novaPDF 5.4 released
February 11, 2008

What’s new (read more):
 » Added Copy Text/Image Watermarks dialog
 » Added "Lookup Address" option when sending emails
 » Corrected rotated and vertical texts conversion
 » Corrected conversion from WordArt, MS Word backgrounds and MS Visio drawings
 » Unistaller deletes now the driver files

newsletter News via Email | rss feed News via RSS
sdkDeveloper Tools

novaPDF SDK is a software development toolkit that can be used by software developers and programmers to add the ability to create PDF files in their applications.
novaPDF OEM is a PDF solution that programmers can use to generate PDF files that will be post-processed by their applications. […]

Reviews & User QuotesPDF Creator Reviews

"novaPDF is a really neat tool. Basically, it’s a PDF printer driver that prints to a PDF file instead of paper.

See more reviews about nova PDF
[…] novaPDF is a great product that works without forcing the user to configure anything. The convenience alone is worth the money." […]

Jason Pullara, Editor
Currently supported languagesLanguages

News:
- Finnish and Arabic languages added.
- Spanish, French, Swedish and Chinese Traditional languages updated.

Help us translate novaPDF and we will give you licenses for novaPDF Professional and mention you on the Languages page. […]

awardsAwards

novaPDF received the Editor’s Pick from Soft32, a major download site:

PDF creator reviews

See the Awards page for more ratings.

knowledgebaseKnowledgebase articles

Latest articles on how to:
 » Create PDF files
 » Convert JPG to PDF
 » Convert Powerpoint to PDF
 » Convert Publisher to PDF
 » Convert web pages to PDF
Full article list in the knowledgebase.