Search code examples
c#.netstringstring-formattingfoxit

Formatting a string in .net for printing a pdf file with Foxit reader


I need help in formatting a string in C#.Simple one, but can't get the fog of my mind.

I have a foxit reader which reads the .pdf file and prints it on to the printer, the user chooses.

MergerPDF.destinationfile is the location of file

PrinterName = @"Companyhi-spdSupply";
commandLine.Arguments = " //t " + mergedPDF.destinationfile + " " + PrinterName;

We are trying to execute it from C# code, which triggers a generic syntax error. Here is the program call statement :

commandLine.Arguments?  " //t C:\\EDR Parser\\EDR\\2016-05-27_09-07_Zero.pdf Comapnyhi-spdSupply"   

We have the command line printing , which is working, when we give this command:

/t "C:\EDR Parser\EDR\2016-05-26_10-56_non_Zero.pdf" Companyhi-spdSupply

Solution

  • Without gettign too fancy, if commandline.Arguments will take it

    commandLine.Arguments = @" /t """  + @mergedPDF.destinationfile.Replace("\\\\", "\\") + @""" " + PrinterName;
    

    the output string is

    /t "C:\EDR Parser\EDR\2016-05-27_09-07_Zero.pdf" Companyhi-spdSupply