Click here to Skip to main content
15,887,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my client wants me to do one task. which is whenever I print ctrl+P from the browser it will go automatically that contents to the database which is sql.

Now, Let me explain what I have tried to achieve this. Usually printerPlusPlus which is third party tool. Which adds virtual printer and prints the files PS to the temp directory than I can read the contents of that postscript file and save it to the database.

My real question is there anything from which I can convert this post script files to text or read them and save the texts to the database? Or is there any better way to achieve this task?

Ghostscript is the alternate and ow-some feature to convert the postscripts to the text or pdf. But, I am completely clueless about the documentation and how to execute their commands.

C#
_viewer.Interpreter.RunFile("C:\\PrinterPlusPlus\\Temp\\ankit_SONY-VAIO_sony_20151227_185020_3.ps");

            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png16m);
            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY = new GhostscriptImageDeviceResolution(96, 96);
            dev.InputFiles.Add(@"C:\\PrinterPlusPlus\\Temp\\ankit_SONY-VAIO_sony_20151227_185020_3.ps");
            dev.OutputPath = @"C:\\PrinterPlusPlus\\Temp\\ankit_SONY-VAIO_sony_20151227_185020_3.txt";
            dev.Process();

            _preview.Activate();

I tried this but this seems to be not working and adding ASCII text to the txt file.
Posted
Comments
Richard Deeming 12-Jan-16 9:24am    
It's adding strange characters to the text file because you're telling it to convert to a PNG - an image.

What library are you using to call GhostScript?
Richard Deeming 12-Jan-16 9:26am    
There are several suggestions in this StackOverflow thread[^] which might help.
Dholakiya Ankit 12-Jan-16 11:34am    
I had already gone through it. its not working..do you have any source code where I can look at?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900