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 - CapturePage and Existing Comments/Annotations
  FAQ FAQ  Forum Search   Register Register  Login Login

CapturePage and Existing Comments/Annotations

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


Joined: 11 Jan 12
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote NBachus Quote  Post ReplyReply Direct Link To This Post Topic: CapturePage and Existing Comments/Annotations
    Posted: 31 Mar 14 at 9:17PM
When using CapturePage() and DrawCapturedPage() (we're transforming the image to add margins), the existing Comments/Annotations entered in on Adobe Reader are not transferred over to the new "page".  I've tried to use CombineContentStreams() to combine all of the content into one stream, but this does not help the issue.  Does anyone have any ideas on how to solve this?
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: 01 Apr 14 at 6:43AM
NBachus,

Annotations are not part of the normal content stream which the CapturePage functions uses. Either are formfields as they are also based on annotations.

Annotations are a special type of object that is draw after the rest of the page is drawn.  They are not designed to be scaled easily.  You can adjust their bounding box but that is the easy bit.  You would need to adjust for line thickness and font height also.

There is going to be no elegant or easy solution to this.  

Another option to scaling the page may be to create a new content stream at the start of the file and another at the end to simulate the CapturePage/DrawCapturePage.  See the code below.  This will keep all of the annots but you will need to move each one manually into position.

// Pseudo code

  QP.LoadFromFile("myfile.pdf", "");

  // add a loop here for multipage documents to process each page.

  int idx = QP.NewContentStream();
  string s = "q 0.7 0 0 0.7 72 96 cm "; // space at the end, set transformation matrix
  QP.SetContentStreamFromString(s);
  QP.MoveContentStream(idx, 1);        // move the content stream to the front of the list.

  idx = QP.NewContentStream();
  string s = "Q ";   // space at the end, restore State command
  QP.SetContentStreamFromString(s);
  
  QP.SaveToFile .....

-------------------------------------------------------------------------------------------

// C# version

            QP.LoadFromFile("myfile.pdf", "");

            Byte[] b;
            ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

            int idx = QP.NewContentStream();

    // This does all of the scaling.
            // A transformation matrix -  0.7 = xscale, 2nd 0.7 = yscale, 72 = horz offset, y = vert offset
            // The scale is for the overall size and the offsets move the page from the bottom corner
            // and position it where required.
            string s = "q 0.7 0 0 0.7 72 96 cm "; // space at the end, set transformation matrix

            b = encoding.GetBytes(s);
            QP.SetContentStreamFromString(b);
            QP.MoveContentStream(idx, 1);        // move the content stream to the front of the list.

            idx = QP.NewContentStream();
            s = "Q ";   // space at the end, restore State command
            b = encoding.GetBytes(s);
            QP.SetContentStreamFromString(b);

            QP.SaveToFile("out.pdf");

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