What format does PrintDocument.getData() return? - android-service

I'm looking into what it takes to develop a PrintService on android. After reading some on-line docs I'm not quite clear on the format of data returned by PrintDocument.getData() method. I'd expect that in the case of PrintDocumentInfo.CONTENT_TYPE_PHOTO the returned data will be an image (I'm not quite sure about this). However, what can I expect when content type is CONTENT_TYPE_DOCUMENT?
There is a sample of PrintDocumentInfo that uses a builder to build a pdf file. Is this always the case? That is, is content of CONTENT_TYPE_DOCUMENT always in pdf format?
I'd appreciate any suggestions and/or pointers to relevant on-line docs.
Thanks.

It is always PDF for CONTENT_TYPE_DOCUMENT.

Related

Getting MP4 property data in VB.NET

I’d like to know if there’s any possible way i can get the file title or comments as a string in VB.NET. It’s easy to get the file name but the title under details in the actual files properties seems much harder to get. I need to get the entire property title of a MP4 file i give it. Thanks. I do not have much knowledge of VB but I’m hoping someone can help me :)
Use this:
Dim information = My.Computer.FileSystem.GetFileInfo("C:\myfile.mp4")
https://learn.microsoft.com/en-us/dotnet/api/system.io.fileinfo?view=netframework-4.8
To get more information, this could be a possible answer:
Get extended file information details

Realm database performance

I'm trying to use this database with react-native. First of all, i've found out that it can't retrieve plain objects - i have to retrieve all of the properties in the desired object tree recursively. And it takes about a second per object (~50 numeric props). Slow-ish!
Now, i've somehow imported ~9000 objects in it (each up to 1000 chars including titles). Looks like there is no easy ay to import it, at least it is not described in docs. Anyway, that's acceptable. But now i've found out that my database size (default.realm) is 3.49GB (!). The JSON file, which i was importing is only 6.5mb. I've opened default.realm with Realm Browser and it shows only those ~9000 objects, nothing else. Why so heavy?
Either, i don't understand something very fundamental about this database or it is complete garbage. I really hope i'm wrong. What am I doing wrong?
Please make sure you are not running in chrome debug mode. This is probably why things seem so slow. As far as the file size issue goes, it would be helpful if you posted your code to help figure out why that is happening.

XCode RSS Feed Won't parse properly

I followed a tutorial (which I'll link at the bottom) that I got from an old StackOverflow answer to parse an RSS feed into a UITableView. The tutorial is a bit outdated, but only a few methods were deprecated, and I replaced them with (what I hope are) the appropriate newer methods. However, I'm running into some trouble, not with the replaced methods, but with the parser not starting the parsing process. There are some NSLogs sprinkled throughout to give clues as to what is going on, and my parser isn't calling parseDidStartDocument:, it's just running and returning the last two NSLogs ("All Done!" and "stories array has %d items"). If someone could take a look at the code and tell me why it's not parsing, I would be very grateful. If you need to see some of my code, just let me know which parts you'd like to see, and I'd be happy to edit it in.
http://gigaom.com/apple/tutorial-build-a-simple-rss-reader-for-iphone/
oooh that tutorial is way out of date - written in 2008!
Try this tutorial, written for iOS5 instead.

Tools/Tests for Evaluating QR Code Generation Quality

I've written my own qr code generator. I followed both the ISO standard as well as a tutorial that I found online (http://www.thonky.com/qr-code-tutorial/). After following the tutorial as a test case (encoding "HELLO WORLD" in alphanumeric mode) I generated what appears to be a working qr code. It scans properly and everything looks happy.
However, upon closer investigation, I noticed that the qr codes generated by my library differ ever so slightly from the ones shown in the tutorial. I have verified that they both start with the same set of binary data to encode. The mask being used is also the same. Note that both my result and the one given in the tutorial both decode properly (thank you error correction!)
I am beginning to think that the results shown in the tutorial are wrong. I tried filling in some of the data by hand it seems to confirm my own result. Also, when I encoded the example given in the ISO standard ('01234567' encoded in numeric mode) I get the same result as is suggested. Only some of the qr code is different. Most of it looks identical.
So my question becomes: is there a tool that can give me error statistics on a qr code? Is there are set of standard test images I can compare against to confirm that my library works entirely correctly?
The easiest thing to do is to get some other platforms to see if they can decode them.
You can try ZXing - http://zxing.org/w/decode.jspx - which will give you the raw data encoded so you can see if you made any mistakes. It should also give you the error correction level etc.
If you just want to see if the text was encoded correctly, try:
http://www.onlinebarcodereader.com/
http://www.patrick-wied.at/static/qrgen/

Convert Wikipedia Page Section to NSString Objective-C

I'm working on some code that retrieves a section of a Wikipedia page as an NSString. I've found a constructed link online that returns the raw data of a section. For instance, to get the first section of the Wikipedia page on 'Boston', you would go to:
http://en.wikipedia.org/w/index.php?title=Boston&action=raw&section=0.
And what I'm trying to achieve, is to convert that raw data into what can be seen on the normal Wikipedia page: http://en.wikipedia.org/wiki/Boston.
Now, at first, I thought I'd use regular expressions to parse out blocks that start with {{ and end with }}. However, this proved to be problematic, and it deleted necessary text.
Then, I thought I could somehow find a wiki markup to html converter (present everywhere online) for Objective-C, but I had no luck there.
There are several similar questions on SO, but none of them seem to be clearly resolved: Getting Wikipedia Article Summary using NSScanner Problem.
So, to resume, does anyone know how to parse a wiki page into an NSString?
Thank you in advance.
Use a PEG WikiText parser such as kiwi: https://github.com/AboutUs/kiwi
You can find kiwi's parsing output rules here: https://github.com/AboutUs/kiwi/blob/master/src/syntax.leg
You will need to download peg/leg to compile the leg file: http://piumarta.com/software/peg/