howto send host fonts to adobe pdf printer
ok, so i changed the adobe pdf printer preferences under the adobe pdf
settings tab to:
View Adobe PDF results is not checked
Prompt for Adobe PDF filename is not checked
Add Document Information is not checked
Do not send fonts to Adobe PDF is not checked
Delete log files for successful jobs is checked
Ask to Replace existing PDF file is not checked
and now this code works:
Microsoft.Office.Interop.Excel.Application appExcel = new
Microsoft.Office.Interop.Excel.Application();
appExcel.Workbooks.Open(@"C:\RDK\RDK Doc.xls", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet wsFile =
(Microsoft.Office.Interop.Excel.Worksheet)appExcel .Sheets[1];
wsFile.PrintOut(1, 1, 1, false, "Adobe PDF", false, false, Type.Missing);
appExcel.ThisWorkbook.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
so this will print the first worksheet of rdkdoc to a pdf without asking for
a filename, etc.
but lets say i have lots of worksheets in the excel file. watch what happens
when i try to print all of them:
Microsoft.Office.Interop.Excel.Application appExcel = new
Microsoft.Office.Interop.Excel.Application();
appExcel.Workbooks.Open(@"C:\RDK\RDK Doc.xls", Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
int i = 1;
foreach (Microsoft.Office.Interop.Excel.Worksheet wsPage in appExcel.Sheets)
{
wsPage.PrintOut(1, 1, 1, false, "Adobe PDF", false, false, Type.Missing);
Application.DoEvents();
while (!File.Exists(@"C:\RDK\RDK Doc.pdf"))
{
Thread.Sleep(3000);
}
string strFile = @"C:\RDK\page" + i.ToString() + ".pdf";
File.Delete(strFile);
File.Move(@"C:\RDK\RDK Doc.pdf", strFile);
i++;
}
appExcel.ThisWorkbook.Close(false, Type.Missing, Type.Missing);
appExcel.Quit();
the first worksheet will print fine, but after that, excel starts prompting
me for a filename.
can anyone help with this issue?
|