Save As after Signed document  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

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

byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Save As after Signed document

Post by byman64 »

I am searching a way to adapt the save as default folder after signed a document.

In short I have the following folder structure
Company A\Invoice\In approval
Company A\Invoice\Approved

Company B\Invoice\In approval
Company B\Invoice\Approved

Company C\Invoice\In approval
Company C\Invoice\Approved

When I sign a pdf from "\In approval" I would like as default path "Approved" . I mean same path of original pdf but "..\approval".

Or one of the following works around:

1# If it's possible use an argument from command line when I open a new pdf from my application. But I didn't see mentioned save as on documentation :-(
2# Force to read the settings->Document->save on specific folder.
(I can change the registry value every time I open a PDF from my application "iCustomSaveAsFolder".
It worls only if PDF XChange is not already open when I open a new PDF. It will works after I close and open PDF XChange.

Other suggests?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Save As after Signed document

Post by Stefan - PDF-XChange »

Hello byman64,

Welcome to our forums.
The Save As... default location can be controlled through the Editor's Preferences (Ctrl + K) -> Documents -> Save Documents and this drop down:
image.png
While not exactly what you want - it's possible that you can e.g. force the default path to Company A\Invoice\ so you would then only need to click one folder to go into the correct one you need.

Kind regards,
Stefan
You do not have the required permissions to view the files attached to this post.
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

Thanks for your reply.

I know that preference, Documents -> Save Documents but it's static. It will be always the same.

I have around 14 folders with the same structure: one for each company and inside 2 folders "In approval" and "approved".
I need to save the pdf signed in the "approved" folder.

I would like control the destination path folder for each pdf based on his own folder structure.
For example it would be good through command line argument .
Something like this one:
PDFXEdit.exe SOURCE_PDF TARGET_FOLDER

Examples
"PDFXEdit.exe" c:\docs\company a\in approval\mydoc001.pdf c:\docs\company a\APPROVED
"PDFXEdit.exe" c:\docs\company b\in approval\mydoc123.pdf c:\docs\company b\APPROVED

Source is the file to sign and Target is the folder to use for the specific PDF and it would be the default for SAVE AS Dialogue Box.
Annoy every time navigate in the folder to pick up the right APPROVED folder.

It would be useful without play with folder every time sign a pdf

I hope it's clear my need: I don't want to choose the folder SAVE AS every time I sign a PDF. It's tedious.

COMMAND LINE OPTIONS
I dont see any option to help me :-(
https://help.pdf-xchange.com/pdfxe8/ind ... ns_ed.html
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Save As after Signed document

Post by Stefan - PDF-XChange »

Hello byman64,

If you are looking at automating that signing process - you can use PDF Tools - and it can then work with relative folders:
image.png
I just tried it out with the above settings - and with my original file being in an
\test\input folder - I correctly got my result file in the output one:
image(1).png
If you are doing the signing manually inside the Editor - then the best you can do is use the "Original Document Folder":
image(2).png
And then when presented with the "Save As" dialogue to go one folder up and then get to the desired output folder.

Kind regards,
Stefan
You do not have the required permissions to view the files attached to this post.
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

Thanks for your reply.

Relative Path + Variable could be a solution.

In the guide for command line arguments I noted this one:

PDFXEdit.exe /runjs "c:\AddDraftStamp.js" "c:\example.pdf"

I read that Javascript could change the save as path folder.

It would be my favorite solution because when I launch from my custom application PDF Xchange editor to open a PDF file I already know which is the target.

I found 2 pieces of code. As is they are no sense but I understant that Javascript could be a good way.

Any suggest?

Code: Select all

// This one works but path is full path
this.saveAs("/c/temp/02.APPROVED/" + this.documentFileName);

// This one with relative path NOT working :-(
this.saveAs("../02.APPROVED/" + this.documentFileName);

Where find all properties and method for this object?
For example this.FolderName not exists but I am sure this contains folder name


KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Save As after Signed document

Post by KD952 »

Hello byman64!

The following JavaScript works for me:

Code: Select all

// Split Path into an array so it is easy to work with
var aMyPath = this.path.split("/");

// Remove old file name + Current folder Name
aMyPath.pop();
aMyPath.pop();

// Add new folder Name + new file name
aMyPath.push("Approved" , this.documentFileName);

// Put path back together and save
this.saveAs(aMyPath.join("/"));
I also made a folder level JavaScript for you.
SaveasApproved.zip
This is a program you need unzip and copy to the JavaScripts folder. -> see here https://www.pdf-xchange.com/knowledgeba ... the-Editor

If you choose to use the folder level JavaScript, you just need to press the following icon in your "Add-on Tools" - Toolbar:
image.png


Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Save As after Signed document

Post by Stefan - PDF-XChange »

Hello Daniel,

Many thanks for sharing this code with all!

Kind regards,
Stefan
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

@Daniel
Thanks for all.

1# I downloaded the zip file and js file stored on %appdata%\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts

2# I tried to paste and run your JS in the Javascript console and seems there is an error in the icon creation. See screenshot
I don't know correct to run with console or not. I just tried.
3# I added the label name "Save As Approved" and removed the icon option and I see it on "Add-on Tools"

RECAP
1# I need to fix the icon trouble (syntax error), I could try an icon from PDF-XChange. How?
2# When I click on "Sign Document" the save as dialog box will appear.
I would like sign, see my signature and then click on SAVE AS APPROVED from Add-On Tools.


Here the current javascript

Code: Select all

var mySaveas = app.trustedFunction( function() { 
	app.beginPriv();

// Split Path into an array so it is easy to work with
var aMyPath = this.path.split("/");

// Remove old file name + Current folder Name
aMyPath.pop();
aMyPath.pop();

// Add new folder Name + new file name
aMyPath.push("Approved" , this.documentFileName);

// Put path back together and save
this.saveAs(aMyPath.join("/"));

app.endPriv();
});

// var myIcon = ... CODE removed

// add js-Button
app.addToolButton({
    cName: "mySaveas",
    cLabel: "SAVE AS APPROVED",   
    cExec: "mySaveas()",
    cTooltext: "Save to the Approved folder",
    cEnable: true,
    nPos: -1
});
Maybe I am just tired, time to sleep now. But pls some other help to fix the syntax error.
image.png
You do not have the required permissions to view the files attached to this post.
KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Save As after Signed document  SOLVED

Post by KD952 »

Hello byman64!

Try this one:
SaveasApproved_1.1.zip


What Version are you on?

Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Save As after Signed document

Post by Stefan - PDF-XChange »

:)
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

@Daniel
Version SaveasApproved_1.1.zip works fine:
1. I stored the script in %AppData%\Roaming\Tracker Software\PDFXEditor\3.0\Javascripts
2. In Add-on Tools I see icon and it works fine: save current file on ..\Approved

My PDF-XChange editor Version: 8.0 build 336.0

it is installed on my Own PC but in Office PC. I don't know how works the license plan but I suppose I should ask to buy an upgrade for latest version.

All would works fine except:
1. "Sign Document" fails because it launch SAVE AS Dialogue box. I have to use your script.
2. If I add "Sign Document" icon in Add-On Tools it will be removed when program start again.
I would like 2 icon in the same toolbar:
a) "SAVE AS APPROVED" b) "SIGN DOCUMENTS"

Toolbar, command, "SAVE AS APPROVED" not found. I suppose it's not a command for PDF-XChange Editor


I don't see any option in the preferences.
image(1).png
image.png
image(2).png
You do not have the required permissions to view the files attached to this post.
Last edited by byman64 on Tue Apr 30, 2024 3:44 pm, edited 2 times in total.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Save As after Signed document

Post by Stefan - PDF-XChange »

Hello byman64,

Yes - signing a file with a digital certificate would always need to save the file so that the digital signature can be properly applied. There is no way around that I am afraid.

Kind regards,
Stefan
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

@Stefan

With other software you can sign the document, see the stamp and the real file signed will be created only when the PDF is saved or saved as
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11036
Joined: Wed Jan 03, 2018 6:52 pm

Re: Save As after Signed document

Post by Daniel - PDF-XChange »

Hello, byman64

At this time we do not offer that functionality. As for the Add on tools function, this is an effect of how JS tool buttons exist. They are dynamically created each time the Editor starts, and the addon tools toolbar comes with them, it is not a persistent location, so it cannot hold new tools between application restarts, nor can the JS tools created on it be added to the Commands menu where you are looking for them.
It is possible for the JS to define which toolbar a tool is added to upon creation, but I do not have an example on hand at the moment. The JS API reference manual may help: https://opensource.adobe.com/dc-acrobat ... croJS.html

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
Support@pdf-xchange.com
KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Save As after Signed document

Post by KD952 »

Hello byman64!

I believe this is as far as we can go:
SaveasApproved_1.2.zip
Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
KD952
User
Posts: 109
Joined: Mon Feb 13, 2023 6:13 am

Re: Save As after Signed document

Post by KD952 »

Workflow would be as follows:
Workflow.gif
1. The program starts the sign document command.
2. When the save as dialogue is opened you automatically have the desired path in your clipboard.
3. press Ctrl + V to paste the path
4. press Enter
5. press Enter

Kind regards,
Daniel
You do not have the required permissions to view the files attached to this post.
byman64
User
Posts: 7
Joined: Mon Apr 06, 2009 10:50 pm

Re: Save As after Signed document

Post by byman64 »

@KD952
Tested you "Save A"s version 1.2...I approve it ;-)
I think it's an enough usable version.
I know Javascript and I use it for web. think I will use your script to understand how apply it to PDF-XChange

@ALL
Thanks for you support

THANKS SO MUCH.
GRAZIE MILLE, Ciao
Antonino Migliore
Italy
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Save As after Signed document

Post by Stefan - PDF-XChange »

Hello Antonino,

Happy to hear you got things working the way you need them!

And many thanks to @KD952 for the great help!

Kind regards,
Stefan