PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
Embedding a logo in a RTF http://forum.pdfsharp.com/viewtopic.php?f=2&t=4218 |
Page 1 of 1 |
Author: | csalernocsit [ Fri Jan 01, 2021 2:14 pm ] |
Post subject: | Embedding a logo in a RTF |
Trying to use version MigraDoc 1.50.5147.0 to embed a gif logo into a RTF document. Used the readily available examples and it's working for PDF but not when I render a RTF. static string MigraDocFilenameFromByteArray(byte[] image) { return "base64:" + Convert.ToBase64String(image); } void LoadLogo() { byte[] imageArray = Library.Helpers.FileUtils.ReadFile(LogoFilename); string strEmbeddedImage = MigraDocFilenameFromByteArray(imageArray); CurrentDocument.LastSection.Headers.FirstPage.AddImage(strEmbeddedImage); } public static byte[] ReadFile(string sPath) { //Initialize byte array with a null value initially. byte[] data = null; //Use FileInfo object to get file size. FileInfo fInfo = new FileInfo(sPath); long numBytes = fInfo.Length; //Open FileStream to read file FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //Use BinaryReader to read file stream into byte array. BinaryReader br = new BinaryReader(fStream, Encoding.Default); //When you use BinaryReader, you need to supply number of bytes to read from file. //In this case we want to read entire file. So supplying total number of bytes. data = br.ReadBytes((int)numBytes); //Close BinaryReader br.Close(); //Close FileStream fStream.Close(); return data; } |
Author: | TH-Soft [ Mon Jan 04, 2021 9:19 am ] |
Post subject: | Re: Embedding a logo in a RTF |
RTFM: BASE64 works for PDF, but not yet for RTF. Just use normal images from files. |
Author: | csalernocsit [ Mon Jan 04, 2021 11:52 am ] |
Post subject: | Re: Embedding a logo in a RTF |
The RTF is generated on a web server thru a web service and downloaded to the client. When the images are added to the RTF, the image is missing when downloaded. I was hoping to embed the image in the RTF like the PDF. |
Author: | csalernocsit [ Mon Jan 04, 2021 5:10 pm ] |
Post subject: | Re: Embedding a logo in a RTF |
I separated the logic between the PDF & RTF generation and the image is now appearing in the downloaded RTF document. |
Author: | csalernocsit [ Tue Jan 05, 2021 12:09 pm ] |
Post subject: | Re: Embedding a logo in a RTF |
Although I'm now able to embed the logo image in the PDF, I've lost the ability to position the image on the header, either left, right or center. How can I add positioning to the image i'm embedding? |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |