Web App accessing pdf images in SpecialFolder.Documents

I have a lot of images in pdf format and would like to access them in a webImageViewer by their names, which are lost if I drag them into the app.

I’ve tried using the imageViewer Browse Picture feature but it doesn’t accept the pdf images and I’d like to refer to them in a code loop anyway rather than Browse manually.

I’ve tried putting SpecialFolders.Documents/myfolder/myfolderImages/“picture1.pdf” in the URL path but that doesn’t work.

Is there any way of doing this?

You cannot use .Child("sub-folder").Child("sub-folder") in Web projects ?

On the web you have to be sure files are publicly accessible and provide means to access them.

Yes. Are you using Xojo Cloud, Lifeboat, or rolling your own? With Lifeboat you can create a Static Files directory to serve files like PDFs, CSS, scripts, and images. In my opinion, serving the files outside of Xojo is the best option. I think there’s a way to do so on Xojo Cloud as well, but you’ll have to ask them for instructions.

Alternatively, there are ways to serve the PDF from Xojo. One option is to write your own file serving routine in HandleURL. Another way would be to read the PDF into memory and serve a WebFile.

Not every browser / computer can display PDFs, you might want to use this workaround (via @Martin_T in another thread)

var url as String = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
WebHTMLViewer1.LoadURL("https://drive.google.com/viewerng/viewer?embedded=true&url=" + url)

Be sure to check out Lifeboat which helps developers deploy Xojo Web applications and serve normal websites with their own Linux server. I build it to help everyone get on the web, and it helps support my efforts to answer web questions in great detail :wink:

Thanks for that. At the moment, I haven’t selected a server as I am still developing my app working on my iMac but I was planning to try out Xojo’s version soon. However, I’ll look at Lifeboat first.

Doesn’t sound like there’s a simple way. I would have thought that when Xojo converts dragged image files into a “Picture” format, it should be possible to take files named c2.pfd or d5.jpg and convert them as Pictures named c2 or d5 rather then naming every file Untitled.

I’m not sure you’re asking the question you want to ask, but I’m having trouble trying to figure out what your goals are.

Xojo doesn’t convert anything when you drag and drop it into the IDE. It can make a reference to some file types so you can access these files in your code globally by name, but this isn’t a conversion of any kind.

If you have a folder full of PDFs that you’d like to include with your app, you could use a Copy Files step to make sure they’re bundled into your application’s resources. You would still need to serve the files by some means. A Copy Files step would be a good way to be sure that your PDFs are included in both debug mode and for deployed builds.

Hopefully one of these two details helps you figure out what you need!

Well, I have a set of 52 playing card images and 4 jokers to make a 108-card deck. I started with .svg files as the suit symbols started off as .svg files in my graphics program (Affinity) and when I exported the complete cards as .svg they made great small file sizes. But the rank numbers and letters were getting font substituted in the export. I tried using .png as I have transparent areas but this made the files considerably larger so I settled on .pdf format, which treats both the rank characters and the suit symbols as curves. So these files are all named for example c2.pdf to c14pdf for the Club suit and similarly for the Diamond, Heart and Spade suits. The naming helps me create instances of my Card Class, with a WebContainer and an embedded WebImageViewer, which I can populate with the images in a loop.

Of course, every time I tweak these images and drag them into the App, they become Picture objects as far as Xojo is concerned but their names are all changed to Untitled, meaning I have to change them all back again.

I simply want to be able to refer to c2, c3 etc as Pictures in the loop I use to populate the Class instances and not have to go through the renaming process every time I rethink the cards. A Copy Files Step sounds interesting. What would that entail?

What export? I’m sure Web2 can handle .svg

Check out the documentation for Copy Files

Some notes: You will lose the ability to refer to the card faces globally by name in your code. You will have to create load routines to read the cards out of the folder you add to the resources with Copy Files.

FWIW, someone with game development experience might solve this by creating one giant sprite-sheet with every card and then the card objects would display the correct section. This would require web development knowledge in conjunction with the Xojo WebSDK so it would not be the most Citizen Developer friendly way to approach the problem. It would however be resource efficient.

Alberto, that’s the export from Affinity Designer’s native file format to svg. You can import files in various formats as well as use its own graphic creation tools and it amalgamates the elements into a finished file that you can export as svg or in various other formats. It seems to export everything it can in the required format and somehow packages the rest. With pdf, it seems to be fine with the bits that started off as svg and it exports the fonts as curves, so long as you tell it to.

I would add a copy file build step to copy the folder containing your images to the resources folder. You can then access them using SpecialFolder.Resources.Child([yourfoldername]).Child([yourimagename])