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 - Flatten annotation in a PDF document
  FAQ FAQ  Forum Search   Register Register  Login Login

Flatten annotation in a PDF document

 Post Reply Post Reply
Author
Message
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Topic: Flatten annotation in a PDF document
    Posted: 04 Jan 14 at 11:39AM
How do I flatten all the annotations (highlights) on a PDF document?  There are so many different functions, and I am not sure about the sequence of using them.

Any help would be appreciated.

KK Aw
Back to Top
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Posted: 05 Jan 14 at 2:57PM
I use the following routine to flatten the annotations.  

procedure TMainform.FlattenHighlights(Qp: TDebenuPDFLibrary0916);
var
  iPagecount: Integer;
  iAnnotCount: Integer;
  i, j: Integer;
  s1: string;
  retval: Integer;
begin
  iPageCount:= Qp.PageCount;
  With Qp do
    begin
      For i:= 1 to iPagecount do
        begin
          QP.SelectPage(i);
          iAnnotCount:= qp.AnnotationCount;
          for j:= 1 to iAnnotCount do
            begin
              s1:= qp.GetAnnotStrProperty(j, 101);
              If sm.equalIC(s1,'Highlight') then
                begin
                  retval:= qp.FlattenAnnot(j, 0);
                  if retval = 0 then
                    ShowMessage(Format('Annotation No. %d cannot be flattened',[j]));
                end;
            end;
        end;
    end;
end;

I have 4 highlights on the first page and two on the second.  
The results of my test are as follows:
a)  Four annotation were found on the first page.  The annotation type of 1 and 3 were blank.
b)  Annotation 2 and 4 were displayed correctly in my PDF previewer.
c)  On the second page, the first highlight covers the text.  The second highlight was displayed correctly.

What have I done wrong or are there bugs in GetAnnotStrProperty and FlattenAnnot?

KK Aw

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: 06 Jan 14 at 3:14AM
KK Aw,

When you flatten Annot 1 then Annot 4 becomes Annot 3, Annot 4 becomes Annot 2 and so on. You are calling FlattenAnnot(1); and then moving onto FlattenAnnot(2) not realising that the old Annot 2 is now Annot 1 and has been skipped.

Try this instead

 for j:= iAnnotCount down 1 do

Andrew
Back to Top
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Posted: 06 Jan 14 at 3:52AM
Thanks Andrew, I get the drift.

Now, my application recognizes all the highlights but on the first page, the highlights are not displayed.  On the second page, both the highlights are now opaque.

KK Aw

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: 06 Jan 14 at 10:50PM
KK Aw,
Is your PDF previewer based on Debenu Quick PDF Library and RenderPageTo... type functions ?

The current 10.11 version of Debenu Quick PDF Library doesn't fully support the rendering of transparency and this is most likely the cause of your problems.  The soon to be released 10.12 version of the library will have much improved support for transparency rendering.

If you would like to send us the PDF to support@debenu.com then we can do some further testing with the soon to be released 10.12 version.

Andrew.
Back to Top
kk aw View Drop Down
Team Player
Team Player
Avatar

Joined: 02 Feb 10
Location: Malaysia
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote kk aw Quote  Post ReplyReply Direct Link To This Post Posted: 07 Jan 14 at 2:25AM
Hi Andrew,

Yes, my previewer is based on Debenu Quick PDF Library and I use the RenderPageTo.. functions.  

I am using version 9.16, as you can see from the codes.  

I will send you the sample PDF for your testing.

KK Aw
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