Skip to main content
March 31, 2016
Answered

create new pdf c#

  • March 31, 2016
  • 1 reply
  • 4409 views

At my organization, all computers have Acrobat Pro installed. The company does not want to use any third party tools.

I am having a hard time finding any examples or documentation on how to create pdf files with C#. I have added a reference to the Acrobat Type Library in my C# application. But I am not sure where to go from there. I did this several years ago in Microsoft Access VBA, but I no longer have that code to try to adapt it to C#.

My question is, can someone please provide an example of a C# method that takes a string object and uses the text of the string to create a PDF document and then save the document to a windows folder? Also, how do I create the Acrobat application and document objects and properly close them? I remember from VBA that they had to be closed before they were destroyed.

I have tried looking at the Adobe Forums. I have also spent several hours on Google. I figured that this would be a great place to ask for help. Thanks.

David

This topic has been closed for replies.
Correct answer Test Screen Name

Your understanding is quite wrong. The Acrobat SDK is exactly what you need. I'm not sure what you think the Acrobat SDK is... perhaps you are thinking of the Adobe PDF Library.

The Acrobat SDK is a collection of documentation and examples, giving the information and resources needed by all programmers wanting to work with Acrobat. So it is ONLY useful to people with Acrobat. The Acrobat SDK doesn't create PDF files, it tells you how you can use Acrobat to do this. The SDK is free.

However, if you want to create a PDF containing a page with a single string, that's not an especially straightforward task. You are unlikely to find an example of this, and you may need to get a deeper understanding of the PDF format and write a plug-in for Acrobat.

1 reply

Test Screen NameCorrect answer
Legend
March 31, 2016

Your understanding is quite wrong. The Acrobat SDK is exactly what you need. I'm not sure what you think the Acrobat SDK is... perhaps you are thinking of the Adobe PDF Library.

The Acrobat SDK is a collection of documentation and examples, giving the information and resources needed by all programmers wanting to work with Acrobat. So it is ONLY useful to people with Acrobat. The Acrobat SDK doesn't create PDF files, it tells you how you can use Acrobat to do this. The SDK is free.

However, if you want to create a PDF containing a page with a single string, that's not an especially straightforward task. You are unlikely to find an example of this, and you may need to get a deeper understanding of the PDF format and write a plug-in for Acrobat.

March 31, 2016

Hello Test Screen Name. Sorry about that. In the past I had written some VBA code for an Access database that would output several reports to a folder in PDF format, and then combine all of the reports into one PDF file. All of this was done without using the SDK. The only requirement was that the user had to have Acrobat Pro installed on their machine.

What we are doing now is programmatically creating a Rich Text Format file. We want to give the user the option of saving as RTF or saving as PDF. So what I thought I would do is generate the string which creates the RTF, but output it as PDF instead.

I have the Acrobat.dll file on my development machine, so I have access to AcroAVDocClass and AcroPDDoc. There appear to be methods associated with these classes that should work for me, but I cannot get it to work right. I am actually creating a PDF document, but it has no pages in it. It seems like what I am doing wrong is that I have to create the document with at least one page in it before I can add anything to the document. Am I on the right track here?

Thanks for your help.

Legend
March 31, 2016

Creating a document and adding a page are straightforward with the OLE methods in the SDK.  Taking an RTF string and putting it on the page is a massive project in itself. Simpler if you don't want text formatting. But please start by getting the SDK. As a programmer you need it, and we will not read it for you!