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 - Draw Text onto Existing PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Draw Text onto Existing PDF

 Post Reply Post Reply
Author
Message
Tim Hayes View Drop Down
Beginner
Beginner


Joined: 16 Feb 07
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tim Hayes Quote  Post ReplyReply Direct Link To This Post Topic: Draw Text onto Existing PDF
    Posted: 26 Apr 07 at 9:51AM
Hi,
 
I am new to QuickPDF.
 
I am seeking to be able to add using  (for instance) page numbers to a PDF that has already been created from a scanner utility. I am using the DRAWTEXT command.
 
I have tested the command on a new document and it works fine (unlock is done).
 
On my scanned PDF, the printed output is not visible.
 
However, I have used FinePrintFactory Pro to print the PDF to another PDF file, and now I can DRAWTEXT and the result is visible.
 
There is no difference in the permissions settings between the files. The only visible differences are (a) the original is A4, the other Letter and (b) the original is 859kb long and the new PDF is 1253kb long - suggesting that there is a compression issue.
 
I am probably doing something really stupid. Any suggestions would be most helpful.
 
Many thanks
Tim Hayes
 
 
 
 
Back to Top
marian_pascalau View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 28 Mar 06
Location: Germany
Status: Offline
Points: 278
Post Options Post Options   Thanks (0) Thanks(0)   Quote marian_pascalau Quote  Post ReplyReply Direct Link To This Post Posted: 26 Apr 07 at 11:43AM
Tim, for debug purpose you should prepare a small demo and send it to support(at)quickpdf.org
 
Or at least you should post the piece of code who writes the page numbers.
Back to Top
Tim Hayes View Drop Down
Beginner
Beginner


Joined: 16 Feb 07
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tim Hayes Quote  Post ReplyReply Direct Link To This Post Posted: 26 Apr 07 at 12:21PM
Marian
 
Newcomer apologies.
 
I have sent you a sample project with test files.
 
The code I am using is as follows:
 
procedure Tqpdf01.btExecClick(Sender: TObject);
var QPDox : TiSEDQuickPDF;
    i : integer;
begin
// 1st try with the scanned PDF
  QPDox := TiSEDQuickPDF.Create;
  try
    screen.Cursor := crhourglass;
    QPDox.UnlockKey('as needed');
    QPDox.LoadFromFile(ExtractFilePath(ParamStr(0)) + '\Test_Scan.pdf');
    with QPdox do begin
      for i := 1 to PageCount
        do begin
        SelectPage(i);
        DrawText(500, 100, 'Page : ' + inttostr(i));
        end;
      SaveToFile(ExtractFilePath(ParamStr(0)) + '\Test_Scan_Out.pdf');
// this does not work
    end;
  finally
    QPDox.Free;
    screen.Cursor := crdefault;
  end;
// now try with the reprinted PDF
  QPDox := TiSEDQuickPDF.Create;
  try
    screen.Cursor := crhourglass;
    QPDox.UnlockKey('as needed');
    QPDox.LoadFromFile(ExtractFilePath(ParamStr(0)) + '\Test_ScanNew.pdf');
    with QPdox do begin
      for i := 1 to PageCount
        do begin
        SelectPage(i);
        DrawText(500, 100, 'Page : ' + inttostr(i));
        end;
      SaveToFile(ExtractFilePath(ParamStr(0)) + '\Test_ScanNew_Out.pdf');
// this works
    end;
  finally
    QPDox.Free;
    screen.Cursor := crdefault;
  end;
end;
 
Thanks
Tim Hayes
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 27 Apr 07 at 2:26AM
Hi Tim!

Perhaps it have to do with the fix output position...
Letter is different from A4 - Is "500, 100" for both okay?
Are there rotated pages?
You should use SetMeasurementUnits and SetOrigin before Drawing.

Best regards,
Ingo

Back to Top
marian_pascalau View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert


Joined: 28 Mar 06
Location: Germany
Status: Offline
Points: 278
Post Options Post Options   Thanks (0) Thanks(0)   Quote marian_pascalau Quote  Post ReplyReply Direct Link To This Post Posted: 27 Apr 07 at 8:12AM

Hi Tim,

I have checked your problem. The difference between the two files is caused by the fact that one of the document alter the page coordinate system and when you believe to paint something on 500/100 you realy paint somewhere else.

 

This is not so bad if you know what is happening. For you I have a solution. In your sample program you need to add 2x lines of code:

 

        QPDox.LoadFromFile(ExtractFilePath(ParamStr(0)) + '\Test_Scan.pdf');

        // <Marian note=”avoid creation of additional layer”>

        //     By default QuickPDF will add a so called

        //     safe layer which create additional content stream.

        //     Because we want to modify the original content we

        //     don’t need this feature.

        QPDox.UseUnsafeLayers(1);

        // </Marian>

        with QPdox do

        begin

            for i := 1 to PageCount do

            begin

                SelectPage (i);

                // <Marian note=”save&restore canvas status”>

                SetPageContent('q'#13#10 + // save canvas status

                    Trim(GetPageContent) + // previous content

                    #13#10'Q'#13#10);      // restore canvas status

                // </Marian>

                DrawText(500, 100, 'Page : ' + inttostr(i));

                // now this should work as well :-)

            end;

            SaveToFile(ExtractFilePath(ParamStr(0)) + '\Test_Scan_Out.pdf');

            // this does not work

        end;



Edited by marian_pascalau - 27 Apr 07 at 8:14AM
Back to Top
Tim Hayes View Drop Down
Beginner
Beginner


Joined: 16 Feb 07
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tim Hayes Quote  Post ReplyReply Direct Link To This Post Posted: 27 Apr 07 at 12:05PM
Hi Marian,
 
That works really well! Thankyou. I am not sure how one gets to find these things - are there a variety of "settings" (see Ingo's note above) that should be used when opening and working with existing PDF's?
 
I really appreciate the work that you, Ingo and others are doing to support QuickPDF. I have read all there is to read on the "disappearance" of the author/owner - I do hope he or she reappears soon!
 
However, in the meantime, I am committed to embedding QuickPDF in a new product I am building. I am new to the product, but along the way, what can I do to help? 
 
I am happy to start writing some extended "how to use / what its all about" documentation as I go along. Of course I may need to ask some questions.
 
I am also happy to contribute code - for instance (although I have not yet delved into it) I see that the CPP version of ZLib is used. I have a Pascal translation that works very well, and would be willing to contribute it if there is a requirement.
 
Let me know how I can help.
 
Regards
Tim Hayes
 
 
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. About — Contact — Blog — Support — Online Store