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

Problem with setting multiple copies with SetupCustomPrinter

Question

The following code should print three copies of the loaded document but I'm only getting a single copy, why?

quickPdf.LoadFromFile('...');
customPrinter := quickPdf.NewCustomPrinter(quickPdf.GetDefaultPrinterName);
//three copies
if quickPdf.SetupCustomPrinter(customPrinter, 4, 3) = 1 then
begin
  printOptions := quickPdf.PrintOptions(0, 0, '');
  quickPdf.PrintDocument(customPrinter, 1, quickPdf.PageCount, printOptions);
end;

Tested with the latest version (7.21) on Delphi 2010 (Update 5) and Windows 7 Professional.

Answer

There seems to be an issue with virtual print drivers (like XPS and PDF printers) not being able to handle more than one copy.

The solution is to manually duplicate existing PDF pages in order defined by collation.

if printCopies > 1 then
begin
    quickPdf.CombineLayers;
    //no collation
    if not collate then
    begin
        //make cloned pages at the end of the selected document
        for pageNum := startPageNum to endPageNum do
            quickPdf.ClonePages(pageNum, pageNum, printCopies);
        //copy cloned pages to a new document and delete the old one ***
        oldDocumentId := quickPdf.SelectedDocument;
        quickPdf.ExtractPages(endPageNum + 1, quickPdf.PageCount - endPageNum);
        quickPdf.RemoveDocument(oldDocumentId);
    end
    //collate
    else
        quickPdf.ClonePages(startPageNum, endPageNum, printCopies - 1);
end;

*** Deleting the original pages with DeletePages makes all the cloned pages blank.


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