PDF Preview in Snippet Web Part Works for PDF With Original File Name, Not For Copy W/Other Name

Copper Contributor

First a list of the conditions

  1. Working with REST API
  2. Working with copy of site's "Home.aspx" (default home page) in 'Site Pages' doc lib, in classic experience mode (I am not the admin, but that's how they want it for now)
  3. Using a Snippet web part, I have used Edit Source ribbon to add HTML directly (text, anchor elements). I also cut an <iframe>element from a modern experience web part construction for a PDF and inserted it in the Snippet source window for the PDF to be shown. It all has been working nicely so far.

I have now created an HTML web form within a page in 'Site Assets' doc lib. Part of the action of this form is to use a drag and drop for an MPP and a PDF of this MPP file. These files are put in the 'Documents' doc lib ('Shared Documents') by the script, and then the script gets the 'Home.aspx' file with the REST API. It looks for the Wikifield property that is part of Site Pages .aspx files with web parts like Snippet, which would allow editing like "Edit Source" through the SharePoint page/ribbon. The script's job is to replace the anchor element 'href' attributes for an MPP file and the PDF of that MPP file, and also to change the iframe element attributes string values that control the displayed PDF in that web part.

 

Within the iframe 'src' attribute, there is a property UniqueId which can be read from the uploaded files (or is it 'items'?). Getting the UniqueId values from the uploaded files in their document libraries, the values can be used to do a string replacement of what's in the text of the Wikifield property of the Home.aspx page.

 

Now here's the problem: when I refresh the modified 'Home.aspx' page, all the changes of the strings in the anchor elements are there, and the changes to the UniqueId string in the iframe elements references the target PDF correctly. But the PDF shows no preview as it did with the replaced PDF. It says the PDF has no preview and offers a download link. Since the PDF uploaded is just a copy of the PDF replaced but with a different filename, what happened? Is there a property inherent in the PDF file that does not get copied with that PDF copy? Or is there something in the Snippet web part that has been altered? The Wikifield property reference the Snippet source shows string changes only in the desired parts of the property value. And the same is found in the SharePoint page of "Home.aspx":  (Edit Page => Format Text => Edit Source)

0 Replies