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

SetOptionalContentVisible

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


Joined: 23 Apr 13
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisMorgan Quote  Post ReplyReply Direct Link To This Post Topic: SetOptionalContentVisible
    Posted: 23 Apr 13 at 5:47PM
Hi group,
I am trying to use SetOptionalContentGroupVisible to hide some PDF layers in an existing PDF,
and then use the RenderPageToFile option to save a page as a new image file.
The image file always comes out blank.

Using Debenu 9.13, Delphi 2006

Here is my code:

         i := pdf.UnlockKey(<REGISTRATIONKEY>); // single developer licence code
         if i<>1 then raiseError;

         i := pdf.LoadFromFile(FPDFfilename,'');
         if i<>1 then raiseError;

         // get PDF layer names
         pdf.UseUnsafeContentStreams(1);
         imax := pdf.OptionalContentGroupCount;
         OutputDebugString(pchar(Format('PDF Layer Count: %d',[imax])));
         for i:=1 to imax do begin
            id := pdf.GetOptionalContentGroupID(i);
            s := pdf.GetOptionalContentGroupName(id);
            OutputDebugString(pchar(Format('PDF Layer: %d Name: %s',[id,s])));
         end;
         // turn off anno layer?
         pdf.SetOptionalContentGroupVisible(1476395013,Ord(false));

         i := pdf.RenderPageToFile(FRes,FPageNum,FImageFmt,FPDFTempImage);
         if i<>1 then raiseError;

The image created by RenderPageToFile always comes out blank if I try to use SetOptionalContentGroupVisible to hide any of the layers in the PDF file.
Am I calling the functions in the right order?
Anything else I am doing wrong?

Thanks,

Chris

Back to Top
ChrisMorgan View Drop Down
Beginner
Beginner


Joined: 23 Apr 13
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisMorgan Quote  Post ReplyReply Direct Link To This Post Posted: 24 Apr 13 at 3:48PM
An update to my previous post.
If I add

pdf.SaveToFile('c:\temp.pdf');

after calling SetOptionalContentGroupVisible, then the temp.pdf has the specified layer correctly turned off.
It is just the RenderPageToFile function which seems to be ignoring my layer visibility preferences.

Any help? Thanks,

Chris
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: 01 May 13 at 5:31AM
Hi Chris,

Some changes that you make to a PDF won't be applied until the PDF is saved. So try adding SaveToString and then LoadFromString prior to rendering the page.

I hope this helps.

Cheers,
- Rowan.
Back to Top
ChrisMorgan View Drop Down
Beginner
Beginner


Joined: 23 Apr 13
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisMorgan Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 13 at 9:34AM
Hi Rowan,

I am afraid this makes no difference.
I have tried various combinations of SaveToString/LoadFromString and even SaveToFile/LoadFromFile. The reloaded PDF does have the layer visibility that I set, but the image that is created by RenderPageToFile either shows all of the layers or none of the layers - a blank image.

Thanks,

Chris


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 13 at 1:53PM
Chris,  

There has been some recent work done in this area of the library but these changes should be in 9.13 already.  Can you create an official support case and send me the problem PDF file and I will see what is going on.


Andrew.
Back to Top
ChrisMorgan View Drop Down
Beginner
Beginner


Joined: 23 Apr 13
Location: United Kingdom
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChrisMorgan Quote  Post ReplyReply Direct Link To This Post Posted: 08 May 13 at 2:03PM
Hi Andrew,
I have already created a support case - 18739. On 1/5/2013 I sent a sample PDF and a source code for a simple Delphi 2006 console program that illustrates my problem.
I can send it again if needed.

Thanks,

Chris
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