SkiaSharp XPS document creation failing on Linux - skiasharp

I can create an XPS file with SkiaSharp fine like this on Windows:
_outputStream = File.Create(outputFileName);
_managedStream = new SKManagedWStream(_outputStream);
if(_outputStream == null || _managedStream == null)
{
throw new System.Exception("XPS Streams not created");
}
Logger.LogInformation("Creating XPS document");
Document = SKDocument.CreateXps(_managedStream);
if(Document == null)
{
throw new System.Exception("Could not create XPS Document");
}
But on Linux (AWS container linux) it silently fails - ie, Document is null and it throws my null check exception.
Documentation is almost non existent as are blog posts for anything SkiaSharp. Has anyone here got this to work well?

Only supported on windows apparently. Another reason Im starting to dislike SkiaSharp.
https://github.com/mono/SkiaSharp/blob/fc9f030a08eb158fb934774cdf54f8df939088c7/tests/Tests/SKDocumentTest.cs#L136

Related

Embarcadero C++ : How to notify user if new update is available?

I am beginner in Embarcadero C++, If my application is developed in Embarcadero C++ and installed in client machine then how my application notify user if new update is available? If user clicked on yes button then it will first download the application then install it.
Please let me know if anybody have any Idea.
Here is how I check if new version of program is available on the server, using
Indy Client component TIdHTTP.
Let's say you have uploaded a new version of your application. Besides installation or zip file containing you application, upload a one line text file (applicationBuildData.txt) which contains build value (integer), delimiter (;) and optionally some other data (version number, program name, etc...). For example:
20170215; ProgamName rel. 1.2.
This is the only line in applicationBuildData.txt file. Here is the code sample (I've modified my original code a bit):
void __fastcall TfrmDialog::Button1Click(TObject *Sender)
{
TIdHTTP *IdHTTP1 = new TIdHTTP(this);
// let's say this is current app build (on user's side)
int currAppBuild = 20170101;
int prodBuildNew = 0;
UnicodeString prodVersionNew;
UnicodeString version_str;
try {
// get content of applicationBuildData.txt into string
version_str = IdHTTP1->Get("http://www.your-site.com/applicationBuildData.txt");
prodBuildNew = StrToInt(version_str.SubString(1, version_str.Pos(";") - 1).Trim());
prodVersionNew = version_str.SubString(version_str.Pos(";") + 1, 100).Trim();
}
catch (...)
{
prodBuildNew = 0;
prodVersionNew = "???";
}
if (prodBuildNew == 0) {
// ...faild to get data from server...
// display message
}
else if (prodBuildNew > currAppBuild) {
// new version is available
// display message
}
else {
// application version is up to date
// display message
}
delete IdHTTP1;
}
In this example, current build number is smaller then uploaded build number and it will indicate user that new version is available.
Note: currAppBuild is usually some global constant, or global variable that presents build version. After new version on the server is detected, you can either download installation/zip or simply display message and let the user go to your site and download new version manually.
Edit: How to download the file to your local disk using TIdHTTP component, check the following video:
https://www.youtube.com/watch?v=fcN8K3R4iZE

Chrome API HID receive not working in Windows

I have a chromapp which sends data to PC using usb, connected as an HID device, working perfectly in Linux. While trying to do the same in windows, the app sees that the device is connected but throws an runtime error :
Unchecked runtime.lastError while running hid.receive: Transfer failed.
The hid.receive callback function is implemented as follows
var pollDevice = function() {
var size = 64;
chrome.hid.receive(connectionId, function(reportId, data) {
if (data != null) {
var dataAscii = arrayBufferToString(data);
console.log(dataAscii);
}
setTimeout(pollDevice, 1);
});
};
I am running Google Chrome Version : 52.0.2743.116 on Windows 10 Pro, Version 1607, Build 14388.0
Did someone else similar issues? Can someone help me out on this??

Debugging WP8 Native Code using a file

I'm developing a WP8 app that has some native code (runtime component).
Inside the runtime component I need to check to content of a c style array.
Because this array is not small, I thought the best I could do is write the array in a file
using fopen/fwrite/fclose;
Checking the returned value from fopen and fwrite, I can see that it succeeded.
But I cannot find the file (using Windows Phone Power Tools).
So where has the file been written?
Is there another way to dump the content of the array to a file (on the computer) from visual studio ?
I'm unfamiliar with the fopen/fwrite/fclose APIs in WP8. Which probably means it's not a whitelisted API you can use to submit your app with. It's best if you just use "Windows::Storage::ApplicationData::Current->LocalFolder" when working with IsoStore in C++. See Win8 code sample # http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700361.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
Thanks Justin,
here's how I ended up doing it:
auto folder = Windows::Storage::ApplicationData::Current->LocalFolder;
Concurrency::task<Windows::Storage::StorageFile^> createFileOp(
folder->CreateFileAsync(L"Data.bin", Windows::Storage::CreationCollisionOption::ReplaceExisting));
createFileOp.then(
[nData, pData](Windows::Storage::StorageFile^ file)
{
return file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
})
.then([nData, pData](Windows::Storage::Streams::IRandomAccessStream^ stream)
{
auto buffer = ref new Platform::Array<BYTE>(pData, nData);
auto outputStream = stream->GetOutputStreamAt(0);
auto dataWriter = ref new Windows::Storage::Streams::DataWriter(outputStream);
dataWriter->WriteBytes(buffer);
return dataWriter->StoreAsync();
})
.wait();
Now compare that to what I "meant" :
FILE *fp = fopen("Data.bin", "wb");
if (fp)
{
int ret = fwrite(pData, 1, nData, fp);
fclose(fp);
}

Windows Phone 8 HRESULT: 0X80042706

I'm developing a Windows Phone 8 Application that uses the map control. I have followed the tutorial, but I keep geeting the messagebox error: HRESULT: 0X80042706. Here is the code from the tutorial
protected override void OnNavigatedTo(NavigationEventArgs e)
{
map.ColorMode = MapColorMode.Light; map.CartographicMode = MapCartographicMode.Road; map.LandmarksEnabled = true; map.PedestrianFeaturesEnabled = true; map.ZoomLevel = 17;
routeQuery.TravelMode = TravelMode.Walking; routeQuery.QueryCompleted += rq_QueryCompleted;
base.OnNavigatedTo(e);
}
...
void rq_QueryCompleted(object sender, QueryCompletedEventArgs<Route> e) {
if (null == e.Error) {
//Recommended way to display route on map
Route MyRoute = e.Result;
MapRoute MyMapRoute = new MapRoute(MyRoute);
map.AddRoute(MyMapRoute);
}
else
MessageBox.Show("Error occured:\n" + e.Error.Message);
}
I tried to search what kind of error HRESULT: 0X80042706 was from here, but I have no idea what that meant.
I even tried to switch the if condition to e.Error == null, but still no good. Can anyone help me?
The error is because your device does not support CHAP authentication while connecting to Virtual Disk Service (i.e. Maps)
This is because you don't have an authentication id from Microsoft.
Follow the details here ( for wp8 maps another authentication is required)
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207033(v=vs.105).aspx
I received the same error from the same tutorial, and found it was due to no internet access to my PC (and hence no map data). Restored Internet access and the error resolved itself.
Please once check your Manifestfile and select Capability option click in ID_CAP_MAP.

window.mozIndexedDB is null in Firefox 15

I'm trying to run the "Using IndexedDB" sample code on https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB
Right out of the gate I stumble with the first line of code:
window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
Using Firebug I see that window.indexedDB is undefined as expected for FF 15, window.webkitIndexedDB is undefined as expected (FF isn't webkit) but window.mozIndexedDB is null but not undefined. If it's null that tells me it exists but doesn't have a valid value/isn't initialized.
This is with Firefox 15.0.1 on OSX 10.6.8 and Ubuntu 12.04. Can somebody tell me why I'm not able to see/use window.mozIndexedDB? Am I doing something wrong?
For completeness, here's my JavaScript file:
window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
var request = window.indexedDB.open("MyTestDatabase", 3);
var db;
request.onerror = function (event) {
alert("Oops, request.onerror");
};
request.onsuccess = function (event) {
// Do something with request.result!
alert("Made it to request.onsuccess");
db = request.result;
};
// This event is only implemented in recent browsers
request.onupgradeneeded = function (event) {
alert("Made it to request.onupgradeneeded");
};
db.onerror = function (event) {
alert("Database error (db.onerror): " + event.target.errorCode);
};
My original HTML5 application uses jQuery Mobile & REST WS. In development I would run it directly from the file system and it works fine. For sharing with coworkers I have it running behind Apache httpd.
While adding the IndexedDB, I was trying to test by viewing files from the file system via the browser. It didn't work and that's what caused me to go back to square one and try running the example code from Mozilla.
It appears IndexedDB requires a domain even if it's localhost. I simply placed my code under public_html and viewed it via httpd/localhost and it's working perfectly.