iOS 9 "Save PDF to iBooks" with HTML - html

iOS 9 has a new built-in UIActivity of UIActivityTypeOpenInIBooks. It's in the default list of activities in the UI and in header file but I've not been able to find any API documentation for it (yet).
It appears that UIActivityTypeOpenInIBooks will create a PDF in iBooks just fine if you include UIImages in your UIActivityViewController items or return them in your UIActivityItemProvider.
However I'd like to create a PDF with an HTML page containing text and images like Safari does. But I can't seem to find a way to pass the HTML to UIActivityTypeOpenInIBooks in an acceptable way.
I've tried passing the HTML as a String, NSData and NSURL of a file. I've also tried returning an UIMarkupTextPrintFormatter which works fine for printing but not for UIActivityTypeOpenInIBooks.
Providing an HTML string or the UIMarkupTextPrintFormatter both result in the following errors:
2015-09-08 11:35:46.392 MyApp[4599:1492484] ERROR: attempting to save to URL with no printing source (formatter/renderer) set
2015-09-08 11:35:46.393 MyApp[4599:1492484] FAILED! due to error in domain UIPrintErrorDomain with error code 4
Has anyone gotten this working?

You can convert the html to pdf before saving it to ibooks.

Related

Error with generate and downloading MVC view to PDF function (Itext - System IO.IO this document has no pages)

I'm new to ASP.NET MVC and not that good with coding. I'm trying to download my returned list from view as a PDF document
The exact error I get is:
System.IO.IOException
HResult=0x80131620
The document has no pages.
Source=itextsharp
StackTrace:
at iTextSharp.text.pdf.PdfPages.WritePageTree()
at iTextSharp.text.pdf.PdfWriter.Close()
at iTextSharp.text.pdf.PdfDocument.Close()
at iTextSharp.text.Document.Close()
My controller with function
My view html
Your problem is in your jquery and your html, you are not passing any values into your div, your table is also not in your div. Thus jquery is pulling nothing, that means that your stream is getting no bytes.

Fetching HTML or links from a website via Json/HtmlUnit

I have been trying to extract the html values from a page e.g. https://www.qwant.com/?q=cat&t=web but when I use jSoup or HtmlUnit I always get a basic page that doesn't compare to what is generated when I search via my normal browser.
My codes in general work on other websites but could someone explain to me why when I visit the above with code that I don't get the same results? I am trying to fetch all the url values on the page. Is it to do with javascript?
WebClient wb = new WebClient(BrowserVersion.FIREFOX_52);
wb.getPage(url);
wb.waitForBackgroundJavaScript(25000);
System.out.println(wb.getCurrentWindow().getEnclosedPage().getWebResponse().getContentAsString());
Some website just won't allow you to parse them headlessly (for obvious reasons). As I tried to curl the Qwant cat result page, the result was a blank page.
But you want to give a try at switching from Firefox to Chrome as your browser : It is not possible to detect and block Chrome headless

htmlRenderer.PDFSharp not converting labels

I am trying to get familiar with htmlRenderer.pdfsharp and have come across an issue that I am trying to figure out. It is not rendering the following HTML:
<td><label for=\"Date\">Date</label></td>
The code I am using to generate the PDF is from one of their examples but it is as follows:
PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.Letter);
The rest of the HTML is populating just fine and am not sure where to go from here with the HTML Renderer. Anyone else ran into this issue and have a fix?
Edit: I removed calling it PDFSharp's html render and linked to the nuget package I am using for htmlRender.pdfsharp.

Opening a local XML file in Google Chrome

Our tool will look like below
Input an XML file.
Click Load button will do transformation of the XML file and display it in a table format.
Currently the tool is working fine in IE and Firefox. Now we have the requirement to support it for Chrome also.
Inside html file JavaScript, we are doing the XML transformation using the XSLT file. For the purpose of loading XML we are creating a DOM object for different browsers as below.
if(window.ActiveXObject) {
XMLObject = new ActiveXObject('Microsoft.FreeThreadedXMLDOM');
}
else {
XMLObject = document.implementation.createDocument("", "", null);
}
But for Chrome we are not able to find the Compatible DOM object code. While searching in web found that the below code will work in Chrome.
XMLObject =new XMLHttpRequest();
Tried with the above method , but it is throwing the error “Cross origin requests are only supported for HTTP”.
Also while loading XML file found that the browser is not giving the correct path of the filename, instead its giving like C:\fakepath\Sample.xml.
Any other way to solve this issue?
If you want to use XMLHttpRequest to access files from the local file system then you have to start Chrome with the command line option --allow-file-access-from-files.

html is blank in a blackberry cascades webview (C++, QT, QML)

in Blackberry Cascades (C++, QT, QML), I am trying to read the html of a webview - but it is returning blank. This webview uses "setUrl(url") to set the url, and does not use "setHtml(html)". Anyway - I have this code:
WebView {
id: loginView
objectName: "loginView"
onMicroFocusChanged: {
console.log("html: " + html);
}
}
And the webview url has two textfields, and when I put my cursor into those text fields or when I type in them, the html of the webview shows up as blank - but I need to see the html, because I am trying to be able to parse that html to get the content of those textfields.
How come the html is blank - and how can I get access to this html?
The Html property of the WebView only returns the code that was inserted with setHtml. (Documentation)
Even if it did report code loaded from a web address, I doubt it would be updated with the current value of textboxes.
To read their content, I recommend you look into the messageReceived signal of the WebView. If you can change the html-code that contains your text boxes, you can use javascript navigator.cascades.postMessage() to send the data to your application.
If you do not control the html, you can still use the evaluateJavaScript method to extract the values of the textboxes with DOM functions from inside your app.