C# Task Scheduler App in background fails to convert excel file to PDF

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
kmoens
User
Posts: 17
Joined: Fri Nov 11, 2011 10:46 pm

C# Task Scheduler App in background fails to convert excel file to PDF

Post by kmoens »

We have an app that we use to convert files from Excel, Word, and other extensions that have a viewer that handles the "printto" verb. We recently worked with a client on a server that when our code runs in the foreground and we convert an Excel (XLSX) file to PDF it works without issue. We then used Windows Task Scheduler to start this process in the background. When we try to convert the same Excel (XLSX) file this code below will error.

The user is the same user I am logged into in a windows session and with the Task Scheduler.
Run whether user is logged on or not
Run with highest privileges
Configure for: Windows Vista, Windows Server 2008

We are using PDFX7.exe 7.0.327.1 and PDFXCoreAPI.msi Content Created on 10/24/2018 5:11 PM Revision Number {09BDD4CB-DA8B-4FE3-8466-9DF41BD50B7B}

Code: Select all


    Dim PDFPFactory As PXCComLib7.CPXCControlEx


    Public Sub New()
        PDFPFactory = New PXCComLib7.CPXCControlEx        
    End Sub
    Private Sub InitSaverObj()
        PDFPrinter = CType(PDFPFactory.Printer("", "PDF-XChange 7.0 DTPOLL", g_RegKey, ""), CPXCPrinter)
        PrinterName = PDFPrinter.Name
        PDFPrinter.SetAsDefaultPrinter()
    End Sub
    
    Public Sub ProcessDocument()

            PDFPrinter.ResetDefaults()
            PDFPrinter.Option("Save.File") = OutFileName
            PDFPrinter.Option("Save.SaveType") = "Save"
            PDFPrinter.Option("Save.ShowSaveDialog") = "No"
            PDFPrinter.Option("Save.WhenExists") = "Overwrite"


                With PDFPrinter
                    .Option("Compression.Graphics") = "Yes"
                    .Option("Compression.Text") = "Yes"
                    .Option("Compression.ASCII") = "No"
                    .Option("Compression.Color.Enabled") = "Yes"
                    .Option("Compression.Color.Method") = "Auto"
                    .Option("Compression.Indexed.Enabled") = "Yes"
                    .Option("Compression.Indexed.Method") = "Auto"
                    .Option("Compression.Mono.Enabled") = "Yes"
                    .Option("Compression.Mono.Method") = "Auto"
                End With

            PDFPrinter.Option("Fonts.EmbedAll") = 1
            PDFPrinter.Option("Save.RunApp") = False
            PDFPrinter.Option("Save.RunCustom") = "No"
            PDFPrinter.Option("Saver.ShowProgress") = "No"

            Dim procPrintto As Process = New Process
            procPrintto.StartInfo.FileName = FileName
            procPrintto.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
            procPrintto.StartInfo.CreateNoWindow = True
            procPrintto.StartInfo.Verb = "printto"
            procPrintto.StartInfo.Arguments = """" + PrinterName + """"
            procPrintto.StartInfo.UseShellExecute = True    
            procPrintto.Start()
    End Sub
What can I post to debug what is happening? Should I grab a dump file? Look at DComConfig for permissions? Get the .NET Exception thrown? Is there logging available in the PDF-XChange product?

Regards,
Kevin
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: C# Task Scheduler App in background fails to convert excel file to PDF

Post by Ivan - Tracker Software »

Can try to print to any other printer in such conditions? As I remember, office applications always required an interactive session to work.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Post Reply