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!
![]() |
SetOptionalContentVisible |
Post Reply ![]() |
Author | |
ChrisMorgan ![]() Beginner ![]() Joined: 23 Apr 13 Location: United Kingdom Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
ChrisMorgan ![]() Beginner ![]() Joined: 23 Apr 13 Location: United Kingdom Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
Rowan ![]() Moderator Group ![]() ![]() Joined: 10 Jan 09 Status: Offline Points: 398 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
ChrisMorgan ![]() Beginner ![]() Joined: 23 Apr 13 Location: United Kingdom Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
ChrisMorgan ![]() Beginner ![]() Joined: 23 Apr 13 Location: United Kingdom Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store