Print Page | Close Window

Flatten annotation in a PDF document

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2806
Printed Date: 04 Apr 26 at 3:08PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Flatten annotation in a PDF document
Posted By: kk aw
Subject: Flatten annotation in a PDF document
Date 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



Replies:
Posted By: kk aw
Date 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



Posted By: AndrewC
Date 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


Posted By: kk aw
Date 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



Posted By: AndrewC
Date 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.


Posted By: kk aw
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk