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 > Sample Code
  New Posts New Posts RSS Feed - Find all annotations in a PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Find all annotations in a PDF

 Post Reply Post Reply
Author
Message
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Topic: Find all annotations in a PDF
    Posted: 25 Sep 09 at 8:13AM
Programmatically retrieving a list of all the various annotations stored inside a PDF is pretty easy when using the AnnotationCount and GetAnnotStrProperty with Quick PDF Library. An example of how to do this is shown below in C# and Delphi.

C# Sample Code:

---
QP.LoadFromFile(txtFilePath.Text);

for (int i = 1; i <= QP.PageCount(); i++)
{
    QP.SelectPage(i);

    txtLog.Text = txtLog.Text + "Page " + Convert.ToString(i) + " has " + QP.AnnotationCount() + " annotations." + "\r\n" + "\r\n";
    
    for (int d = 1; d < QP.AnnotationCount(); d++)
    {
        string AnnotType = QP.GetAnnotStrProperty(d, 101);
        txtLog.Text = txtLog.Text + AnnotType + "\r\n";
    }
}
---

Delphi Sample Code:

---
Memo5.Lines.BeginUpdate;
Memo5.Lines.Clear;
ProgressBar1.Max := QP.PageCount;

for Page := 1 to QP.PageCount do
begin
  QP.SelectPage(Page);
  ProgressBar1.Position := Page;

  Memo5.Lines.Add('Page ' + IntToStr(Page) + ' has ' +
 IntToStr(QP.AnnotationCount) + ' annotations');
  for AnnotIndex := 1 to QP.AnnotationCount do
  begin
 AnnotType := QP.GetAnnotStrProperty(AnnotIndex, 101);
 Memo5.Lines.Add('Annot number ' + IntToStr(AnnotIndex) + ' on this page has type: ' + AnnotType);
  end;

  Memo5.Lines.Add('');
end;
---
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 09 at 1:34AM
This is an enhanced version of the Delphi Sample Code:

---
QP := TQuickPDFQVer.Create;
 try
   QP.UnlockKey(' ... ');
   QP.LoadFromFile('annots.pdf');

   for Page := 1 to QP.PageCount do
   begin
     QP.SelectPage(Page);
     Memo1.Lines.Add('Page ' + IntToStr(Page));
     for AnnotationIndex := 1 to QP.AnnotationCount do
     begin
       Memo1.Lines.Add('  Annotation ' + IntToStr(AnnotationIndex));
       Memo1.Lines.Add('    Type: ' +
         QP.GetAnnotStrProperty(
AnnotationIndex, 101));
       Memo1.Lines.Add('    Contents: ' +
         QP.GetAnnotStrProperty(
AnnotationIndex, 102));
       Memo1.Lines.Add('    Name: ' +
         QP.GetAnnotStrProperty(
AnnotationIndex, 103));
       Memo1.Lines.Add('    Subject: ' +
         QP.GetAnnotStrProperty(
AnnotationIndex, 127));
       Memo1.Lines.Add('    Left: ' +
         FormatFloat('0.00', QP.GetAnnotDblProperty(
AnnotationIndex, 105)));
       Memo1.Lines.Add('    In reply to: ' +
         FormatFloat('0.00', QP.GetAnnotIntProperty(
AnnotationIndex, 128)));
     end;
   end;
---
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