How to call docPrint SDK from Delphi code? I'm changed all the DLL Import functions from Pchar to PAnsiChar parameters

We have created a test package with Delphi language to you, please test it in attachment.

You can compile and run it in Delphi6, click "Print MS Word document (*.doc)" button, select a DOC file, then you will get an output JPG file in the D:\ folder.

Can you work fine with this Delphi6 example?

btw, if you are not using Delphi6, you need change string settings to ANSI instead of UNICODE, docPrint_Register() parameters is support ANSI characters only,

rslt := docPrint_Register(Pchar('XXXXXXXXXX'),Pchar('Damarco'));

VeryPDF
----------------------------------------------------
Thanks,

Delphi6 is very outdated, and I no longer use it. Currently I am using Delphi XE5 and XE7.

I used your advice and changed all the DLL Import functions to PAnsiChar parameters.

Function docPrint_Register(lpRegCode: PAnsiChar; lpCompanyName: PAnsiChar) : longint; stdcall; external 'doc2img.dll' name 'docPrint_Register';

and function calls:

rslt:=docPrint_Register(PAnsiChar('XXXXXXXXXX'),PAnsiChar('Damarco'));

This appears to be working. Once I have a little more coffee, I'll start some more in-depth testing and I will report back to you.

Thanks.
Customer
----------------------------------------------------
When ran as a normal application, this is working.

The reason I wanted to move to the DLL version is I expected this would eliminate all the issues I have trying to get this to run as a windows service. However, I have found this does not help.

I have been running a windows service on windows 2008 with Docprint Pro 5. This has been working well. However, it does not with on Windows server 2012R2.

I have tried using the DLL, COM Objects, and CreateProcess with command line. All do the same thing. I see Doc2PDF.exe gets started, then it hangs. I have no idea if its displaying message box or if its having another issue.

What I need is for Doc2PDF to work from within a windows service, running on Windows 2012R2, and I need it completely unattended. No desktop interaction. How can I achieve this? I am converting http URLS, and .txt files to PDF (Office not needed).

Thanks
Customer
----------------------------------------------------
I understand your situation, when you call doc2pdf.exe from server side application, doc2pdf.exe will be run inside SYSTEM user account, but MS Office is not work properly from SYSTEM user account, this is a limitation in MS Office, so doc2pdf.exe will hang. In order to solve this problem, you need run doc2pdf.exe or Office DCOM inside an interactive user account instead of SYSTEM user account, then you will get it work fine.

Our Knowledge Base is contain more examples and solutions for this situation,

http://www.verypdf.com/wordpress/category/docprint-pro

for example,

Please look at "Example 6" and "Example 7" from following web page,

Example 6: Run conversion via "docPrint_Service.exe" application,

http://www.verypdf.com/artprint/docprintsdk.htm

Example 7: Run conversion inside an interactive user account from service or web applications,

http://www.verypdf.com/artprint/docprintsdk.htm

You can also call "docPrintCom.exe" from your code to convert office files to PDF files, please look at following web pages for more information,

http://www.verypdf.com/wordpress/201403/verypdf-release-notes-verypdf-has-release-a-new-docprintcomexe-for-docprint-sdk-product-40311.html

http://www.verypdf.com/wordpress/201412/doc2img-dll-library-an-attempt-was-made-to-load-a-program-with-an-incorrect-format-exception-from-hresult-0x8007000b-41125.html

In order to convert office files to PDF files by "docPrintComExe", you can run "C:\Program Files (x86)\docPrint Pro v6.0\docPrint_Service.exe" as a normal Windows EXE application first, then you can run following code to convert your office files or HTML files to PDF files,
------------------------------
strLicenseKey = "XXXX-XXXX-XXXX-XXXX"

set docPrintObj = CreateObject("docPrintComExe.docPrint")

'Please run "docPrint_Service.exe" application before you call this function
nRet = docPrintObj.RunCmdViaDocPrintService("-* " & strLicenseKey & " -i D:\temp\test.docx -o D:\temp\out2.pdf", 1, strLicenseKey)
------------------------------

The following is another VBScript source code, you can port it to Delphi code easily,

------------------------------
strInputFile = "http://www.verypdf.com"
strLicenseKey = "XXXX-XXXX-XXXX-XXXX"

Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)
strOutputFile = strFolder & "\output.pdf"

Set docPrint = CreateObject("DocPrintComExe.docPrint")
nRet = docPrint.docPrintCOM_Register(strLicenseKey, "VeryPDF.com Company")
nRet = docPrint.RunCmd("-i " & strInputFile & " -o " & strOutputFile & " -* " & strLicenseKey & " -s ""htmlheader=VeryPDF Page Header"" -s ""htmlfooter=VeryPDF Page Footer""", 1)

If (fso.FileExists(strOutputFile)) Then
   msg = strOutputFile & " exists."
Else
   msg = strOutputFile & " doesn't exist."
End If
MsgBox msg
------------------------------

Above solutions are all need run "C:\Program Files (x86)\docPrint Pro v6.0\docPrint_Service.exe" as a normal Windows EXE application by manual after a user logged into system, if your server is nobody to logged in, you can use "VeryPDFComRunCmd COM Component" to run doc2pdf.exe from Administrator user account directly,

http://www.verydoc.com/exeshell.html#VeryPDFComRunCmd_COM_Component

http://www.verydoc.com/blog/verydoc-release-notes-verydoc-releases-an-exe-com-of-verypdfcomruncmd-exe-today-verypdf-exe-com-does-allow-you-to-call-ms-office-and-any-exe-application-from-asp-php-c-net-etc-program-languag.html

"VeryPDFComRunCmd COM Component" can be used to run any EXE from any User account, we sure this COM will solve this problem to you completely.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

This entry was posted in docPrint Pro and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!