PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Image from memory does not work with RTF https://forum.pdfsharp.net/viewtopic.php?f=2&t=3476 |
Page 1 of 1 |
Author: | trian [ Sun Oct 16, 2016 11:39 am ] |
Post subject: | Image from memory does not work with RTF |
Hello! I want to add an image from application resources to the document and render it to RTF. It perfectly works with PDF but does not work with RTF. The image does not shows. I used both PDFsharp-MigraDoc.1.50.4000-beta3b and PDFsharp-MigraDoc-GDI.1.50.4000-beta3b but the result is the same... Here is my code (VB.NET): Code: // main code
... Dim image_ As Byte() = LoadImage("Inventory.image_for_report.png") Dim imageFilename As String = MigraDocFilenameFromByteArray(image_) paragraph.AddImage(imageFilename) ... Private Function LoadImage(ByVal filename As String) Try Dim assembly = System.Reflection.Assembly.GetExecutingAssembly() Using stream_ As UnmanagedMemoryStream = assembly.GetManifestResourceStream(filename) Dim count As Long = stream_.Length Dim data_(count) As Byte stream_.Read(data_, 0, count) Return data_ End Using Catch ex As Exception Return vbNull End Try End Function Private Function MigraDocFilenameFromByteArray(ByVal image As Byte()) Return "base64:" & Convert.ToBase64String(image) End Function |
Author: | trecco [ Fri Apr 21, 2017 2:57 pm ] |
Post subject: | Re: Image from memory does not work with RTF |
I have the same Problem. Using MigraDoc with NugetPackage PDFsharp-MigraDoc-gdi Version: 1.50.4000-beta3b Image is rendered in PDF but not when using RTF. Code: var renderer = new RtfDocumentRenderer(); renderer.Render(doc, stream, closeStream: false, workingDirectory: null) Attachment:
|
Author: | Thomas Hoevel [ Wed Apr 26, 2017 10:59 am ] |
Post subject: | Re: Image from memory does not work with RTF |
Hi! The RTF renderer was not yet modified to support those BASE64 images. I'm sorry for the inconvenience. For the time being it is recommended to use images from files (create temporary files as needed for images from resources etc.). |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |