It is a little more complicated than just adding proxy.cgi to your web server. From your post I assume you are developing you application on your local windows machine and connecting to Geoserver that is hosted on a separate web server somewhere.
The initial issue you are running into is the different domain issue. If a web applications javascript attempts to load data that is not of a very limited range of formats from a different webserver than the webserver that hosts the site the browser will not allow this to work. With the Geoserver and the OpenLayers.Control.WMSGetFeatureInfo the information can be presented in a number of different formats and that in turn triggers the Access-Control-Allow-Origin error.
The way to get around this is to add a proxy script to the same webserver (in this case your local machine) that is serving up the web application you are working on. The dependancy here will be that your webserver can run the script. For example if you are using tomcat or jetty I would recommend a .jsp script as it is supported by default by these systems. If you are using apache2 you will need to configure it to support whatever script you prefer.
I am going to assume you are using something simple like tomcat or jetty. If this is the case add this script in the root directory of your webapp:
<%@page session="false"%>
<%@page import="java.net.*,java.io.*" %>
<%
try {
String reqUrl = request.getQueryString();
URL url = new URL(reqUrl);
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setDoOutput(true);
con.setRequestMethod(request.getMethod());
int clength = request.getContentLength();
if(clength > 0) {
con.setDoInput(true);
byte[] idata = new byte[clength];
request.getInputStream().read(idata, 0, clength);
con.getOutputStream().write(idata, 0, clength);
}
response.setContentType(con.getContentType());
BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
out.println(line);
}
rd.close();
} catch(Exception e) {
response.setStatus(500);
}
%>
This should be something like [tomcat_root)/webapps/MyApplication/proxy.jsp
Now somewhere in you application before you make any openlayers calls ect add the following:
OpenLayers.ProxyHost = "/proxy.jsp?url=";
This should get around the issue. Of course depending on your setup you may need to adjust some of this to work in your particular situation. This is how I have setup my applications before and it works quite well.
One final thing to note is that this is a very basic proxy script that I have given you here. If you are going to put it on a production server you will need to be mindful that it presents a security risk and should be hardened to protect your sytem before putting it into production.
I think this is actually an issue with your printer; it's probably set to 'print to fit' rather than 'print actual size', and so it's scaling your map when you print. It's likely something that takes place after your map has left the program; try printing as an image file of some sort (.pdf, .tiff,. jpg) from your GIS, and then printing the image.
Best Answer
I have solved my overlays printing problem. I getting image of overlays numbers within map.
I have attached screenshot.
The code is as follows.