Closed o-leary closed 7 years ago
Will look into it.
Fixed the FileSource for Uwp :) New 7z file with compiled projects is in the root directory of the project ;)
Please let me know if it works ;) Thanks!
Can you verify if it's working now, so i can close the issue?
I've finally had time to try this out. Everything compiles fine, but when creating the document the application hangs and eventually gives an exception
An exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: Unable to load resources for resource file "MigraDocCore.Rendering.MigraDoc.Rendering.Resources.AppResources" in package "88d52432-7f15-4c35-963d-61146522a867".
This only happens if I uncomment section.AddImage(img); I have been trying various solutions but haven't got anywhere. I thought it may relate to assembly neutral language selection, but I can't compile some of your source which makes it tricky to rule out. (the nuget package for ImageSharp is just a placeholder, so I will try and find it elsewhere).
Edit: I managed to compile with differing ImageSharp versions, and include those DLLs without the resources file embedded, the error thrown is then placed in the PDF as "DisplayImageNotRead". I have tried various image formats including the testimage you supplied.
Can you upload a sample project somewhere? Then I'll take a look. Though you could install this package: "Install-Package Microsoft.Net.Compilers" and my code will compile (you can't compile it normally because I'm already using c#7 syntax, which visual studio will be able to compile with that package)
I have added a vs2015 compatible solution -> though I only added the projects you need to create a pdf with images on uwp (no tests, no example, now android,...)
I had to make some small tweaks to the project files to remove the Microsoft.Net.Compilers.props file references (although I had the package and it's still listed as a dependency). I got this compiling and added an example UWP app with a button that generates a PDF. I still get the same behavior. I've put in the example uses you had given in your test app, and two I had tried. To switch which method to use just change the int option in the buttons click method. I had to 7z and then zip the folder to upload it here due to size and then file type restrictions.
While I did not get a System.Resources.MissingManifestResourceException, I did run into a deadlock (I hate c# handling of async methods within a sync method... they should really make it easier, because it does NOT hang when using a UWP unit test...). I've pushed some changes, hopefully this solves the issue. :)
Also your picker doesn't do anything because with the switch you are overriding the stream anyway.
Ahh, the picker is just to choose an output directory for the pdf file "testfile.pdf", so you don't have to go looking for it. The file used is always the TestImage.png you provided.
I'll give your changes a shot, thanks :)
Edit: The manifest exception is probably due to a regional language setting, and can probably be fixed by specifying a neutral language, however you have solved the problem and the image is embedded successfully. You're a damn legend my friend.
Glad I could help :) Thanks for the feedback!
Apologies as this is most likely because I can't figure out how to implement it properly.
In a migradoc table, attempting to add an image:
and
Otherwise your port has been extremely useful to me and I am able to create very complex documents. Thank you for sharing!