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 - DeleteAnnotation
  FAQ FAQ  Forum Search   Register Register  Login Login

DeleteAnnotation

 Post Reply Post Reply
Author
Message
John View Drop Down
Beginner
Beginner


Joined: 04 May 12
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Quote  Post ReplyReply Direct Link To This Post Topic: DeleteAnnotation
    Posted: 04 May 12 at 3:50AM
Hello
 
The following works without a problem:
a) lnstantiate QPDF
    tempQPDF := TQuickPDF.Create;
b) create a new content stream (layer)
    tempQPDF.NewContentStream;
c) render a page to stream
    tempQPDF.RenderPageToStream(tempDPI, tempQPDF_PageNum, 1, tempMemoryStream);
d) draw an annotation on the rendered page
    DrawBox(tempAnnotLeft, tempAnnotTop, tempAnnotWidth, tempAnnotHeight, 1);
e) then save the pdf file.
 
Question:
When I reopen the saved pdf file and render the page on which I placed the annotation, tempQPDF.AnnotationCount returns 0.
 
My goal is to delete all of the annotations on the page with the code below.
 
procedure TformImageEnPDF.SpeedButton1Click(Sender: TObject);
var
  I: Integer;
begin
showmessage('test' + #13 +
            'CurrentPage = ' + IntToStr(tempQPDF.SelectedPage) + #13 +
            'AnnotationCount = ' + IntToStr(tempQPDF.AnnotationCount));
  with tempQPDF do
    begin
      for I := 1 to AnnotationCount do
        begin
          DeleteAnnotation(I);
        end;
    end;
end;
Suggestions ??
 
TIA
 
John
 
 
 
 
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 12 at 6:38AM
Hi John!

"...
d) draw an annotation on the rendered page  
 DrawBox(tempAnnotLeft, tempAnnotTop, tempAnnotWidth, tempAnnotHeight, 1);
..."

This draws a box on the page - nothing more and no real annotation ;-)
If you want to insert a real annotation you should use
AddNoteAnnotation
Please read here:
http://www.quickpdflibrary.com/help/quickpdf/AddNoteAnnotation.php
And all about annotations in general here:
http://www.quickpdflibrary.com/help/quickpdf/AnnotationsAndHotspotLinks.php

Cheers and welcome here,
Ingo



Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 04 May 12 at 1:05PM
John,  

When you delete annotations or formfields then you need to delete them backwards.  This is when you delete an annotation then the total number of annotations reduced by 1.   This is why the loop must be backwards.

procedure TformImageEnPDF.SpeedButton1Click(Sender: TObject);
var
  I: Integer;
begin
showmessage('test' + #13 +
            'CurrentPage = ' + IntToStr(tempQPDF.SelectedPage) + #13 +
            'AnnotationCount = ' + IntToStr(tempQPDF.AnnotationCount));
  with tempQPDF do
    begin
      for I := AnnotationCount downto 1 do  // step - 1  <<<<<<<<<<<<<<<<<<<<<<<<
        begin
          DeleteAnnotation(I);
        end;
    end;
end;

Andrew
Back to Top
John View Drop Down
Beginner
Beginner


Joined: 04 May 12
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 12 at 2:24PM
Ingo
 
Thanks for the reply.
 
To clarify, my first post.
a) Each PDF opened, is associated with a database record which stores the original content stream count. 
b) This allows me to know the content stream number of the layer/stream that I created when the PDF was originally opened and select that content stream when the pdf is loaded.
c) All drawboxes or putlines placed on an existing PDF are placed on the content stream that I created when the PDF was original opened.
 
If I render a page, delete the content stream on which I had previously placed a drawbox, save the PDF and rerender the page, the drawbox I had previously placed is gone.  This action is as expected.  I can then repeat this process of rendering the page, placing a new drawbox, resaving the PDF, viewing the redrawn drawbox and then again deleting the redrawn drawbox. 
 
All of the viewing, drawing and deletion is done from a single instantiation of a delphi form which does the following from the OnCreate event of the form
a) Instantiates an instance of QuickPDF,
b) loads the PDF document via tempQuickPDF.LoadFromFile and
c) sets the active stream/layer via a to call tempQuickPDF.SelectContentStream.
 
Question:
How is it that I can repeatedly place a drawbox on a selected content stream and then delete the stream without either reloading the entire document or recreating the instantiation of tempQuickPDF?  Does each rerendering of the page recreate all of the content streams (even those previously deleted) based on some variable that was defined when the pdf document was loaded into the instantiation of the tempQuickPDF?
 
TIA
 
John
 
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 12 at 3:23PM
Each content stream contains drawing commands.  When the PDF renders it processes each contentstream 1 after the other and draws what is contained in the each stream. 

Because the contentsteams contain the only copy of the drawing commands they cannot be recreated.  The only way they can be recreated is by reloading the file.

As Ingo points out,  DrawBox draws a graphical rectangle onto the page.  A rectangle is not a true PDF Annotation object.  You need to use AddNoteAnnotation to add a proper annotation which is a special separate object that is not included in the content stream but is stored in a list of Annotations.  Annotations are always drawn after all of the contentstreams have been drawn.

Andrew.
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