Are there any open source BlackBerry PDF renderer application. I have searched for PDF viewer, could not find any. Any suggestion would be appreciable.
use google viewer inside your Browserfield, that will do the trick! =D!
public ScrLoad()
{
String url = "http://docs.google.com/gview?embedded=true&url=http://prueba.agenciareforma.com/appiphone/android/elnorte.pdf";
add(new BrowserField(url));
}
Google Docs Viewer http://docs.google.com/gview
JPedal: http://www.jpedal.org/java_me_pdf_viewer.php
Related
In Android, I want to test PDF which contains terms and conditions, but this displayed inside WebView. I am able to switch to WebView, I am using below code.
String strWebContextName = getContexts().stream().filter(ctx -> ctx.contains(“WEBVIEW_”)).findAny().orElse(null);
if (Objects.nonNull(strWebContextName)) {
((AndroidDriver) getBaseMobileDriver()).context(strWebContextName);
}
Then locate the script tag and get the content
#FindBy(xpath = “//script[#type=“text/javascript” and contains(text(),”_init")]")
private WebElement webElementPdfPath;
String htmlCode = (String) ((JavascriptExecutor) getBaseMobileDriver()).executeScript(“return arguments[0].innerHTML;”, webElementPdfPath);
After this I don’t know how to proceed? Please help
In my experience with verifying PDF's in a WebView is that there is only limited you can search for with selectors. I'm used to only class or type attributes of the PDF container. I have never been able to search for specific text in an PDF with XPath (PDF's are also not part of the HTML but more an extension which opens the document).
Try a simpler XPath: //script[#type='text/javascript']. This way you know the PDF is opened, but that's all.
I've done this with desktop browsers as well. For browsers, there is no way to identify inner PDF elements, but only limited to: //embed[#type='application/x-google-chrome-pdf']. If I needed to verify the PDF with conditions I've used SikuliX image recognition for instance.
I'm all new to Xamarin and I'm currently working on a sample or a "prove of concept" app using Xamarin.Forms.
I'm supposed to perform a print task from this app though I'm not at this point sure what to print yet (the screen, content of a label, a file etc.).
Either way, what is the easiest way to print from a Xamarin.Forms app?
(current target is primarily Android 4.4+).
I hope this isn't too complicated :)
EDIT:
Ok let me just update this post as the original text might be a bit ambitious/vague.
I have a Xamarin.Forms project (+ an Android part) and I have some HTML available in the XF part of the project that I need to get into a WebView and print it.
From what I understand, the thing with the WebView has to be done on the Android part of the project due to the fact that this is where the printing will be handled.
I was hoping this could be done from code since I don't really need to display the WebView, just print it's content.
The Android part of the project has only the MainActivity and no layouts or XAML files.
I don't know where to add the WebView or how to access it (other than DependecyService seems to be a buzz word here) so I'm kinda stuck here.
I'm thinking that this task should be rather trivial to someone with a little more Xamarin experience than me.
Every platform XF supports has it's own mechanism for printing. XF does not provide any abstractions for printing in a cross-platform manner. You will need to write printing logic for each layer and expose it to XF using DependencyService (or some other DI engine).
Here is a good example, of course, using dependency service:
https://codemilltech.com/xamarin-forms-e-z-print/
I so wanted to do this but it was too hard. Finally built it into Forms9Patch - a MIT licensed open source project.
Verifying that Printing is available
Before printing, you should verify that printing is available on your device. To do so, call:
if (Forms9Patch.PrintService.CanPrint)
{
// do the printing here
}
Print the contents of a Xamarin.Forms.WebView
using Forms9Patch;
...
var myWebView = new Xamarin.Forms.WebView
myWebView.Source = new HtmlWebViewSource
{
Html = "some HTML text here"
};
...
myWebView.Print("my_print_job_name");
Note that your WebView does not have to be attached to a Layout. This allows you to Print without having to display the WebView in your app’s UI.
Printing an HTML string
using Forms9Patch;
...
var myHtmlString = #"
<!DOCTYPE html>
<html>
<body>
<h1>Convert to PNG</h1>
<p>This html will be converted to a PNG, PDF, or print.</p>
</body>
</html>
";
...
myHtmlString.Print("my_print_job_name");
PLEASE NOTE: iOS sometimes places the page breaks in weird places. I have a StackOverflow Bounty on why this happens and how to fix it.
Using EmbeddedResource as a source for a Xamarin.Forms.WebView
This is sort of an experimental feature I’ve built that I’ve found it useful. As such the documentation is sparse. It allow you to put HTML content in a folder in your app’s EmbeddedResources folder and then use it as a source for a WebView. A much nicer solution than using platform specific approach provided by Xamarin. It also supports putting all of the HTML content into a zip file. Please take a look at the source code to see how it works.
You can handle the printing of lists/ invoices .. with the xfinium pdf component from xamarin componentstore. With that you create your _pdffile and then call the following method which starts the adobereader from where you can select a printer (in my case google cloudprint)
public void printPdfToCloud(string _pdffile)
{
try
{
var saveto = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), "YourApp/"+_pdffile);
string file_path = saveto;
if (System.IO.File.Exists(file_path))
{
Android.Net.Uri pdfFile = Android.Net.Uri.FromFile(new Java.IO.File(file_path));
Intent pdfIntent = new Intent(Intent.ActionView);
pdfIntent.SetPackage("com.adobe.reader");
pdfIntent.SetDataAndType(pdfFile, "application/pdf");
pdfIntent.SetFlags(ActivityFlags.NoHistory);
StartActivity(pdfIntent);
}else
{
// give a note that the file does not exist
}
}
catch (Exception E)
{
// Do some Error dialog
}
}
I'm building an app using Cordova and I used this Plug-in to print the content of an HTML page. I would try to print this to a PDF, not using AirPrint printer.
How can I do it (also by modifying .m and .h files in the Plugin Folder)?
Here's the plugin I've used: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/PrintPlugin
Thank you!
var html = document.getElementById("printHTML").innerHTML;
window.plugins.printPlugin.print(
html,
function(result) {
alert("Printing successful");
},
function(result) {
if (!result.available){
alert("Printing is not available");
}
else{
//Localised error description
alert(result.error);
}
});
Let me know if you find a better answer as I am looking for the same solution. In the meantime, what I have done is open up a browser in a new window (skip the plugin all together) and run the html-document through pdfcrowd.com. Then I use airprint directly from the browser.
I have looked everywhere for this solution. The code below allows me to print to the printer, Adobe PDF, but what I want to do is automate the file name save as screen with a generic name and in a specific folder. For example, the file would be saved to C:\temp\tmpResize.pdf and I am having problems there.
var params = this.getPrintParams();
params.interactive=params.constants.interactionLevel.silent;
params.pageHandling=params.constants.handling.none;
params.fileName = "/c/temp/tmpResize.pdf";
params.printerName="Adobe PDF"
this.print(params);
Thanks for your help.
Is it possible render a PDF object using Primeface 3.4 and DefaultStreamedContent? This used to work for us in Primefaces 2.2:
Backing Bean:
streamedDoc = new DefaultStreamedContent(pdfStream, "application/pdf");
...
public StreamedContent getStreamedDoc() {
return streamedDoc;
}
view:
<object id="embeddedPDF"
data="?primefacesDynamicContent=confirmForm.streamedDoc#toolbar=0?docId=456"
type="application/pdf"
width="100%"
height="1610px"/>
But after upgrading to 3.4, the PDF doesn't get rendered. We don't get an exception. We simply get this Abode Reader error in the browser:
Adobe Reader could not open 'A9RE0BF.tmp' because it is either not a supported file type or because the file has been damaged. (for example, it was sent as an email attachment and wasn't correctly encoded)."
Any ideas?
What about using the primefaces lightbox and the media components?
http://www.primefaces.org/showcase/ui/multimedia/media.xhtml
http://www.primefaces.org/showcase/ui/overlay/lightBox.xhtml
You can see the PDF inside the lightBox, I think it's more elegant.
Anyway just with the media one you can solve your problem I guess.
Regards.