Print Page | Close Window

SetOptionalContentVisible

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=2606
Printed Date: 13 Jul 25 at 11:43PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: SetOptionalContentVisible
Posted By: ChrisMorgan
Subject: SetOptionalContentVisible
Date 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




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


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


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




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

http://www.debenu.com/support/contact/ - http://www.debenu.com/support/contact/

Andrew.


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



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