Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - I need help Adding with page count
  FAQ FAQ  Forum Search   Register Register  Login Login

I need help Adding with page count

 Post Reply Post Reply
Author
Message
sachinda View Drop Down
Beginner
Beginner
Avatar

Joined: 15 Mar 25
Location: Sri lanka
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote sachinda Quote  Post ReplyReply Direct Link To This Post Topic: I need help Adding with page count
    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;


Edited by sachinda - 15 Mar 25 at 7:15PM
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store