I need to generate a pdf image file that is dimensionally accurate for print-out into a hard copy. In addition, I need to accurately specify of the margins around the printed image. Here is an simple test example of a possible solution (that does not seem to work correctly):
SetDirectory[NotebookDirectory[]];
{xsize,ysize} = {7,9}; (*scale is in inches*)
{{left,right},{bottom,top}} = {{1/4.,8.5-xsize-1/4.},{1/2.,11-ysize-1/2.}}; (*scale is in inches*)
Export["TestPDFNotebook.pdf",
Rasterize[Graphics[Line[72*{{0,0},{0,ysize},{xsize,ysize},{xsize,0},{0,0}}]],
ImageSize->{xsize,ysize}*72], ImageSize->{xsize,ysize}*72, ImageMargins->Floor[72.*{{left,right},{bottom,top}}]] (*scale is now in printer points*)
Note that here I am using Export to generate a pdf file of a bitmapped image that is created with Rasterize. In addition, I am using the ImageSize option to specify the intended image size during printout. I am also using the ImageMargins options to specify margin widths. Both ImageSize and ImageMargins have units of printer points (72 pnts/inch). The intended paper size is 8.5 x 11 inches. The intended image size in this example is 7 inches x 9 inches. Unfortunately the image dimensions are completely lost during printout. Why is this happening? and more importantly, how to fix it?