Printing byte array image to printer - asp.net

I have byte array image and want to print/send it to printer through my web application.
How can I print that byte array to my local printer through web app.

Unfortunately you're limited to printing capabilities of the browser, and those capabilities are not particular fantastic. A typical approach is to utilise a client-side plugin and format your 'response' to the browser to work with that plugin.
One example is creating an Adobe PDF and passing that as your response to the client. Here's an example using a free library.

Related

How to write a working URL to a Mifare Classic 1K

Quite simply, I am only able to write to this card in hexadecimal. After much research, I can only find methods to write a working URL(that opens the browser on mobile), that use specific apps that are not compatible with the card I have. I would love it if one of you clever folks could explain to me the method by which I can turn a URL into the correct format, and where(sector, headers etc...) I should store it within my card. Thanks
Unfortunately Mifare Classic Tags are non standard, so there is no reliable way on all mobile hardware to write a URL that will automatically open a browser.
Most mobile hardware supports the NFC standard Tag's and some support reading from Mifare Classic Tags (but not all).
If reading from a non standard Mifare Classic Tag is supported then there is a chance that the NDEF data format will be also supported.
All mobiles will handle automatically URL's encoded in the NDEF format.
First you need to format the Mifare Classic Tag in a way to store NDEF, see the NXP application note https://www.nxp.com/docs/en/application-note/AN1305.pdf on how to do this.
Once configured to store NDEF data you can store a URL using NDEF URI type - details at https://github.com/haldean/ndef/blob/master/docs/NFCForum-TS-RTD_URI_1.0.pdf
Writing the data in this way will cause a fair number of mobiles to open a URL in a browser without any App, but also a fair number won't even read the Mifare Tag.

Output of Print Driver application, PCL

We have a legacy application written by a developer which takes a PDF/text file and converts it to a TIFF. The user just prints the file to a custom print driver.Output of the driver is a Printer control language file and finally TIFF.
The user doesn't see the PCL file. PCL file is internally produced and inputed as a binary reader which gets converted to a TIFF.
How do I see the PCL File?? I would really like to have a small stand-alone test program which converts a PDF to PCl using this print driver and then TIFF.
The print driver is written in C, C++ code.
This driver was written in 2010. With the new Adobe version 2018.009.20050, text in adobe forms is not being captured.
I'd appreciate some pointers!
I do not have an answer but I wish to comment and follow the topic.
Like the poster, I'm working with a few virtual print drivers and have noted this change of behavior from Adobe Reader 2018.009.20050 is impacting them. Examples: Foxit's PDF Printer, as well as an HP PostScript Driver I've been using whenever I need to redirect a printstream to a file.
The issue seems to be that the new release of Adobe Reader is no longer recognizing these PostScript printers as such. A tell-tale sign is that Adobe Reader, when printing, has 'Advanced' options that would typically let someone designate some PostScript options/preferences. With the recent Reader release, these options are now disabled for all of my PostScript-capable printers, except when using the "Adobe PDF Printer".
My guess: like many Windows applications, when Adobe Reader prints to a device that it thinks is NOT PostScript-capable, Reader will choose to rasterize the PDF's text into image/vector data, rather than expressing it as text-and-font information. ( ..and some applications, like Chrome, seem to always do this, nevermind the type of printer. )
I am hoping that Adobe sees a bug here to be fixed soon. It's creating quite a headache otherwise.
In the meantime, I've found that Foxit's most-recent PDF Reader does NOT have this same issue. It continues to create PostScript for my set of virtual printers.
UPDATE (1/2/18):
This is Adobe's support article describing a different issue but the same proposed registry change for avoiding text rasterization.

ASMX Web Service that returns image

I want an .asmx service that returns a .png file. My problem is, my web application is hosted on GoDaddy. Because of this, I can't edit the web.config file. If I could edit the web.config file, I would simply created an HTTP Handler.
My question is, is there a way to have an .asmx that returns an image? If so, how?
Why not simply have the service return the image as a byte array (byte[]).
I have no idea why you think you should edit the web.config.
It really depends on how you want to use the image.
If you chose to return a byte array like John suggests, there will be a huge overhead for serializing that to xml (or json), something like 13-15 times (for xml).
I'd suggest that you create a Generic Handler (.ashx) with a query string arg referring to the image, and write directly to the response stream.
Then in your web service, in place of the image, return the url to the handler with proper query string. The consumer of the service can then be responsible for getting the image.
Hopefully this helps.
The best way to return an image from a web service is probably just to return it either as a byte array or as a custom type which includes a byte array (as well as other information, such as image type or suggested file name, etc.).
When you say you want it to return an image, what exactly are you expecting? Do you expect an image in the way that an image renders in a web browser when linked? If so, you're going to have to manually manipulate the output. There are plenty of tutorials online about "displaying an image from a database in asp .net" which would help you.
Basically, you'd hijack the response and change its headers, write the binary image data, and end the response. It works well enough on a web page, but I've never tried it on a web service. It would, however, be considered poor form for a web service to do this. It would break the "contract" of the web service. (Which is why I'm hoping, and at least assuming, that this is not the desired effect.)
If you just want a handler that returns a PNG file, use an .ashx file. If you want a service with a method that returns a PNG file, convert the PNG to a byte array first and return the array.

in flex, dynamically load Sound object from encoded bytes

I have a legacy file format that contains sounds embedded in it (in various encodings). I would like to be able to play these sounds in Flash (Air?) by reading the sound bytes out of the file and instantiating a Sound object with them.
If the sound is unencoded (e.g., raw pcm), I've found that I can use the new flex 4 SampleDataEvent.SAMPLE_DATA event to play the sound.
However, if the sound is encoded (e.g., mp3), then I'm at a loss. The sound expected by SampleDataEvent.SAMPLE_DATA has to be raw pcm. From what I've seen, encoded Sounds can only be instantiated by [Embed]ing them, or by using a URLRequest with Sound.load().
Surely there's a third way? AMF or e4x?
There are really only two routes for you to go. The first is to write a decoder in ActionScript. You may be able to use Alchemy to port over some C/C++ code to make this job significantly easier (and possibly more performant). This is exactly how I got Ogg Vorbis playback to work with Flash.
The other option is to dynamically create a valid SWF inside of a ByteArray. That SWF could contain an embedded sound object that was made up of your sound data. A number of folks have pulled off similar hacks in the past before Flash Player 10 was available. I believe you can find a good place to start in Andre Michelle's and Joa Ebert's PopForge codebase.

In ASP.NET what is the best way to convert a PDF file to HTML?

What my users will do is select a PDF document on their machine, upload it to my website, where I will convert into an HTML document for display on the website. The document will be stored in a database after conversion.
What's the best way to convert a PDF to HTML?
I have been handed a requirement where a user would create a "news" story as a pdf and then would upload it to the sever, where it will be converted to HTML and displayed on the website.
Any document creation software that can save documents as PDF can save them as HTML. I'm assuming the issue is that your users will be creating rich documents (lots of embedded images), which results in multiple files, and your requirements stem from a desire to make uploading these documents as simple as possible to the user.
There are numerous conversion packages that can probably do this for you, however when you're talking about rich content, you are talking about text plus images. Those images have to be stored somewhere and served somehow, and whatever conversion method you use will require you to examine all image sources to make sure they point to valid locations on your server.
I would like to suggest an alternate way of doing this that you can take to your team: Implement one of the many blog APIs for publishing content. There are free and commercial software packages that use these APIs to publish content directly to a website, such as Windows Live Writer and Microsoft Word. Your users can simply create their content and upload it directly to your website without having to publish it as PDF first then upload it. So the process becomes much smoother for your users, and you get the posts in a form that doesn't require you spend thousands of dollars on developing or buying conversion code.
The two most common APIs are the MetaWeblog API and the Movable Type API. Both are very simple and easy to implement. I think this way would be a MUCH better alternative than what you're thinking about doing.
I don't think converting a PDF to an HTML string is necessarily the best idea, especially if you want to export it back as PDF. PDF files often contain binary elements such as images, so you may be best to convert it to ASCII via an encoding, such as Base64. That way you will have an ASCII string you can save into a text field in the DB and then convert it back out. Could you expand more on the main requirement?
My recommendation would be to not do it that way IF POSSIBLE (but we all know what managers are like) so...
I would recommend that you stay away from converting the PDF to/from HTML (because unless you can find a commercial solution it will be nigh on impossible) and instead do as has already been mentioned and store it as an encoded Base64 string, or BLOB or some other binary format in the database, and then display it to the user with some sort of PDF view plugin for the browser.
All it took was a simple google search for "PDF to HTML": http://www.gnostice.com/pdf2manyOverview_x.asp. I'm sure there are others.
So while it's 'possible', you may want to explain to your manager that this isn't the best content management solution.
Why not use the iTextSharp to read the PDF content? Then You could save both the binary PDF and the text content to the database. You could then let users search the content and download the PDF.
You should look into DynamicPDF. They have a converter (currently Beta) out for serving exactly this purpose. We have used their products with great success (especially for dumping Reporting Services reports directly to PDF).
Ref: http://www.dynamicpdf.com/

Resources