Select to view content in your preferred language

Open a PDF when Clicking on Polyline in Web Map

602
9
Jump to solution
04-07-2025 11:12 AM
Labels (1)
MHO_Harbors
Occasional Contributor

In AGOL Experience Builder, I want to build an app. The app should function like this: when a user clicks on a polyline in the map widget, the option to open a PDF about that polyline also appears. So maybe I have  a polyline outlining a construction area and in My Content I have a georeferenced PDF that is the actual site plan for the the area. When the user clicks on the polyline, an option to open the PDF should appear. I cannot seem to get the trigger in the map widget to work like this however. I have also added an Embed Button in the upper right thinking I can somehow link the URL of the PDF to it, and to the polygon in the map. I cannot figure it out though.  Any advice? Thank you.

 

ExpBuild.png

0 Kudos
1 Solution

Accepted Solutions
MHO_Harbors
Occasional Contributor

That's what happened actually. So I just converted the PDF to HTML code and host it on GitHub. So it's working. Thanks for the workflow!

View solution in original post

0 Kudos
9 Replies
JeffreyThompson2
MVP Frequent Contributor

This should be doable and you are on the right track with the Embed Widget.

  1. In your data, create a column containing URLs to the web address where the users can view your PDF for each feature.
  2. Add an Embed Widget.
  3. Use the Connect to Data option. Select the data layer and use the dropdown to pick Selected Features.
  4. Click Data Attributes (the little stacked circles) and select the column where you stored the URLs.
  5. In the Map Widget, add a Record Selection Changes > Widget Controller > Open Widget > Embed Action.

With this combo, clicking on the feature should pop open the Embed Widget and open it to the webpage with your PDF.

GIS Developer
City of Arlington, Texas
0 Kudos
MikeVolz
Frequent Contributor

If you have access to a web server with IIS, you could create a virtual directory that points to the pdf file location folder.  Then you could add a field in layer that concatenates the virtual directory with the specific file name in html format to access the pdf in your web app.  I have done this with numerous web apps at my org.

0 Kudos
MHO_Harbors
Occasional Contributor

Mike, thank you are you talking about something like Amazon Web Services? In this case, I believe the steps would be the same as Jeffrey's workflow above, but I'd be using a different URL? I think I would still have a problem opening the PDF in the embed window (please see my response above). When I use other URLs to regular websites (say www.esri.com) the website shows up in the embed folder, but this isn't the case for PDFs it seems. Maybe if I concatenate the virtual directory and the PDF file location folder the PDF shows like a regular web page?

Thanks for your help on this.

0 Kudos
MHO_Harbors
Occasional Contributor

I'm also thinking if I convert the PDF to HTML and host it on Github, that might be a work around too.

0 Kudos
MichaelVolz
Esteemed Contributor

Are you looking to have the pdf open in a different window of the same web page or will a new browser window open?

For my orgs apps a new browser window opens with below GIS feature class field value where target='blank' opens a new browser window

<a href="https://alias/'Virtual Directory'/'File name.jpg'" target='_blank'>View</a>

My org does not use SharePoint to store our images in public web apps.  We tried that, but I believe it might have worked inside the org but failed for the public app itself (Might have been a SharePoint access issue).

0 Kudos
MHO_Harbors
Occasional Contributor

Thank you! I will try it this afternoon and let you know how it goes.

0 Kudos
MHO_Harbors
Occasional Contributor

You nailed it. It opens in an embed window on the right. Thank you!

One problem however, and that's how the PDF displays. I have saved the PDF in Sharepoint and copied the URL and put it in a field in the layer's attribute table. When I click on a polyline, the attribute table opens with an opportunity to click on View in the URL field, but nothing shows in the Embed window. I am  wondering if text should pop-up in the embed window with a URL to the PDF that can be opened in a new window. Something like "Please click here to view the construction drawing."

But I don't know what the code would be to call the URL in the cell in the row that holds the URL:

Screenshot 2025-04-08 095855.png

 

0 Kudos
JeffreyThompson2
MVP Frequent Contributor

This may be your problem.

https://doc.arcgis.com/en/experience-builder/latest/configure-widgets/embed-widget.htm

Note:

If you choose to display a PDF directly in the Embed widget, some users may not be able to view it in certain browsers for security reasons.

GIS Developer
City of Arlington, Texas
0 Kudos
MHO_Harbors
Occasional Contributor

That's what happened actually. So I just converted the PDF to HTML code and host it on GitHub. So it's working. Thanks for the workflow!

0 Kudos