Edit the PRN file generated by PCL driver
-
Hi All, I have .Prn file which was generated out of PCL printer.I need to find a string in that file and then I have to replace it with another string. Iam able to do it by using stream writer,streamreader,Binary reader,binary writer and file streams. But if gave a print(LPR)for it, it get failed and giving me syntax error as Illegal tag. If I print original file it is printing very well. I came to know that while writing it has lost some of its originality ,so it was failed The original file size is like 16k, after the editing it becoming as 22k.. more over it is not normal file,It is a file generated by PCL printer. So may be during the conversion it is losing printer supported font. so that's the reason printer cannot understand the file(after editing)to print.so it gives syntax error as Kernel and Illegal tag error. I even cannot compare both file because the file is generated by PCL printer which has some non-readable data I have no clues to overcome this problem Please help me Thanks in advance
-
Hi All, I have .Prn file which was generated out of PCL printer.I need to find a string in that file and then I have to replace it with another string. Iam able to do it by using stream writer,streamreader,Binary reader,binary writer and file streams. But if gave a print(LPR)for it, it get failed and giving me syntax error as Illegal tag. If I print original file it is printing very well. I came to know that while writing it has lost some of its originality ,so it was failed The original file size is like 16k, after the editing it becoming as 22k.. more over it is not normal file,It is a file generated by PCL printer. So may be during the conversion it is losing printer supported font. so that's the reason printer cannot understand the file(after editing)to print.so it gives syntax error as Kernel and Illegal tag error. I even cannot compare both file because the file is generated by PCL printer which has some non-readable data I have no clues to overcome this problem Please help me Thanks in advance
There is no such thing as non-readable data if you can access the file; it just depends on how you read it. What are you using to edit the file? Swapping out a bit of text shouldn't increase the file size by 6k! You mention streamreader, Binary reader, etc, so I assume you're writing your own editing app. What language are you using? There are some interesting differences in the way various languages handle text - you may be getting invisible CRLF characters appended to your edits, for example, which will totally screw up the file format. A little more detail would be helpful...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
-
There is no such thing as non-readable data if you can access the file; it just depends on how you read it. What are you using to edit the file? Swapping out a bit of text shouldn't increase the file size by 6k! You mention streamreader, Binary reader, etc, so I assume you're writing your own editing app. What language are you using? There are some interesting differences in the way various languages handle text - you may be getting invisible CRLF characters appended to your edits, for example, which will totally screw up the file format. A little more detail would be helpful...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
Iam Using c#.net,I made the following 2 methods for it First Method: public void writetofile(string JobOwnerName, string genfilename) { try { string fileContent = string.Empty; string NewOwnername = "@PJL SET JOBATTR=" + '"' + "@JOAU=" + JobOwnerName + '"';//@PJL SET JOBATTR="@JOAU + JobOwnerName + " string strTextFileName = genfilename; string strTextToInsert = NewOwnername; ArrayList lines = new ArrayList(); StreamReader rdr = new StreamReader(strTextFileName); //String search_str = "%-12345X@PJL JOB"; //String search_str = "%-12345X@PJL JOB MODE=PRINTER"; String search_str = "@PJL JOB MODE=PRINTER"; string line; string s = "@PJL SET JOBATTR=" + '"' + "@JOAU="; while ((line = rdr.ReadLine()) != null) { if (line.StartsWith(s)) { lines.Remove(line); } else { lines.Add(line); } } rdr.Close(); lines.Insert(lines.IndexOf(search_str) + 1, strTextToInsert); StreamWriter wrtr = new StreamWriter(strTextFileName); foreach (string strNewLine in lines) wrtr.WriteLine(strNewLine); wrtr.Close(); } catch (Exception ex) { } } 2nd method: string JobOwnerName = "suman" + '"'; string path = @"C:\D.prn"; string temp = @"C:\DD.prn"; string test1 = "@PJL SET JOBATTR=" + '"' + "@JOAU=" + JobOwnerName + '"'; string s = "@PJL SET JOBATTR=" + '"' + "@JOAU="; string line; StreamReader sr = new StreamReader(File.Open(path, FileMode.Open)); StreamWriter sw = new StreamWriter(File.Open(temp, FileMode.Create)); while ((line = sr.ReadLine()) != null) { line = sr.ReadLine(); if (line.StartsWith(s)) { line = line.Replace(line.Substring(line.IndexOf('"') + 7), JobOwnerName); sw.WriteLine(line); sw.Wr
-
Hi All, I have .Prn file which was generated out of PCL printer.I need to find a string in that file and then I have to replace it with another string. Iam able to do it by using stream writer,streamreader,Binary reader,binary writer and file streams. But if gave a print(LPR)for it, it get failed and giving me syntax error as Illegal tag. If I print original file it is printing very well. I came to know that while writing it has lost some of its originality ,so it was failed The original file size is like 16k, after the editing it becoming as 22k.. more over it is not normal file,It is a file generated by PCL printer. So may be during the conversion it is losing printer supported font. so that's the reason printer cannot understand the file(after editing)to print.so it gives syntax error as Kernel and Illegal tag error. I even cannot compare both file because the file is generated by PCL printer which has some non-readable data I have no clues to overcome this problem Please help me Thanks in advance
I guess your problem is the replacement of linefeeds and newlines with an incompatible alternative. You know, just like you have to choose "ASCII-Transfer" in your FTP-Tool so that notepad.exe can show the config-files of your linux-server correctly. You need to preserve the whitespace. Try reading binary, replacing a single letter, then writing the otherwise unchanges binary result back to a new file. You have reached your goal as soon as the two files afterwards are of the same size.
Cheers, Sebastian -- "If it was two men, the non-driver would have challenged the driver to simply crash through the gates. The macho image thing, you know." - Marc Clifton