I would like opening documents in a Xamarin Forms app possibly without writing platform-specific code.
Documents could be PDF or Word files and I do NOT want to open documents inside the app, rather I want to use the default app: default Pdf Reader and Word (if installed). Any idea?
I am trying by using Device.OpenUri(new Uri("file:///Assets/pdf-sample.pdf")) and setting PDF file Build Action=Embedded Result, unfortunately without success.
You can do it simply with webview (there goes an example: https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/)
Related
I'm working on a project in .net that has a need for a document preview function.
I've implemented a Webview2 control and, as the majority of doucments that need to be viewed are pdf, this works a treat.
However, now and again some documents may be in either docx or xlsx format.
When I set webview2.Source = New Uri(PathtoFile) on these files, the webview2 control downloads the document to my downloads folder rather than rendering it.
I get that the files are not HTML, but then again neither are PDFs and they work out of the box.
Is there some mechanism I'm missing whereby I can have the Webview2 control display the file contents for docx and xlxs rather than download?
We are having the same problem ourselves. At the moment we are using a product called Aspose that will allow us to convert Word Documents to XPS, after which we can display the document in a Document Viewer.
While this works, and it works well, the main problem is that this relies on us downloading the document, then converting it and then loading the converted document into the Viewer. Which causes a certain perception of "sluggishness" due to all of that work, whereas images and PDFs, especially when hosted on the Web, can be hosted directly in the WebView2 and this then leaves the rest of our application nicely responsive to user interaction.
So in case anyone comes up with a better suggestion, I'm following this ...
The code using Aspose is pretty straightforward (example in Visual Basic .NET):
Dim oDoc As Aspose.Words.Document = Nothing
oDoc = New Aspose.Words.Document(sFile)
oDoc.Save(fileName:=sToFileName, saveFormat:=Aspose.Words.SaveFormat.Xps)
(left out all error handling and so on in order to focus on the actual functionality. sToFileName just contains a filename along the lines of [somefolder][yourtargetfilename].xps ...)
I guess you may try to convert DOCX to PDF directly via Aspose.Words and XLSX to PDF via Aspose.Cells. Both these APIs support rendering to PDF or even image formats. Since your viewer supports to view PDF or images, so you may try this approach, it might work for your needs.
PS. I am working as Support developer/ Evangelist at Aspose.
I would like to ask the following if possible. We have a client that wants a separate pdf document, embedded in a main pdf document and opens when you click it. Like the function in MS Word where you can attach another Word document inside a Word document (Word-ception, lol) and you can still open it.
I've tried it in Acrobat Pro with the Attachment and Link tools. Another option was to put the link document in an ftp server for accessibility. but our client really wants this functionality. Is this possible in Indesign?
Thank you!
Using Word as your example vehicle there are several ways to link 2 documents.
One is an appendix to the other, in PDF terms is a merge or binding but its one flowing document with separate sequential sections/chapters.
Another way is to link to an external file, in PDF terms a hyperlink to a relative second file, which can be locally folder relative or a web absolute reference. You have tried that.
In Word we can add objects internally with icons, in PDF that can be an annotation comment attachment to save externally and action accordingly. You also seem to discount that approach.
Finally PDF offers an Adobe Specific Structure where multiple PDFs attachments can be imbedded in an overall PDF wrapper. These are called Portfolios and not! to be confused with their portfolio service
They are unpopular since in a browser without Adobe Reader they should only offer the cover page.
Whilst in securer offline readers the files may well be shown as attachments that you need to save or independently open to view them.
Only some non Acrobat viewers may view them as a collection. And in the past that required runing insecure SWFlash, But I understand that has changed ?
Here is how the 3 internal PDF files seen above were shown in older Acrobat 9.
Possibly the best experience is using Foxit Reader
When I open a certain pdf file on SharePoint, I wish to see the Bookmarks Navigation tab open by default. I can do this manually by File > Properties > initial View and changing the Navigation tab to "Bookmarks Panel and Page".
I need to do this with hundreds of pdf files and then upload them to SharePoint.
I am using VBA. I don't mind using other forms of automation.
Currently, I have AVDoc (CAcroAVDoc) and can open the Bookmarks Pane but it's not changed in the settings.
AVDoc.SetViewMode 3
I tried PDDoc.SetInfo etc but nothings changing the "settings".
Any suggestion will be appreciated.
I am running a lot of code in Excel VBA, that does a lot of pdf manipulation. The only thing that remains is to change the settings.
With Acrobat as the runtime, there is no scriptable interface to the initial view settings. However, you can easily use any of several .NET PDF libraries to make this change. A Google search for ".NET PDF Library" will yield both free and commercial varieties. You'll need to research which one is best for your task and skill set.
Please, help me and tell me what am I missing.
My goal is to display simple PDF file (stored locally for example) in the WebView control. Can I bind path of the file to the Source property of the WebView? Or what is the correct way to show PDF in UWP?
P.S. and if the only option is to do like here - how must I add pdf.js to my project??
My goal is to display simple PDF file (stored locally for example) in the WebView control.
If you want to display pdf in WebView control, then the methods in Display a Local PDF File in a WebView is most like the only way to solve your problem.
You can follow the steps in the xamarin official document, and here are some additional tips we need to pay attention to:
After downloading pdfjs, for UWP app, you need to copy the entire folder into the Assets folder, make sure that the folder is named "pdfjs", otherwise you will need to modify the code to change the path.
Your .pdf file should be stored into the Content folder under the Assets folder, it means you will need to create a new folder named "Content" under Assets and copy your .pdf file into this folder. Otherwise, you will also need to modify the code to change the path.
After copying your .pdf file into the "Content" folder, don't forget to change the Build Action of this file to Content like this:
Or what is the correct way to show PDF in UWP?
In uwp app, you can use Image to show PDF file, you can refer to the official PDF document sample. But I don't know if PDF can be displayed as Image in Android and IOS apps, since you're developing a cross-platform project, I think it's better to use the built-in method to solve such problem.
If a demo for xamarin UWP is needed, you can leave a comment, I will upload my demo later.
This is not a back-end programming question. I can only modify the markup or script (or the document itself). The reason I'm asking here is because all my searches for appropriate terms inevitably lead to questions and solutions about programming this functionality. I'm not trying to force it via progrmaming; I have to find out why this PDF is behaving differently.
So:
I have a bunch of links to PDFs on a page. Most of them open in new tabs, but one of them, the most recent, starts to open in a tab, but then the tab closes and the PDF gets downloaded as a file instead. All markup is consistent - there's nothing differnt about the odd-man-out except the actual URL.
You can see this here:
http://calwater.mwnewsroom.com/Investor-Relations/Financial-Reports/Annual-Reports
All annual reports up to 2012 open in a new tab, but 2013 downloads instead.
This leads me to believe that there is some meta-data property of the PDF itself that tells it how to open, and that, in this case, the 2013 PDF was created using different settings.
Apparently, the PDF was saved out to PDF from InDesign.
Does anyone have any insight?
Problem solved. There was simply an error in the string (like an extra period) that references the attachment such that it couldn't tell it was a PDF. Fixing the reference fixed the problem.