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 - DeleteOptionalContentGroup problem not save ?
  FAQ FAQ  Forum Search   Register Register  Login Login

DeleteOptionalContentGroup problem not save ?

 Post Reply Post Reply
Author
Message
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Topic: DeleteOptionalContentGroup problem not save ?
    Posted: 16 Oct 17 at 7:32AM
I was using this snippet to add OptionalContentGroup:

Local $iOCG1 = $oQP.NewOptionalContentGroup("POUCZENIE")
Local $iCS_Id = $oQP.NewContentStream()
$oQP.SelectContentStream($iCS_Id)
$oQP.SaveState()

$oQP.SetTransparency(0) ; no transparency

Local $iIDFont = $oQP.AddTrueTypeFont('Arial {1250}', 0)
$oQP.SelectFont($iIDFont)
$oQP.SetBreakString(@CRLF)

$oQP.SetLineWidth(1)
$oQP.SetTextColor(1, 0, 0)
$oQP.SetLineColor(1, 0, 0)

$oQP.DrawLine( _
$aMaxBoundaries[$QPDF_CSVTEXTCOL_X4LD], _
$aMaxBoundaries[$QPDF_CSVTEXTCOL_Y4LD] + 10, _
$aMaxBoundaries[$QPDF_CSVTEXTCOL_X3RD], _
$aMaxBoundaries[$QPDF_CSVTEXTCOL_Y3RD] + 10 _
)

If Not @Compiled Then _ArrayDisplay($aMaxBoundaries, '$aMaxBoundaries')

Local $iIDFont = $oQP.AddTrueTypeFont('Arial {1250}', 0)
$oQP.SelectFont($iIDFont)
$oQP.SetBreakString(@CRLF)
$oQP.SetTextSize(8)
$oQP.SetTextAlign($__eQPDF_TEXTALIGN_Justified)

Local $iPouczenieWidth = $aMaxBoundaries[$QPDF_CSVTEXTCOL_X3RD] - $aMaxBoundaries[$QPDF_CSVTEXTCOL_X4LD]
Local $iLeft = $aMaxBoundaries[$QPDF_CSVTEXTCOL_X4LD]
Local $iTop = $aMaxBoundaries[$QPDF_CSVTEXTCOL_Y4LD] + 20

_QPDF_SetDefaultCoordinates($oQP)
$oQP.DrawWrappedText($iLeft, $iTop, $iPouczenieWidth, $sPouczenie_Text)

$oQP.SetContentStreamOptional($iOCG1)
$oQP.SetOptionalContentGroupVisible($iOCG1, 1)
$oQP.SetOptionalContentGroupPrintable($iOCG1, 1)
$oQP.LoadState()



My problem is that currently I can not delete this OCG
$oQP.SelectContentStream(1)
MsgBox(0, 'Save ?', $oQP.ContentStreamSafe())
MsgBox(0, 'Delete Result:', $oQP.DeleteOptionalContentGroup($oQP.GetOptionalContentGroupID(1)))

So First MsgBox is saying 0 and second MsgBox is saying 1

But when I use 
$oQP.SaveToFile($sPDF_FileFullPath & '__Deleted_Pouczenie.pdf')

I still have this OCG visible in this PDF file.

Do I'm doing something wrong ?



Edited by mLipok - 16 Oct 17 at 10:18AM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 7:43AM
btw.
Foxit Quick PDF Library 14.11 Reference Guide.pdf

in description for .DeleteOptionalContentGroup

is not specyfing that return value are 0 or 1 but it is.

The return value is exactly like mentioned in Foxit Quick PDF Library 14 Developer Guide.pdf
If a function is not documented as having a return value then you can assume that a return value of one (1) indicates success. A returning value of zero (0) indicates failure. Other returned values indicate valid handle or ID and what this ID is for can be determined by the function name.

so the return Value for .DeleteOptionalContentGroup is showing properly 1 and 0 for example when I select non existen OCG.




Edited by mLipok - 16 Oct 17 at 7:43AM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 7:45AM
The other question is why 
$oQP.SelectContentStream(1)
MsgBox(0, 'Save ?', $oQP.ContentStreamSafe())

is saying 0

??


As I showed before I used QPDF to create this OCG

Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 8:06AM
Originally posted by mLipok mLipok wrote:

The other question is why 
$oQP.SelectContentStream(1)
MsgBox(0, 'Save ?', $oQP.ContentStreamSafe())

is saying 0

??


As I showed before I used QPDF to create this OCG


Now I figured it out.
$oQP.ContentStreamSafe() was saing 0 as I need also select Page
$oQP.SelectPage(2) MsgBox(0, 'Select Result', $oQP.SelectContentStream(1)) MsgBox(0, 'Save ?', $oQP.ContentStreamSafe())

I figured it out when I was trying to use:
$oQP.SetOptionalContentGroupVisible($iGroupID, 0)
$oQP.SetOptionalContentGroupPrintable($iGroupID, 0) 

Which was not working until I use $oQP.SelectPage(2)

But .DeleteOptionalContentGroup is still not working even if I select proper page.



Edited by mLipok - 16 Oct 17 at 8:16AM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 8:28AM
QUESTION:
Do you know any way to find on which page is located specyfic OCG ?

Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
ukobsa View Drop Down
Senior Member
Senior Member


Joined: 29 May 06
Location: Germany
Status: Offline
Points: 115
Post Options Post Options   Thanks (0) Thanks(0)   Quote ukobsa Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 3:59PM
Hi,

just tested it with this code (14.11): and here the second PDF do no longer have the OCG layer (just the layer; content is still visible)


  lPDF  := TDebenuPDFLibrary.Create;
  try
    lPDF.SetOrigin(1);
    lPDF.AddStandardFont(1);
    lPDF.DrawText(100, 50, 'Regulärer Text');

    lPDF.NewContentStream;
    lPDF.DrawText(100, 100, '1. Layer DUMMY added');

    nOC := lPDF.NewOptionalContentGroup('DUMMY');
    lPDF.SetContentStreamOptional(nOC);
    lPDF.SetOptionalContentGroupVisible(nOC, 0);

    lPDF.SaveToFile('.\test_oc_dummy.pdf');

    nRes := lPDF.DeleteOptionalContentGroup(nOC);
    // nRes is set to 1 when executing

    lPDF.SaveToFile('.\test_oc_dummy_del.pdf');
  finally
    lPDF.Free;
  end;


Does this help?
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 7:16PM
Thanks. I will give it a try. And back with results.

Edited by mLipok - 16 Oct 17 at 7:17PM
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 7:36PM
Your example is like this:

    ......
    lPDF.NewContentStream;
    lPDF.DrawText(100, 100, '1. Layer DUMMY added');

    nOC := lPDF.NewOptionalContentGroup('DUMMY');
    lPDF.SetContentStreamOptional(nOC);
    lPDF.SetOptionalContentGroupVisible(nOC, 0)
    .......

My is like this:

    ......
    nOC := lPDF.NewOptionalContentGroup('DUMMY');
    lPDF.NewContentStream;
    lPDF.DrawText(100, 100, '1. Layer DUMMY added');

    lPDF.SetContentStreamOptional(nOC);
    lPDF.SetOptionalContentGroupVisible(nOC, 0)
    .......

I'm wondering if I doing this wrong ?

Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 9:51PM
@ukobsa
I have used your example in AutoIt and I have such example:

Func _Example2()
Local $oQP
If _QPDF_CreateObjectAndUnlock($oQP) = $QPDF_RET_VALID_COMMERCIAL Then
$oQP.SetOrigin(1) ;
$oQP.AddStandardFont(1) ;
$oQP.DrawText(100, 50, 'Regulärer Text') ;

$oQP.NewContentStream ;
$oQP.DrawText(100, 100, '1. Layer DUMMY added') ;

Local $iOC = $oQP.NewOptionalContentGroup('DUMMY') ;
$oQP.SetContentStreamOptional($iOC) ;
$oQP.SetOptionalContentGroupVisible($iOC, 0) ;

$oQP.SaveToFile(@ScriptDir & '\test_oc_dummy.pdf') ;

Local $iRes = $oQP.DeleteOptionalContentGroup($iOC) ;
MsgBox(0, '$iRes', $iRes)
;~     // $iRes is set to 1 when executing

$oQP.SaveToFile(@ScriptDir & '\test_oc_dummy_del.pdf') ;
EndIf
EndFunc   ;==>_Example2

The results are here:
http://lipok.pl/Debenu/test_oc_dummy.pdf
http://lipok.pl/Debenu/test_oc_dummy_del.pdf

REMARK: 
Downlad this two files, and open in AcrobatReader not in GoogleChrome or in any other WebBrowser.


You should notice that:
test_oc_dummy_del.pdf

still contains "1. Layer DUMMY added" text .


I expected that deleting OCG would also remove all content inside this OCG.

But that did not happen.
Question is :  Why that did not happen ?

Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 16 Oct 17 at 10:31PM
Hi :)

here are two links with similar problems.
The second one was the interesting one for you.
Rowan is telling there something about the meaning of these OptionalContentGroups and why the content is still there obviously you've deleted the OCG ;-)
http://www.quickpdf.org/forum/delete-optionalcontentgroup_topic3253.html
http://www.quickpdf.org/forum/help-with-detecting-visible-ocgs-and-removing-ocgs_topic3153.html

Cheers,
Ingo

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