Print Page | Close Window

I need help Adding with page count

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=4046
Printed Date: 02 Apr 25 at 2:11AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: I need help Adding with page count
Posted By: sachinda
Subject: I need help Adding with page count
Date Posted: 15 Mar 25 at 7:06PM
Hi all I need big help with adding page count .
i want to add page numbers to each pdf page...if a pdf page has 2 images and user want 3 copies then it must need to be print as 
copy 1 of 3
copy 1 of 3
copy 2 of 3
copy 2 of 3
copy 3 of 3
copy 3 of 3...... 
like this .... but my output always printing copy 1 of 3 in the all pages... but the console output will give me the correct text  and pdf output give the wrong text .Here is my code.

function printService.PrintImageFromStream(fin: TStream;reqid, rtype: string; ncopies, npages: Integer): Integer;
var
    DPL: TDebenuPDFLibrary1114;
    i,c,imgID,imgsID, unlockResult, iPrintOptions, res: Integer;
    cPrinter: WideString;
    err, pageText: string;
begin
    Result := 0;
    try     
        DPL := TDebenuPDFLibrary1114.Create;
        with DPL do
            try
                unlockResult := unlockKey('0000'); 

                if unlockResult = 1 then
                begin
                    cPrinter := DPL.NewCustomPrinter(GetPrinterName(rtype));
                    DPL.SetupCustomPrinter(cPrinter, 4, ncopies);
                    DPL.SetupCustomPrinter(cPrinter, 7, 2);

                    for c := 1 to ncopies do
                      begin
                            for i := 1 to npages do
                                begin
                                   fin.Position := 0;
                                   CompressImages(1);

                                   imgID := AddImageFromStream(fin, -i);
                                     if imgID > 0 then
                                        begin
                                          SelectImage(imgID);
                                          SetPageDimensions(ImageWidth, ImageHeight);
                                          SetOrigin(1);

                                          if DrawImage(0, 0, ImageWidth, ImageHeight) <> 1 then
                                          raise Exception.Create('unsupported image');

                                          pageText := Format('Copy %d of %d', [c, ncopies]);

                                          AllocConsole;
                                          Writeln('pageText ', pageText);

                                          DPL.SetTextColor(0, 0, 0);
                                          DPL.SelectFont(AddStandardFont(5));
                                          DPL.SetTextSize(36);
                                          DPL.DrawText(50, 226, pageText);
                                          SelectPage(NewPage);
                                        end
                                     else
                                       raise Exception.Create('unsupported image');
                                end;
                      end;

                    iPrintOptions := DPL.PrintOptions(1, 0,'veloprint[' + reqid + ']');
                    res := DPL.PrintDocument(cPrinter, 1, npages, iPrintOptions);

                    if res <> 0 then
                    begin
                        Result := 200;
                    end
                    else
                    begin
                        ShowErrorNotification('Printer error');
                        raise Exception.Create('[error] [' + reqid + '] ' + 'PrintImageFromStream: Printer error');
                    end;
                end
                else
                    raise Exception.Create('[error] [' + reqid + '] ' + 'DPL licence error');
            finally
                DPL.Free;
            end;
    except
        On E: Exception do
        begin
            raise Exception.Create(err);
        end;
    end;
end;



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk