PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 20, 2018 8:25 am

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 

Joined: Sun Oct 16, 2016 11:19 am
Posts: 1

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):
// main code
Dim image_ As Byte() = LoadImage("Inventory.image_for_report.png")
Dim imageFilename As String = MigraDocFilenameFromByteArray(image_)

Private Function LoadImage(ByVal filename As String)
        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

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

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.

var renderer = new RtfDocumentRenderer();
renderer.Render(doc, stream, closeStream: false, workingDirectory: null)

mdddl.zip [6.58 KiB]
Downloaded 38 times

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

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2807
Location: Cologne, Germany

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.).

Thomas Hoevel
PDFsharp Team

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: Baidu [Spider], Bing [Bot] and 9 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