Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Print a PDF from a Windows Service

Last post 09-25-2009, 10:41 PM by shahzad.latif. 15 replies.
Page 1 of 2 (16 items)   1 2 Next >
Sort Posts: Previous Next
  •  07-02-2009, 2:39 AM 186543

    Print a PDF from a Windows Service .NET

    Hello,

    I would like to know how to print a PDF from a Windows service while specifying which printer to use.

    I tried with PDFViewer, but apparently I have an error "Format string input invalid"

    An idea, a procedure?
     
  •  07-02-2009, 2:56 AM 186547 in reply to 186543

    Re: Print a PDF from a Windows Service .NET

    Attachment: Present (inaccessible)

    I try to open my pdf with Acrobat and it's ok. But, with PDFViewer, i have a error.

    If I use PrintLargePdf => Error

    If I use OpenPdfFile => Error

    And always the same error : "Format invalid"

     
  •  07-02-2009, 11:34 AM 186624 in reply to 186547

    Re: Print a PDF from a Windows Service

     

    Hi Laurent,

    I have tested this issue at my end and found no problem. I have used the following code:

     

    PdfViewer viewer = new PdfViewer();
    viewer.OpenPdfFile(common.Path("tmp86A.pdf"));

    System.Drawing.Printing.PrinterSettings pset = new System.Drawing.Printing.PrinterSettings();
    pset.Copies = 1; //specify number of copies
    pset.PrinterName = "HP Officejet 4300 series"; // name of default printer to be used

    viewer.PrintDocumentWithSettings(pset); //pass printer settings object to the method
    viewer.ClosePdfFile();

    Kindly try this code snippet at your end. You can also use this code in the windows service and specify the printer name as well. If you still find any problem, please do let us know.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-03-2009, 2:08 AM 186707 in reply to 186624

    Re: Print a PDF from a Windows Service

    I do not find the "common.Path" I assume that the correction of my problem came from there, as my error is on the "OpenPdfFile"

    The rest of your example is exactly what I do.
     
  •  07-03-2009, 2:55 AM 186720 in reply to 186707

    Re: Print a PDF from a Windows Service

    Hi Laurent,

    I'm sorry for the inconvenience. In fact, common.Path has nothing to do with the actual code; that is my custom method to resolve the path to the test files. You can specify the path as OpenPdfFile(@"c:\test").

    Please try it like this. If problem still persists then please make make a sample windows project with your code and share with us, so that we could have a look and find the problem.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-03-2009, 3:14 AM 186726 in reply to 186720

    Re: Print a PDF from a Windows Service

    Ok, so I tried and it does not change my problem. My concern comes from the OpenPdfFile. I have the error when I try to call.
     
  •  07-03-2009, 5:28 AM 186749 in reply to 186726

    Re: Print a PDF from a Windows Service

    Hi,

    Please share your code with us and the detailed error message as well. Kindly, mention which version of Aspose.Pdf.Kit for .NET you're using? Are you using a 32-bit or 64-bit machine? Which OS are you using.

    As a matter of fact, in order to diagnose the problem we need to create the scenario at our end and reproduce the problem, so that we'll be able to fix it.

    We really appreciate your cooperation.

     Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-03-2009, 6:27 AM 186762 in reply to 186749

    Re: Print a PDF from a Windows Service

    Attachment: Present (inaccessible)
    The file that I have provided as an attachment causes the error.
    I am running Windows XP SP3 32 bits.
    I'm using version 3.4.0.0 of Aspose.Pdf.Kit for. NET 2.0
    I provided an example program that generates the same error (in french):
     
    L'exception System.FormatException n'a pas été gérée
      Message="Le format de la chaîne d'entrée est incorrect."
      Source="Aspose.Pdf.Kit"
      StackTrace:
           à Aspose.Pdf.Kit.PdfViewer.OpenPdfFile(String filePath)
           à WindowsApplication1.Form1.simpleButton1_Click(Object sender, EventArgs e) dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs:ligne 29
           à System.Windows.Forms.Control.OnClick(EventArgs e)
           à DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)
           à DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)
           à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           à System.Windows.Forms.Control.WndProc(Message& m)
           à DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
           à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           à System.Windows.Forms.Application.Run(Form mainForm)
           à WindowsApplication1.Program.Main() dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs:ligne 17
           à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()
     
  •  07-03-2009, 6:33 AM 186763 in reply to 186762

    Re: Print a PDF from a Windows Service

    Attachment: Present (inaccessible)
    I provided a new project as an example the first use of specific components, but the problem still exists in this version.
     
  •  07-03-2009, 11:06 AM 186820 in reply to 186763

    Re: Print a PDF from a Windows Service

    Hi,

    Thank you very much for sharing the details. We'll look into the matter and update you the earliest possible.

    We appreciate your patience.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-07-2009, 11:45 AM 187331 in reply to 186820

    Re: Print a PDF from a Windows Service

    Hi,

    I have again tested the issue at my end using the same specifications as yours and found no problem. Can you please try Aspose.Pdf.Kit 3.5.0.0 at your end? This is our latest version of Aspose.Pdf.Kit. I'm very sorry that you're having this problem. Nevertheless, if problem persists then, please do let us know, so that I'll be able to forward a request to our development team for further investigation.

    We're sorry for the inconvenience.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-08-2009, 1:52 AM 187409 in reply to 187331

    Re: Print a PDF from a Windows Service

    Hello,

    I just tried with version 3.5.0.0 but I have apparently the same mistake. Apparently, this is a format error. Visual Studio refers to DateTime, so I wish to clarify that I use a French version of Windows with the locale french if it can help you during the tests.

    L'exception System.FormatException n'a pas été gérée
      Message="Le format de la chaîne d'entrée est incorrect."
      Source="Aspose.Pdf.Kit"
      StackTrace:
           à Aspose.Pdf.Kit.PdfViewer.OpenPdfFile(String filePath)
           à WindowsApplication1.Form1.button2_Click(Object sender, EventArgs e) dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs:ligne 38
           à System.Windows.Forms.Control.OnClick(EventArgs e)
           à System.Windows.Forms.Button.OnClick(EventArgs e)
           à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           à System.Windows.Forms.Control.WndProc(Message& m)
           à System.Windows.Forms.ButtonBase.WndProc(Message& m)
           à System.Windows.Forms.Button.WndProc(Message& m)
           à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           à System.Windows.Forms.Application.Run(Form mainForm)
           à WindowsApplication1.Program.Main() dans C:\Documents and Settings\Laurent Bensch\Mes documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs:ligne 17
           à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()

     
  •  07-08-2009, 6:30 AM 187478 in reply to 187409

    Re: Print a PDF from a Windows Service

    Hi Laurent,

    The 'French version' proved to be a valuable piece of information! In fact, I have reproduced the isse at my end by changing the culture info to French. I have logged this issue as PDFKITNET-9586 in our issue tracking system. Our team will be looking into the matter and you'll be updated via this forum as the issue is resolved.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-08-2009, 6:38 AM 187479 in reply to 187478

    Re: Print a PDF from a Windows Service

    Pleased to have helped. I'm looking forward to the correction.
     
  •  09-25-2009, 6:27 AM 199604 in reply to 187479

    Re: Print a PDF from a Windows Service .NET

    Hi,

    I have the exact same problem. But... When I made a dummy app and created the class and method that we use in our main app the code works. But when it's exectued in our main app we get the obove mentioned FormatException Error.

    The class and method we use is:
    public static void Print(string fileName, bool showDialog)
            {
                PdfViewer viewer = new PdfViewer();
                try
                {
                    viewer.OpenPdfFile(fileName);
                    if (showDialog)
                    {
                        viewer.PrintPageDialog = false;
                        viewer.PrintDocumentWithSetup();
                    }
                    else
                    {
                        viewer.PrintDocument();
                    }
                }
                finally
                {
                    viewer.ClosePdfFile();
                }
            }

    And the Exception ossurs on line: viewer.OpenPdfFile(fileName);
    I have tested with fileName = @"c:\test.pdf".

    My developer enviroment is:
    Windows 7 64 bit Swedish. 
    Visual Studio 2008 (c#)

    Regards
    Thomas Gyllencreutz
     
Page 1 of 2 (16 items)   1 2 Next >
View as RSS news feed in XML