{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
richTextBox1.Clear();
String readText = System.IO.File.ReadAllText(openFileDialog1.FileName);
richTextBox1.Rtf = readText;
richTextBox1.SaveFile(userInput,
RichTextBoxStreamType.RichText);
userInput.WriteByte(13);
Form2 Form2 = new Form2();//userInput
Form2.printControl11.PrintPreview(userInput, ref s);
Form2.ShowDialog();
s= Form2.printControl11.CustomValue;
int i_temp = 0;
XmlDocument doc = new XmlDocument();
doc.LoadXml(s);
// SetPageSetUpDialog(Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageSizeW").InnerText), Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageSizeH").InnerText), Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginL").InnerText), Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginR").InnerText), Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginT").InnerText), Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginB").InnerText), Convert.ToBoolean(doc.SelectSingleNode("/Pageset/PageScape").InnerText));
int i_width = Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageSizeDpiW").InnerText);
int i_height = Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageSizeDpiH").InnerText);
int i_MarginRight = Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginHundredthsOfInchR").InnerText);
int i_MarginTop = Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginHundredthsOfInchT").InnerText);
int i_MarginBottom = Convert.ToInt32(doc.SelectSingleNode("/Pageset/PageMarginHundredthsOfInchB").InnerText);
i_MarginRight = Form2.printControl11.ConvertUnit_HundredthsOfInchToDPi(i_MarginRight);
i_MarginTop = Form2.printControl11.ConvertUnit_HundredthsOfInchToDPi(i_MarginTop);
i_MarginBottom = Form2.printControl11.ConvertUnit_HundredthsOfInchToDPi(i_MarginBottom);
//panel1.Height = i_height;
//int i_panelLeft = panel1.Left;
richTextBox2.Width = i_width - i_MarginLeft - i_MarginRight;
richTextBox2.Height = i_height - i_MarginTop - i_MarginBottom;
richTextBox2.Left = i_MarginLeft;
richTextBox2.Top = i_MarginTop;
userInput.Dispose();
}
}