memorystream

wkhtmltopdf outputstream & download - diaglog

自作多情 提交于 2019-12-19 03:17:07
问题 is it possible to get a pdf stream created by wkhtmltopdf from any html file and popup a download dialog in IE/Firefox/Chrome etc.? At the moment I get my outputstream by this code: public class Printer { public static MemoryStream GeneratePdf(StreamReader Html, MemoryStream pdf, Size pageSize) { Process p; StreamWriter stdin; ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\PROGRA~1\WKHTML~1\wkhtmltopdf.exe"; // run the conversion utility psi.UseShellExecute = false; psi

Is there an in memory stream that blocks like a file stream

你说的曾经没有我的故事 提交于 2019-12-18 12:58:09
问题 I'm using a library that requires I provide an object that implements this interface: public interface IConsole { TextWriter StandardInput { get; } TextReader StandardOutput { get; } TextReader StandardError { get; } } The object's readers then get used by the library with: IConsole console = new MyConsole(); int readBytes = console.StandardOutput.Read(buffer, 0, buffer.Length); Normally the class implementing IConsole has the StandardOutput stream as coming from an external process. In that

Serializing/deserializing with memory stream

霸气de小男生 提交于 2019-12-17 07:20:01
问题 I'm having an issue with serializing using memory stream. Here is my code: /// <summary> /// serializes the given object into memory stream /// </summary> /// <param name="objectType">the object to be serialized</param> /// <returns>The serialized object as memory stream</returns> public static MemoryStream SerializeToStream(object objectType) { MemoryStream stream = new MemoryStream(); IFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, objectType); return stream; } ///

Image.FromStream() method returns Invalid Argument exception

人走茶凉 提交于 2019-12-17 06:50:19
问题 I am capturing images from a smart camera imager and receiving the byte array from the camera through socket programming (.NET application is the client, camera is the server). The problem is that i get System.InvalidArgument exception at runtime. private Image byteArrayToImage(byte[] byteArray) { if(byteArray != null) { MemoryStream ms = new MemoryStream(byteArray); return Image.FromStream(ms, false, false); /*last argument is supposed to turn Image data validation off*/ } return null; } I

Save and load MemoryStream to/from a file

倖福魔咒の 提交于 2019-12-16 22:36:14
问题 I am serializing an structure into a MemoryStream and I want to save and load the serialized structure. So, How to Save a MemoryStream into a file and also load it back from file? 回答1: You may use MemoryStream.WriteTo or Stream.CopyTo (supported in framework version 4.5.2, 4.5.1, 4.5, 4) methods to write content of memory stream to another stream. memoryStream.WriteTo(fileStream); Update: fileStream.CopyTo(memoryStream); memoryStream.CopyTo(fileStream); 回答2: Assuming that MemoryStream name is

Can't create MemoryStream

纵饮孤独 提交于 2019-12-13 18:15:22
问题 Is there any reason why this code shouldn't produce a memory stream with the word Slappy in it? private MemoryStream StringBuilderToMemoryStream(StringBuilder source) { MemoryStream memoryStream = new MemoryStream(); StreamWriter streamWriter = new StreamWriter(memoryStream); streamWriter.Write("slappy"); return memoryStream; } Even if I say streamWriter.Write(source.toString()); it fails. Funny thing is, that it works on one of the methods that calls this routine but not on any of the others

Using PDF itextSharp it is possible to put an image on top of text while creating the pdf document

让人想犯罪 __ 提交于 2019-12-13 14:16:55
问题 I attempted several ways to do this, but still cannot get it. It appears iTextSharp requires a 2 pass situation so that an image appears on top of the text. So I am attempting to do this using memory streams, but I keep getting errors. Public Function createDoc(ByRef reqResponse As HttpResponse) As Boolean Dim m As System.IO.MemoryStream = New System.IO.MemoryStream() Dim document As Document = New Document() Dim writer As PdfWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(document, m)

VB.NET: Retrive an image (blob) from MySQL DB

ぃ、小莉子 提交于 2019-12-13 06:04:36
问题 I've a field called "Foto" in MySQL DB. This field is a blob. When I used SQL Server, the following code worked: Dim conn As New MySqlConnection conn.ConnectionString = ConnectionString Dim cmd As New MySqlCommand cmd.Connection = conn conn.Open() cmd.CommandText = "SELECT Foto FROM MyTable WHERE ID = '" & IDtxt.ToString & "'" Dim reader As MySqlDataReader reader = cmd.ExecuteReader While reader.Read If (IsDBNull(reader("Foto"))) Then frmCartaIdentitaView.pctImage.Image = Nothing Else Dim

A generic error occurred in GDI+ exception when trying to save image into MemoryStream

廉价感情. 提交于 2019-12-12 16:32:43
问题 I am using C# windows form. My code : private void Openbutton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { SurveyDiagrampictureBox.Image = Bitmap.FromFile(openFileDialog.FileName); MemoryStream memoryStream = new MemoryStream(); SurveyDiagrampictureBox.Image.Save(memoryStream, ImageFormat.Jpeg); SurveyDiagram = memoryStream.GetBuffer(); } } It doesn't always occur, the exception throws when

Writing CSV to MemoryStream using LinqToCSV does not return any data

本秂侑毒 提交于 2019-12-12 13:25:51
问题 I've verified using System.Text.Encoding.ASCII.GetString(ms.ToArray)); that my memorystream has the expected data. However using the LinqToCSV nuget library will not generate my csv file. I get no errors or exceptions thrown. I just get an empty file when I'm prompted to open the file. Here is my Action Method public FileStreamResult Export(){ var results = _service.GetProperties().Take(3); System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.IO.TextWriter txt = new System.IO