cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior of SaveAs() function

former_member329524
Active Participant
0 Kudos

Hello, all

I am having the strangest issue with SaveAs(PDF!, true) function for data store.

When application is run normally, in the user session, the function works correctly.

However, when the application is launched in batch mode from SQL Anywhere DB server (using xp_cmdshell command) it returns -1.

What am I missing here ?

Thank you

Arcady

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

My guess would be permissions, the SQL Anywhere DB will be running as a specific user and may not have permission to either run ghostscript or the folders where you are trying to save the PDF.

David

former_member329524
Active Participant
0 Kudos

I thought of that, but the DB Server is running with "System" user and the destination folder is the working directory folder where other files (text) are written all the time.

former_member329524
Active Participant
0 Kudos

After changing the user of the service from "SYSTEM"  to regular domain user it all started working.

I will try to get some answers from the IT department, but does anyone know of a similar issue?

Former Member
0 Kudos

Hi Archady;

It's the same problem & solution when running a Web Service NVUO that generates PDF's. You gave to run it inside an IIs application pool with the correct permissions.

Regards ... Chris

Former Member
0 Kudos

Just spoke with my tech support. They say that a windows service runs in a different environment and actually cannot see the printers. So you will have to create a user for this service and run it as that. So your using a domain user login is the only fix, just need to create a restricted user for this purpose.

Former Member
0 Kudos

It sounds like you probably already have this sorted, but I had a similar problem in Windows Server 2012 where it created a PDF, but it was 0 bytes.  To fix it I had to add a few registry entries to make the Ghostscript PDF printer visible to the SYSTEM account.  The registry entries were under :

HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\

(Devices, PrinterPorts and Windows keys)

As David says below, my problem was because the SYSTEM account ran in an environment where the printers weren't visible.  Adding the registry entries made them visible to the SYSTEM account.

Edit - Here is the knowledge base article that helped me (although my problem was not related to COM): https://support.microsoft.com/en-au/kb/184291

Former Member
0 Kudos

Very useful post Daryl. Thanks

Answers (0)