PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Aug 16, 2017 1:18 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Oct 16, 2016 11:39 am 
Offline

Joined: Sun Oct 16, 2016 11:19 am
Posts: 1
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


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 21, 2017 2:57 pm 
Offline

Joined: Fri Apr 21, 2017 2:37 pm
Posts: 1
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:
mdddl.zip [6.58 KiB]
Downloaded 19 times


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 26, 2017 10:59 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2687
Location: Cologne, Germany
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.).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], pistoletov and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group