I am using XE5 to create a mobile app and one thing I need to do is be able to download a PDF as a byte stream via a datasnap server, store it on the local device and then open it.
I have manage to download and store a PDF on the local device (not using datasnap server yet, but simply using an Indy HTTP control. This works okay for now and the document is definitely stored on the local device.
Now I am trying to open it and am struggling to figure out how to.
This filename points to the correct file:
filename := TPath.Combine(TPath.GetDocumentsPath, 'Test.pdf');
This points to
/Users/versodev/Library/Application Support/iPhone Simulator/7.0.3/Applications/96674DE6-7997-48F9-9892-1383EBCE473B/Documents/Test.pdf
I have tried using the Apple.Utils class in the samples folder and using SharedApplication.OpenURL but this does not work (even if I convert the filename to a NSUrl).
Interestingly though, the canOpenURL returns true.
Any ideas on how I can simply open a PDF document that is stored in the Documents folder of the app on the local device? I don't mind using a default app (eg Safari), or creating a control in my app to view it.
(I have tried using the UIDocumentInteractionController but am not totally sure how it works)
Related
I've been asked to add a file browser to an existing Objective C application that uses a WKWebView to load up a Javascript internal app.
Currently we have the capability of looking at the pictures on device to upload images into the app, but I've now been asked to do the same with more generic file types, specifically PDFs.
What I've read so far is that this is only possible if a file is stored in a specific part of the file system and only if the app knows exactly where the file is to begin with, but what I need is the capability to browse to a certain degree.
What I'd like to know is whether this is possible and if there is a good place to start on that?
Thanks.
I'm building an application in ColdFusion that lets the user choose a group of photos and will let them be printed automatically, however, I need to print the file and not the webpage holding the images. Is this possible with CFFILE? If not what is the best way to do this?
Dan's suggestion of an Active-X control (even if it's possible) will only work for MSIE 11 and earlier. Active-X will not work for MS Edge or any non-MS browser. It's not a global, future-proof solution.
The best solution will be to convert the images to a multi-page PDF file as TRose suggests. You will then present the file to the user to download or view in the browser. The user will have to manually print the PDF file.
Here's why: ColdFusion is a server-side applicaiton server. It crafts content that is viewable via a web browser. For security reasons, web browsers cannot automatically aceess a user's local computer(1) and therefore cannot connect to any printer connected to that computer.
(1) This is also why we can't upload files without user interaction.
I'm currently working on a intranet webapp for a company.
I've created it so the administrators of the site are able to upload files
(.docx, .pdf, .xlsx, .ppt etc) up to the webapp, to provide easier access
to documents for the employees. It works very well, however my client wasn't
too fond of having to download the files, and wanted it to pop up in the browser,
or open up the file-spesific program instead of download.
I was playing with some ideas:
1. Somehow parse the files to JSON at upload, and then show the content in browser with html.
2. Generate a pdf from the uploaded file (which automatically launches in the browser).
3. Somehow use a previewer to show the filecontent in the browser
4. Clients computer launches the uploaded file automatically on download, however I think this is a bit more tricky...
What would be the best and most time-efficient way to go about this?
It feels like what you actually want/need is a javascript document viewer (only) such as http://viewerjs.org/.
Assuming I have an app on iOS that generates a data file, and I would like the user the ability to import/export that file, how is that best done?
Import from email in xcode/objc:
http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app
Is this possible in Delphi? (i.e. register an ios app as file handler for a specifc file type)
(I am planning on handling export through generating an email attaching a file? I suspect this is probably possible although if anyone knows for sure, feel free to share)
It has been asked why import/export across email is useful.
Because legally EU/US law and cloud storage is difficult with personal data
You don't need any desktop computers
You can sync data between ios and android apps if user changes mobile
You are not bound to any specific cloud provider or anything similar
Quote from above article where author explains where the file path is passed to the app:
application:didFinishLaunchingWithOptions, passing the URL in the
UIApplicationLaunchOptionsURLKey, or via application:handleOpenURL.
But since I have not used Delphi for ages (for mobile), I would just like to know for sure if Delphi supports this or not before buying a new version
You can send files using email. I use the email component from D.P.F Delphi iOS Native Components to send file attachments using email. I don't see any reason why you should not be able to send your data file as long as it is not too big. Use a file extension that is unique to your app.
You could also use iTunes filesharing in order to give your users direct access to your data file. Just set the UIFileSharingEnabled key in your info.plist and store you data file inside of the documents folder. This does require a desktop PC, but it is still a very nice addition to sending backups by email.
Depending on your needs,
I would suggest looking at perhaps saving the file to a server using FTP and Indy and then on the other device you can retrieve it?
http://www.delphipages.com/forum/showthread.php?t=208397
Set the TidFTP connection parameters
Do a FTP put : // ftp.Put('testfile.txt');
Perhaps have a Database with a column that you specify a file version etc
Do a simple Get request if you want to retrive the file with the filename
or Alternatively you can save it to a blob field in a DB and have the other device read the blobfield if you don't want to do it via FTP
I'm having a little problem! I'm designing an asp mvc 4 application for a client which should import and process an excel file. To process the excel file I use the C# version of the NPOI framework.
My client uses mac and I use windows.
Everything works fine on windows but when my client tries it on his mac, it does not work anymore. After doing some searching I found that the content type of the uploaded file was "application/octet-stream" when uploading from mac (opposed to "application/vnd.ms-excel" when uploading from windows).
We use the exact same file, the only difference is that my clients file is saved on a mac and mine on a windows pc (we both got the same file from google docs).
It became weirder when he was experiencing the same error when he tried it on a windows pc with the file which was saved on mac.
Does anybody have an idea on what is going on? Or how I can get my NPOI processing working when the content type is "application/octet-stream"?
The browser can freely choose what content type to send. It could even send you "fluffy/bytes" if it wanted and you can't do anything about it. It appears that Safari on Mac does not know what an Excel file is so it does not send the Excel content type.
What is NPOI? Why does your application require that content type to be set? You can recognize that this is an Excel file by looking at the file extension that was posted. If neither content type not extension were posted (entirely possible) you can only guess by the file contents.