How to use ps2pdfsdk and ps2pdfcom to convert Postscript, PS and EPS files to PDF files from 64bit C# application?

Hi,

I have a developer license for ps2pdf and am trying to follow the instructions on

https://www.verypdf.com/wordpress/201301/how-to-use-ps2pdfsdk-from-64bit-c-application-34100.html

for how to use the ps2pdfsdk through COM in C# .NET. I have succeeded in registering in COM and getting a reference to ps2pdfcom in my application, but from there I am not sure how to make the actual call to VeryPDF_PSToPDF. The instructions in that link seem more geared towards C or Javascript. Can you provide specific instructions for invoking it in C#? The C# example provided in the zip only shows how it works for PInvoke with the 32 bit ps2pdfsdk.dll, which is not what I need. This is for a critical customer-specific application that we need to get working asap.

Thanks,
Customer
-------------------------------------

image
Thanks for your message, please refer to following example to understand how to call "ps2pdfcom.ps2pdf" from C# application,

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using ps2pdfcom;

using System.IO;

 

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            string appPath = Path.GetDirectoryName(Application.ExecutablePath);

            string strInFile = appPath + "\\test.ps";

            string strOutFile = appPath + "\\_test.pdf";

            string strLicenseKey = "-$ XXXX-XXXX-XXXX-XXXX";

 

            string strCmd = strLicenseKey + " \"" + strInFile + "\" \"" + strOutFile + "\"";

 

            System.Type VeryPDFType = System.Type.GetTypeFromProgID("ps2pdfcom.ps2pdf");

            ps2pdfcom.ps2pdf VeryPDFCom = (ps2pdfcom.ps2pdf)System.Activator.CreateInstance(VeryPDFType);

            VeryPDFCom.com_VeryPDF_PSToPDF(strCmd);

            MessageBox.Show("Converter finished.");

        }

    }

}

 

If you need an entire C# project, please feel free contact us, we will send the entire project to you asap.

 

The following is a simple VBScript source code to call "ps2pdfcom.ps2pdf", you can save it to a "test.vbs" file and run it to convert PS to PDF file easily,

--------------------------------------------------------------
Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)

strInFile = strFolder & "\test.ps"
strOutFile = strFolder & "\test_vbs.pdf"
strCmd = "ps2pdf -$ XXXXXXXXXXXXX " & strInFile & " " & strOutFile

Set ps2pdfcom = CreateObject("ps2pdfcom.ps2pdf")
ps2pdfcom.com_VeryPDF_PSToPDF strCmd
--------------------------------------------------------------

VeryPDF

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

One Reply to “How to use ps2pdfsdk and ps2pdfcom to convert Postscript, PS and EPS files to PDF files from 64bit C# application?”

  1. Hi,

    One other question. I am trying to package together an install for ps2pdfcom and wanted to know which files are needed in order to run ps2pdfcom on a particular machine? Is it just the following:

    install.bat
    ps2pdfcom.exe
    ps2pdfsdk.dll

    Or are other ones from the ps2pdfsdk\bin folder needed as well? Such as ps2pdfsdk.lib? I would like to not have to include the entire bi folder, as it is rather large.

    Thanks,
    Customer
    —————————————–
    You need distribute following files along with your product,

    pdf2any.dll
    pdfsdk.dll
    pdftools.dll
    ps2pdf.dll
    ps2pdfsdk.dll
    ps2pdf_x64.dll
    ps2pdf_x86.dll
    winfont.map
    encoding\*.*

    You can simple ignore any other files except above.

    VeryPDF

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

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!