Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How can I fit to page?

Question

I want to print different sized PDF documents to user specified paper size. For example it is possible that the document is A1 and I want to print it to an A3 format. Can you provide me with a sample? I used the following sample but the pages weren't fit to paper:

qp.LoadFromFile(Filename);
qp.SetPageSize(PrintingOptions.PaperSize);
// Set the paramters for the PrintDocument function
string PrinterName = PrintingOptions.Printer;
int StartPage = 1; // Set first page number
int EndPage = qp.PageCount(); // Set last page number

// Set the paramters for the PrintOptions function
int PageScaling = 0;
int AutoRotateCenter = 1;
string Title = Filename;

// Assign the options for printing to an int variable
int Options = qp.PrintOptions(PageScaling, AutoRotateCenter, Title);
// Print the document with the required paramters and options specified
qp.PrintDocument(PrinterName, StartPage, EndPage, Options);
Answer

To acoomplish what you're trying to do you'll need to use the custom printer functions (NewCustomPrinter and SetupCustomPrinter).

Some info on the custom printer functions here.

And here is some JScript sample code which demonstrates how to use the functions:

/* Create a custom printer and specify your own settings  */
 
// Load a sample file from the input folder
 
QP.LoadFromFile(GetInputFolder() + "JavaScript.pdf"); 
 
// Create the custom printer
 
CustomPrinter = QP.NewCustomPrinter("Microsoft XPS Document Writer");
 
// Setup the settings for the customer printer
 
// Medium quality
 
QP.SetupCustomPrinter(CustomPrinter, 5, 2); 
 
// Monochrome
 
QP.SetupCustomPrinter(CustomPrinter, 6, 1); 
 
// Horizontal Duplex
 
QP.SetupCustomPrinter(CustomPrinter, 7, 3);
 
// Configure print options
 
iPrintOptions = QP.PrintOptions(0, 0, "Printing Sample");
 
// Print the current document to the default printing 
// using the options as configured above
 
QP.PrintDocument(CustomPrinter, 1, 1, iPrintOptions);

So you need to setup the printer and the paper size for your customer printer before you call the PrintDocument function.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum