User login

Who's online

There are currently 1 user and 56 guests online.

Online users

Advertisements


SourceForge.net Logo

Problem With C#

Submitted by jmpena on Tue, 2008-01-08 23:49.

well im using PDF creator to open a MSWord template in my C# application and Print the document to generate a PDF.

my problem is that i cant set the name of the PDF.

i found some code on internet to do that but all that i found doesn't work at all.

here is the code. [in this way the PDFcreator creates a PDF in the default path and with the default name, the problem goes in the Code show in the bottom (PART 2)]

PART 1

clsPDFCreator creator = new clsPDFCreator();
string parameters = "/NoProcessingAtStartup";
if (!creator.cStart(parameters,false))
{
return false;
}
else
{
creator.cClearCache();

oWordApp.ActivePrinter = "PDFCreator";

Object false_object = false;
Object missingValue = Type.Missing;
Object background = true;
Object append = true;
Object range = Word.WdPrintOutRange.wdPrintAllDocument;
Object outputFileName = Type.Missing;
Object from = Type.Missing;
Object to = Type.Missing;
Object item = Word.WdPrintOutItem.wdPrintDocumentContent;
Object copies = 1;
Object pages = Type.Missing;
Object pageType = Word.WdPrintOutPages.wdPrintAllPages;
Object printToFile = false;
Object collate = Type.Missing;
Object fileName = Type.Missing;
Object activePrinterMacGX = Type.Missing;
Object manualDuplexPrint = Type.Missing;
Object printZoomColumn = Type.Missing;
Object printZoomRow = Type.Missing;
Object printZoomPaperWidth = Type.Missing;
Object printZoomPaperHeight = Type.Missing;

oWordApp.PrintOut(ref background, ref append, ref range, ref outputFileName, ref from, ref to, ref item, ref copies, ref pages, ref pageType, ref printToFile, ref collate, ref fileName, ref activePrinterMacGX, ref manualDuplexPrint, ref printZoomColumn, ref printZoomRow, ref printZoomPaperWidth, ref printZoomPaperHeight);

// Wait till doc gets queued up.
while (creator.cCountOfPrintjobs != 1) ;
creator.cPrinterStop = false;

// Wait till all doc get converted to pdf.
while (creator.cCountOfPrintjobs != 0) ;

// Close all the opened documents.
foreach (Word.Document doc in oWordApp.Documents)
doc.Close(ref false_object, ref missingValue, ref missingValue);

// Stop the printer.
creator.cPrinterStop = true;

// Set back the default printer.
oWordApp.Quit(ref false_object, ref missingValue, ref missingValue);

// Close the printer
creator.cClose();
creator = null;

****************************************
PART 2

IF I USE THIS, the program show a popup parameter window, i fill them but the PDF dont get create.

by the way, i dont want my app to show de popup because it will show on the server.

clsPDFCreatorOptions opt = new clsPDFCreatorOptions();
opt.UseAutosave = 1;
opt.StartStandardProgram = 0;
// Use directory for saving the file.
opt.UseAutosaveDirectory = 1;
// Name of the output directory.
opt.AutosaveDirectory = @"c:\";
// Format in which file is to be saved. 0 if for pdf.
opt.AutosaveFormat = 0;
// Name of the output file name.
opt.AutosaveFilename = NewFileName;
creator.cOptions = opt;

creator.cClearCache();

ANY HELP!!

PLEASEEEEEEEEEEE

© 2006 by pdfforge.org :: Contact us

Validate XHTML or CSS.