How to set document to IsDirty or equivalent

PDF-XChange Editor SDK for Developers

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

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.
RMan
User
Posts: 239
Joined: Tue Jul 02, 2013 10:06 pm

How to set document to IsDirty or equivalent

Post by RMan »

We have a case where we are converting a file format to a PDF in the users temporary folder then bringing the temporary PDF file we created into the editor. Everything works but we want it to work like a new document where we provide the name we think the user will want to use but have them be prompted to save the file when they try to close it or exit the PDF-XChange Editor and to where they cannot undo it so much that it doesn't prompt them to save it.

Using C++ as the programming language

I can get the value using IPXC_DocSrcInfo::IsDirty Property

But there is not way to set the property to true
pSourceInfo->put_IsDirty(true);

Any suggestions
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13093
Joined: Wed Jan 03, 2018 6:52 pm

Re: How to set document to IsDirty or equivalent

Post by Daniel - PDF-XChange »

Hello, RMan

I have raised this with the Devs for input -hopefully they can get back to us shortly.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13093
Joined: Wed Jan 03, 2018 6:52 pm

Re: How to set document to IsDirty or equivalent

Post by Daniel - PDF-XChange »

Hello again

I have just heard back from the dev team, here was their reply:
Misha wrote:The `IPXC_DocSrcInfo::IsDirty` property only determines whether a document has been modified, which is why it is read-only and does not have a `put` method.

However, in their post, the user notes that their workflow includes converting to PDF, which is exactly what makes the document modified. But it seems they first save the file to a temporary folder and then open it to demonstrate to the user; in this case, the saved document will no longer be considered modified.

I believe the following approaches could be useful for the user to solve their problem:

- The first method:
In their current scenario, it is worth skipping the intermediate step of saving the document and displaying it to the user immediately after conversion. The document will indeed be new and modified.

- The second method:
1) The file should be opened using the "Temp" option (for more details, see `IPXV_Inst::CreateOpenDocParams` Documentation - https://sdkhelp.pdf-xchange.com/view/PX ... nDocParams). This will prevent a direct "Save" operation to avoid overwriting the current file in the temporary folder, and will always force the "Save As" option instead.
2) Using the `IPXV_Document::Modified` property, they can manually mark the document as modified, which temporarily changes the UI-flag only. Alternatively, they can use the `IPXV_Document::SetModified` method to actually mark the document as modified.

Additionally, in both scenarios, by using `IPXC_DocSrcInfo::CustDispFileName`, they can specify the name that will be used in the "Save As" feature."
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
RMan
User
Posts: 239
Joined: Tue Jul 02, 2013 10:06 pm

Re: How to set document to IsDirty or equivalent

Post by RMan »

Thanks that works for one case.

Another case I forgot to mention is when we are using a IPXV_ImportConverter:Convert Method and have to return a IPXC_Document** pDoc for the Open Dialog to handle. Is there a way to handle it in that case?

IPXV_ImportConverter::Convert Method
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 13093
Joined: Wed Jan 03, 2018 6:52 pm

Re: How to set document to IsDirty or equivalent

Post by Daniel - PDF-XChange »

Hello, RMan

Glad to hear it, i have passed your new question along for review as well - and will be back when possible!

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
[email protected]
User avatar
MishaH
User
Posts: 35
Joined: Wed Sep 11, 2024 1:43 pm

Re: How to set document to IsDirty or equivalent

Post by MishaH »

Hello, RMan

Thank you for clarifying your workflow.
Now I guess that you are working on your own implementation of 'IPXV_ImportConverter', which helps a lot in understanding the likely context of the issue.
If you could share your conversion workflow, we might be able to help you improve it to avoid that extra file saving to the disk altogether.

However, we have some ideas that should make your current workflow scenario work as expected. Combining the 'IPXC_DocSrcInfo::IsVirtualPDF' property and the 'IPXV_Inst::ModifyCoreDoc' method should work, and you can implement it like this:

Code: Select all

// Forces the use of "Save As" instead of a direct "Save"
pDocSrcInfo->put_IsVirtualPDF(VARIANT_TRUE);
// Performs a document modification to mark it as dirty/modified
pxvInst->ModifyCoreDoc(pCoreDoc, PXC_DocModifyType::DocModify_Do);
Additionally, if you want the temporary file to be automatically deleted from the temporary folder once it is no longer needed (when the document is closed), you can use the 'IPXC_Document::DeleteOnClose' property:

Code: Select all

pCoreDoc->put_DeleteOnClose(VARIANT_TRUE);
Please let us know if this solution works for you.

Kind regards,
Misha