Open in Read Only mode - View only mode.

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Open in Read Only mode - View only mode.

Post by espens »

Is it possible to open a document in Read Only mode? E.g. it should not be possible to edit any content, just view.

I want to user to make an explicit choice if they want to edit a doc.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Open in Read Only mode - View only mode.

Post by Tracker Supp-Stefan »

Hello espens,

Is this the option you need?
https://sdkhelp.pdf-xchange.com/vie ... t_ReadOnly

Regards,
Stefan
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Open in Read Only mode - View only mode.

Post by espens »

No, not really. That would not prevent the user from adding pages etc. to the open document. What I'm trying to achieve is to to use the editor as a viewer.

I guess I could set the edit commands offline, and only enable them when needed.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Open in Read Only mode - View only mode.

Post by Ivan - Tracker Software »

The best way to do that is to set permission mask when you open document. But please note, you cannot change them without reopening the document.

To do so, you have to specify int value SecPermMask in open document params.
For example, to make document read only you have to specify the following mask:

Code: Select all

ATL::CComPtr<IPXV_Inst> pInst;
...
ATL::CComPtr<ICab> pOpenParams;
pInst->CreateOpenDocParams(&pOpenParams);

{
     ATL::CComPtr<ICabNode> pOpenParamsRoot;
     pOpenParams->get_Root(&pOpenParamsRoot);
     int secPerms = PermF_All & ~(Permit_Copying_And_TextGraphicsExtractions | Permit_Printing | Permit_HighQualityPrinting);
     pOpenParamsRoot->SetInt("SecPermMask", secPerms);
}
ATL::CComPtr<IPXV_MainFrame> pMainFrm;
pInst->get_ActiveMainFrm(&pMainFrm);

pMainFrm->OpenDocFrom(pDocSrc, pOpenParams);
HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Open in Read Only mode - View only mode.

Post by espens »

Setting the security like this also disables the possibility to drag from the thumbs viewer onto a new page. Is it possible to enable the possibility to Drag a page out of a read-only document? would think that enabling Permit_Copying_And_TextGraphicsExtractions also would allow drag out.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

Enabling the Permit_Copying_And_TextGraphicsExtractions flag will allow copying and extraction of the content. Thus the read only mode won't be valid anymore.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Open in Read Only mode - View only mode.

Post by espens »

What I want is that when a document is opened it should not be possible to edit it or save it back to it's original location.

A user would need to create a new document from the existing one by dragging pages onto a new document (+ tab).
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Open in Read Only mode - View only mode.

Post by Ivan - Tracker Software »

In that case enabling Permit_Copying_And_TextGraphicsExtractions should help.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Open in Read Only mode - View only mode.

Post by espens »

Drag ann Drop from thumbs viewer is turned off until I turn on Permit_Assemble. Unfortunately that override Permit_Modification in that I can now drag and drop pages from other documents into this document (if source document is opened with full permissions). But I'm not able to drag pages out of a document opened with the security set to:

PermF_All and ~(
Permit_Copying_And_TextGraphicsExtractions || Permit_Printing || Permit_HighQualityPrinting
|| Permit_Assemble )

But I need it the other way around and one should never be able to modify a document if Permit_Modification is set.

Neither am I allowed to drag a page from the document opened with these flags unless I also clear 0x2. If cleared I'm allowed to drag pages from the document and onto the (+) tab. But I'm not allowed to drag pages from the locked down document and onto the thumbs of new document.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Open in Read Only mode - View only mode.

Post by Tracker Supp-Stefan »

Hi espens,

It's still 2:27 AM where Ivan is - but I've asked him to follow up in this topic when he can.

Regards,
Stefan
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Open in Read Only mode - View only mode.

Post by Ivan - Tracker Software »

As I see here is a bug with checking permissions on drag&dop operation start.
Will fix it. This fix will be available in next build.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Open in Read Only mode - View only mode.

Post by espens »

I'm also able to place a stamp on a read-only document.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Open in Read Only mode - View only mode.

Post by Ivan - Tracker Software »

fixed
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
cmarsura
User
Posts: 91
Joined: Fri Jun 15, 2007 9:57 am
Location: Italy

Re: Open in Read Only mode - View only mode.

Post by cmarsura »

Tracker Supp-Stefan wrote:Hello espens,

Is this the option you need?
https://sdkhelp.pdf-xchange.com/vie ... t_ReadOnly

Regards,
Stefan
Hi,
how can I grab the IUIX_Edit Interface ?
Can you provide an image or description on how to navigate the various interfaces?
Not all the interfaces are used in the SDK Sample, so is a bit difficult glean out the various interface dependencies.

Thanks.
Carlo
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

What did you mean by grab? For example, you can create IUIX_Edit by using https://sdkhelp.pdf-xchange.com/vie ... CreateEdit
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cmarsura
User
Posts: 91
Joined: Fri Jun 15, 2007 9:57 am
Location: Italy

Re: Open in Read Only mode - View only mode.

Post by cmarsura »

I am replacing your PDF Viewer with the Editor version.

I need to put readonly the control as I was doing in the viewer using the CoPDFXCview.ReadOnly property, but I don't want to go through the OpenDocFrom because I does not have a handy IStream implementation in VB6.

My need is simply to access the actual IUIX_Edit interface instance (or a simular one) buried somewhere after I load a pdf with the OpenDocFromPath() to set the ReadOnly property afterward.

Sadly, if I search in your help site the IUIX_Edit, the interface is not returned in the results when it appears as method parameter, so I learned to search into the IDL.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

I think you misunderstood what the IUIX_Edit is - it's an edit field object on the dialog. Setting it's ReadOnly value would disable only this edit's input.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cmarsura
User
Posts: 91
Joined: Fri Jun 15, 2007 9:57 am
Location: Italy

Re: Open in Read Only mode - View only mode.

Post by cmarsura »

OK, I chosed the wrong interface.

But:
A) how can I put the control in readonly mode? The various editing tools should be disabled.
B) there is a way to hide the purple/green banners appearing when a PDF/a file is loaded or it have form fields into? Being the control used in readonly mode I do not need such messages.
cmarsura
User
Posts: 91
Joined: Fri Jun 15, 2007 9:57 am
Location: Italy

Re: Open in Read Only mode - View only mode.

Post by cmarsura »

Any news ?
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Open in Read Only mode - View only mode.

Post by Ivan - Tracker Software »

A) how can I put the control in readonly mode? The various editing tools should be disabled.
The control has no read only mode. Instead you can open document with restricted editing features as shown some posts above (https://forum.pdf-xchange.com/ ... 66&p=94315). Please note that the sample works for OpenDocFromPath() method as well.
B) there is a way to hide the purple/green banners appearing when a PDF/a file is loaded or it have form fields into? Being the control used in readonly mode I do not need such messages.
In new build of the Editor it will possible to hide Doc Info bar (or its parts) using IPXV_DocInfo bar that unfortunately is not published in current build.

HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Open in Read Only mode - View only mode.

Post by docu-track99 »

Pls disregard this post...:lol:
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Open in Read Only mode - View only mode.

Post by Tracker Supp-Stefan »

Hi docu-track99,

OK - switching on "actively disregard forum posts" mode :D

Seriously though - I hope you found out what you were looking for!!!

Cheers,
Stefan
docu-track99
User
Posts: 518
Joined: Thu Dec 06, 2007 8:13 pm

Re: Open in Read Only mode - View only mode.

Post by docu-track99 »

Thanks Stefan, I did. I was wondering where PermF_All, Permit_Copying_And_TextGraphicsExtractions were coming from, and then I was able to find them here https://sdkhelp.pdf-xchange.com/vie ... PermsFlags and here https://sdkhelp.pdf-xchange.com/vie ... ermissions.

For anyone interested, here's the subroutine I use in VB.Net to set these read-only params:

Code: Select all

Private oReadOnlyParams As ICab
...
    Private Sub SetReadOnlyParams()
        Try
            oReadOnlyParams = pdfCtrl.Inst.CreateOpenDocParams()
            Dim pOpenParamsRoot As ICabNode = oReadOnlyParams.Root
            Dim secPerms As Integer = PXC_PermsFlags.PermF_All And Not (PXC_SecurityPermissions.Permit_Copying_And_TextGraphicsExtractions Or PXC_SecurityPermissions.Permit_Printing Or PXC_SecurityPermissions.Permit_HighQualityPrinting)
            pOpenParamsRoot.SetInt("SecPermMask", secPerms)
        Catch ex As Exception
            'Catch Errors Here
        End Try
    End Sub
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

Hello docu-track99,

Thanks for the VB.Net sample :wink:
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
anovy
User
Posts: 164
Joined: Mon Feb 08, 2010 8:48 am

Re: Open in Read Only mode - View only mode.

Post by anovy »

Hi,
This thread helped me to open document in read-only mode, however I need also a method how to recognize that any opened document is in such mode. Please advise.

Thank you.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

Hello anovy,

You can store that information in your code, because only you know what are you setting in the read-only mode.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
anovy
User
Posts: 164
Joined: Mon Feb 08, 2010 8:48 am

Re: Open in Read Only mode - View only mode.

Post by anovy »

Hi,

Meanwhile I changed my code to test the operation permissions (via IPXC_Document::RequestPermission) instead of testing read-only mode. It is sufficient for my needs.

However there is another issue with the read-only mode (as set by the method advised here). It causes that the page extraction is also denied, although this is 'read-only' operation. The Viewer SDK and its ReadOnly mode retains page extraction permission.

So is there some way in Editor SDK how to set this read-only mode and retain page extraction?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Open in Read Only mode - View only mode.

Post by Sasha - Tracker Dev Team »

Hello anovy,

I will ask the developer who is responsible for the security and will reply.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ