How to convert PDF to XPS using Delphi?

Q: We need to convert files of PDF to XPS. PDF to Vector Converter seems to be what we're looking for. But...How would I integrate this into a Delphi application? Do you have a Delphi units that contain a ready written interface to the DLL?Ideally the application would be one single exe, but we will accept a DLL(We won't accept a command line tool to sit alongside out exe, nor a client/server solution.)

*************************************************************************************

A:You can call "PDF to Vector Converter Command Line Developer License USD$1995" from your Delphi code by CreateProcess() API function, we hoping this command line application will useful to you.
If you are good at DLL integration, you can call PDF to Vector Converter SDK from your Delphi code, but we haven't Delphi example yet, please refer to following VB6 code, you can port it to Delphi code easily,
================================
Private Declare Function VeryPDF_PDF2Vector Lib "pdf2vec.dll" (ByVal strCommandLine As String) As Long
Private Sub Command1_Click()
Dim nRet As Long
Dim strCmd As String
strCmd = "pdf2vec.exe" & " -$" & " XXXXXXXXXXXXXXXXXXXX"
strCmd = strCmd & " d:\temp\11.pdf"
strCmd = strCmd & " C:\out.swf"
nRet = VeryPDF_PDF2Vector(strCmd)
MsgBox (Str(nRet))
End Sub

******************************************************************

Q:We won't accept a command line tool to sit alongside out exe
So that example using pdf2vec.exe is redundant.
However, DLL integration won't be a problem, as long as I get proper definitions of the published DLL functions. In fact, you can have the Delphi code when I'm done so you can give them to other users thereafter.
Can you give me a complete definition of those published functions?
Better yet, could you let me know what calls I need to make to convert PDF files to XPS?

******************************************************************

A:Yes, no problem, please refer to following definition by VB and VC++,
Private Declare Function VeryPDF_PDF2Vector Lib "pdf2vec.dll" (ByVal strCommandLine As String) As Long
__declspec(dllexport)
int WINAPI VeryPDF_PDF2Vector(LPCTSTR lpCommand);
You can run following code to convert PDF to XPS easily,
int nRet = VeryPDF_PDF2Vector("pdf2vec -$ XXXXXXX C:\test.pdf C:\out.xps");

******************************************************************

The end reply: Thank you. Now I've got it to work. 🙂
Here's the Delphi declaration for pdf2vec...
{$EXTERNALSYM VeryPDF_PDF2Vector}
function VeryPDF_PDF2Vector(strCommandLine : PAnsiChar): Int64; stdcall; external 'pdf2vec.dll' name 'VeryPDF_PDF2Vector';
...and here's how to use it...
const
SLicenceKey = 'XXXXXXXXXXXXXXXXXXXX';
var
i: integer;
lCommand, lSource, lDest: AnsiString;
begin
if OpenDialog2.Execute then
begin
lSource := OpenDialog2.FileName;
lDest := ChangeFileExt(lSource, '.xps');
lCommand:= 'pdf2vec "-$" "' + SLicenceKey + '" "' + lSource + '" "' + lDest + '"';
if FileExists(lDest) then
if not DeleteFile(lDest) then
raise Exception.Create('File already exists: ' + lDest);
i := VeryPDF_PDF2Vector(PAnsiChar(lCommand));
ShowMessage(IntToStr(i));
end;
end;

******************************************************************************

If you have any question about file format conversion like PDF to XPS by Delphi, you are welcome to contact us by the ways supported on this website.

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

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!