Javascript function importAnFDF always shows the file dialog

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

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

Post Reply
dboef
User
Posts: 4
Joined: Wed Oct 05, 2022 4:26 pm

Javascript function importAnFDF always shows the file dialog

Post by dboef »

Hello,

I want to import annotations from an FDF file using javascript and the function importAnFDF. According to the API reference this function has a parameter cPath where you can specify the path. However when using this function like importAnFDF("<path>") the file dialog still appears, and the cPath parameter is ignored.

When using the function exportAsFDF this problem does not occur, and the FDF file is created at the location provided by the cPath parameter. without a file dialog appearing.

How can I import an FDF through javascript without the file dialog appearing?

I'm using version 9.4 build 364.0

Kind regards,
David
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: Javascript function importAnFDF always shows the file dialog

Post by TrackerSupp-Daniel »

Hello, dboef

Are you using the fullpath in the <path> section of your JS, or are you simply entering the filename? If you are only entering the filename, as in the JS API reference manual's example, you will need to ensure that the fdf file in question is located in the same folder as the PDF you are running this import in. Otherwise, it would be best to use the complete path, including "C:\...\etc" leading up to the file.

If that is still not working, please send me a copy of the string you are using, so that we can take a look and see if there is a typo or something that is causing the issue.

Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
dboef
User
Posts: 4
Joined: Wed Oct 05, 2022 4:26 pm

Re: Javascript function importAnFDF always shows the file dialog

Post by dboef »

Hello Daniel,

I am using the full path as the parameter

For exporting I use:

Code: Select all

exportAsFDF(true, true, null, true, "C:\\PDF\\test.fdf", true);
This creates the test.fdf file in the directory C:\PDF as expected.

I then clear the annotations in the file and try importing them.

For importing I use:

Code: Select all

importAnFDF("C:\\PDF\\test.fdf");
This shows the file dialog instead of directly importing the annotations. (If I use the file dialog the annotations are imported correctly)

I've attached the annoted pdf I'm using for testing
test.pdf
(4.93 KiB) Downloaded 11 times
:

Kind regards,
David
User avatar
rakunavi
User
Posts: 871
Joined: Sat Sep 11, 2021 5:04 am

Re: Javascript function importAnFDF always shows the file dialog

Post by rakunavi »

Hello dboef,

Sorry for interrupting. When specifying a file path in PDF JavaScript, formally it must be a device-independent path. Try the following.

Code: Select all

importAnFDF("/C/PDF/test.fdf");
  • File paths in Acrobat JavaScript
    https://acrobatusers.com/tutorials/file-paths-acrobat-javascript/
Best regards,
rakunavi
TOP desires for PDFXCE
forum.pdf-xchange.com/viewtopic.php?t=39665 LassoTool
forum.pdf-xchange.com/viewtopic.php?t=38554 CmtGarbled
forum.pdf-xchange.com/viewtopic.php?t=37353 FulScrMultiMon
forum.pdf-xchange.com/viewtopic.php?t=41002 DisableTouchSelect
dboef
User
Posts: 4
Joined: Wed Oct 05, 2022 4:26 pm

Re: Javascript function importAnFDF always shows the file dialog

Post by dboef »

Hello rakanuvi.

Thank you. It works now.

Kind regards,
David
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Javascript function importAnFDF always shows the file dialog

Post by Tracker Supp-Stefan »

:)
Post Reply