Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have been working to create activex control for printing the files. now at the moment my what my function does is that

printdoc(file_path);

file_path is the path of file residing in my harddisk such as C:\abc.text, D:\def.jpg etc.
its is working path.
now i have to move this object to the office client server system. where clients will retrieve files from server via http:\xyx\asd.doc\ etc.
i am just assigning this http:\ path to the "file_path" variable. but it is not working.

can anyone explain me why its nt working??
and how can i make it to work?
Posted
Comments
hina_abbas123 21-Nov-13 2:09am    
ahh...sorry for the comment :-(
Er Daljeet Singh 21-Nov-13 2:26am    
try to give the relative path not the absolute path
use Server.Mappath() for giving the path to the printdoc function
hina_abbas123 21-Nov-13 3:21am    
http://10.33.100.90/fileServer/inDocuments/File009830EAA6B4F5943E12C9E04400144F3EB0DC009830.doc
this is the file path i want to print.
kindly tell me how can i use server.mappath() with it?
Er Daljeet Singh 21-Nov-13 4:16am    
try this code

class PrintDoc : PrintDocument
{
public Font font;
string text;
protected override void OnPrintPage(PrintPageEventArgs e)
{
base.OnPrintPage(e);
if (text == null) text = File.ReadAllText(this.DocumentName);
int chars, lines;
SizeF textSize = e.Graphics.MeasureString(text, font, e.MarginBounds.Size, StringFormat.GenericTypographic, out chars, out lines);
string textDrawn = text.Substring(0, chars);
e.Graphics.DrawString(textDrawn, font, Brushes.Black, e.MarginBounds.Location);
if (chars < text.Length)
{
text = text.Substring(chars);
e.HasMorePages = true;
}
}
}

on button click

PrintDoc doc = new PrintDoc();
doc.DocumentName = @"C:\Users\daljeet\Desktop\Modified_Files_Name.txt";
doc.font = new Font("Consolas", 9);
doc.Print();
hina_abbas123 22-Nov-13 0:00am    
but here again.. file is being selected from hardware.
that portion of my code is working fine.
when i run my activex on the client/server system. there system needs to get print of file located at http:/10.x.y.z/filename; it got problem.. printing the files in C:, D: drives is not the issue

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