We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

I am losing (all ?!) formats when sending a syncfusion byte array to an network printer(e.g. after printing that array the document has lost his font):

Hi,I am losing formats when sending a syncfusion byte array to an network printer(e.g. the byte array has lost his font): Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.NoDelay = true; IPAddress ip = IPAddress.Parse(ip); IPEndPoint ipEndPoint = new IPEndPoint(ip, someport); socket.Connect(ipEndPoint); socket.Send(_temp); socket.Close();Syncfusion Stuff:... myfunc(){WordDocument word = new WordDocument();//... some code word.Save(myMemoryStream, FormatType.Docx);_temp= myMemoryStream.ToArray();word.Close();} How to solve this problem ?!Thanks

5 Replies

KE Kevin replied to Kevin May 18, 2017 04:05 PM UTC

Hi,I am losing formats when sending a syncfusion byte array to an network printer(e.g. the byte array has lost his font): Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.NoDelay = true; IPAddress ip = IPAddress.Parse(ip); IPEndPoint ipEndPoint = new IPEndPoint(ip, someport); socket.Connect(ipEndPoint); socket.Send(_temp); socket.Close();Syncfusion Stuff:... myfunc(){WordDocument word = new WordDocument();//... some code word.Save(myMemoryStream, FormatType.Docx);_temp= myMemoryStream.ToArray();word.Close();} How to solve this problem ?!Thanks

May be this helps too, when providing that byte array to an user agent(FileContentResult File(byte[] fileContents, string contentType, string fileDownloadName);)using asp.net mvc) we need to add the contentType like this for getting the right document for the client: "application/pdf" ,excel: "application/vnd.openxmlformats-officedocument.spreadsheetml‌​.sheet", word: "application/vnd.openxmlformats-officedocument.wordprocessin‌​gml.document" .


SY Sethumanikkam Yogendran Syncfusion Team May 19, 2017 01:14 PM UTC

Hi Kevin,

Thank you for contacting Syncfusion support.

We are unable to reproduce the reported issue with the given details. We suspect that, you might not be installed the fonts (which are used in the Word document) in your production environment. If so, kindly install all the used fonts in your production environment to resolve the reported issue.

If you’re still facing the same issue means, kindly provide us your confirmation details on the below which will be helpful to provide you the appropriate solution at the earliest.

     1. If Loading existing Word document (with or without further modifications in the input document):
          a. If you’re loading any input Word document using Essential DocIO, please try the below code to open Word document directly using FileStream and send a byte array to network printer.
 
// Open Word document using FileStream.
FileStream fileStream = new FileStream("input.docx", FileMode.Open);
// Copy file stream to MemoryStream.
MemoryStream memoryStream = new MemoryStream();
fileStream.CopyTo(memoryStream);
// Gets byte array from memory stream of file.
byte[] temp = memoryStream.ToArray();
 

          b. If you’re facing the same issue means, then the used fonts in the input document might not be installed in your production environment so, install all the used fonts to resolve the issue.
          c. If you’re not facing the reported issue in this approach, then kindly provide us simple sample or code snippet along with input and resultant Word document from your end to reproduce the issue at our end.

     2. If Creating Word document from scratch level:

          As mentioned above, if the issue is reproduced after installing all the used fonts in your production environment, then kindly provide us a sample with fonts used and resultant document generated at your end which will be helpful to analyze further and update you the appropriate details at the earliest.

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



KE Kevin May 22, 2017 11:08 AM UTC

Hi,

I the problem here was, that the printer does not support fonts, when sending data over TCP/IP.

Can you provide me an example, to convert an pdf file to images(byte array)?

Something like this:

List<byte[]> PdfToImage(some PdfFile)


KE Kevin May 22, 2017 01:34 PM UTC

using this, will result in printing the raw byte-array(printable and non-printable characters),instead of printing a normal pdf page:
List<byte[]> convert(byte[] pdf){
    PdfLoadedDocument loadedDocument = new PdfLoadedDocument(pdf);
            PdfLoadedPageCollection loadedPages = loadedDocument.Pages;
            Bitmap bitmapImage;
            PdfImage image;

            List<byte[]> ergebnis = new List<byte[]>();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                for (int i = 0; i < loadedPages.Count; i++)
                {
                    bitmapImage = loadedDocument.ExportAsImage(i);
                    bitmapImage.Save(memoryStream, ImageFormat.Png);
                    ergebnis.Add(memoryStream.ToArray());//schreibe das Byte-Array
                }
            }

            return ergebnis;

What is the problem here ?


AA Akshaya Arivoli Syncfusion Team May 23, 2017 07:20 AM UTC

Hi Kevin, 
 
We regret to let you know that we were unable to reproduce the reported issue with the provided details. However, based on the provided details we suspect that your requirement can be achieved by Silent Printing the PDF document using the Syncfusion.PdfViewer.Windows assembly (without exporting the PDF document into image). We have created the sample for your reference and shared the same in the following location. 
 
 
Please try the above sample and revert us with more details about your requirement or the modified sample, if your requirement is differs from the provided sample. Also, share us PDF document in which the issue could be reproduced. These details will be helpful for us to investigate more on your requirement and assist you better. 
 
Regards, 
Akshaya 


Loader.
Live Chat Icon For mobile
Up arrow icon