PDF Editing Issues

How to Create a PDF Link That Opens an Attached KMZ File

Olivia MillerOlivia Miller Nov 5, 2026 869 views

Question details

The user needs to create a clickable link inside a PDF document that triggers an attached KMZ file to open directly in Google Earth.

How to Create a PDF Link That Opens an Attached KMZ File
Product
PDF
Device & OS
not provided
Scenario
Adding interactive links to a PDF to launch specific non-PDF file attachments for readers.
Observed behavior
The author wants the link action to successfully trigger the extraction and launching of a specific KMZ attachment when clicked.
Before you start

Ensure that the KMZ file is already embedded in your PDF document as an attachment and that the computer viewing the PDF has Google Earth installed and associated with the .kmz file extension.

Solution 1Recommended

Use JavaScript to Launch the Attached KMZ File

Create a custom link action using JavaScript to export and launch the non-PDF attachment directly from the document.

Standard PDF link actions often struggle to directly launch non-PDF attachments due to security and compatibility constraints. By using Acrobat JavaScript, you can instruct the PDF reader to export the attached file to a temporary location and prompt the operating system to open it in its default application (like Google Earth).

1
Embed the KMZ Attachment

Open your PDF editor, navigate to the Attachments panel (usually represented by a paperclip icon), and add your target KMZ file to the document. Note the exact file name, such as 'MyFile.kmz'.

2
Create a Link Tool Box

Select the 'Link' tool from the Edit or Tools menu. Draw a clickable rectangle over the specific text or image on the PDF page where you want the link to be.

3
Set Action to Run a JavaScript

In the Link Properties dialog box, switch to the 'Actions' tab. Click the 'Select Action' dropdown menu, choose 'Run a JavaScript', and click the 'Add' button.

4
Enter the Launch Script

In the JavaScript Editor window, paste the following code: this.exportDataObject({cName: "MyFile.kmz", nLaunch: 2}); Make sure to replace "MyFile.kmz" with the exact name of your attached file, keeping the quotation marks.

5
Save and Test the Link

Click 'OK' to close the editor and properties windows. Save your PDF document. Click the newly created link to verify that it extracts the file and prompts Google Earth to open.

Use JavaScript to Launch the Attached KMZ File
Security Prompt Notification: Launching external attachments via JavaScript may trigger a security warning in standard PDF readers. The user reading the PDF will need to approve the prompt to allow the file to open.

Easily Manage PDF Links and Attachments with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to effortlessly embed file attachments, create interactive document links, and manage your PDF navigation efficiently.

  1. 1. Open your PDF: Launch WPS Office and open your target PDF document in the WPS PDF editor.
  2. 2. Insert the Attachment: Navigate to the Insert tab, click on the 'Attachment' icon, and select your KMZ file to embed it securely into the document.
  3. 3. Add Interactive Links: Go to the Edit tab, select 'Link', and draw a box over your text. Configure the link properties to connect to your desired action or file.
  4. 4. Save the Document: Click 'Save' or press Ctrl+S to ensure your embedded files and interactive links are properly stored within the PDF structure.
Seamlessly insert, extract, and manage PDF file attachmentsIntuitive link creation tool for text, images, and page navigationHigh compatibility with standard PDF formats, Adobe Acrobat, and other viewersLightweight desktop application with a user-friendly interface
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't the KMZ file opening when I click the PDF link?

This usually happens due to PDF reader security settings blocking JavaScript actions, or because the .kmz file extension is not associated with Google Earth on your operating system. Ensure Google Earth is installed and check your reader's trust settings to allow attachment extraction.

Can I link to a specific 3D view in the KMZ file from the PDF?

No, the PDF link only triggers the operating system to launch the KMZ file in its default application. Specific views, layers, or coordinates must be configured and saved within the KMZ file itself before you attach it to the PDF.

Do I absolutely need to use JavaScript to link to a PDF attachment?

For non-PDF attachments like KMZ, ZIP, or Excel files, standard PDF link actions cannot directly launch the embedded files in most viewers. Using Acrobat JavaScript (specifically the exportDataObject method) ensures the file is passed to the OS to open properly.

Will the attached KMZ file still work if I email the PDF to someone else?

Yes. Because the KMZ file is embedded directly into the PDF as a document attachment (rather than just linking to a path on your local hard drive), it will travel with the PDF. The recipient simply needs a PDF reader that supports JavaScript and to have Google Earth installed.