Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

create new pdf c#

New Here ,
Mar 31, 2016 Mar 31, 2016

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

TOPICS
Acrobat SDK and JavaScript
4.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 31, 2016 Mar 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

...
Translate
LEGEND ,
Mar 31, 2016 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2016 Mar 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016

I would rather not have to jump through all of the red tape to get my organization to allow me to download and use the SDK. Suffice it to say that it is not an easy task. Everything that gets added to our machine has to be approved by a third party who does not have a stake in what we are developing, so they do not care.

All I am asking is how to do this using the Acrobat.dll file. Like I said, I can create the PDF file but it has zero pages. So after (or while) I am creating the PDF, I would like to insert the string into the file, and then properly close the file.

Thank you again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2016 Mar 31, 2016

The SDK is not something you "install" on your computer, it's documentation and sample code. The documentation is also available online (e.g. via the link I posted earlier). Chances are you will not get far by trying to use the TLB - as far as I know, there are no routines to create static PDF content (unless you want to create annotations and then flatten the document). If you already have an RTF file, just print that to the Adobe PDF printer. That's the most straight forward way to create a PDF file from RTF.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016

hmmm...It is interesting that you say that. I looked at the SDK years ago when I was developing Microsoft Access applications. I wanted to allow users to generate and combine PDF documents without having to have Acrobat Pro installed on their machines. But the SDK was not free. Has that changed? I guess I will have to investigate that. I just assumed that it was still the same way. I went to the SDK page earlier and it looked like there was a download link, but I assumed I would be downloading dll files onto my machine, but maybe not. If they are dll files, I would have to get approval and make sure that we were licensed to used them before I could use them. I will look into it. Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2016 Mar 31, 2016

There have been times when the SDK required a membership, but the principle has always been the same: it is supplementary info for programmers who have Acrobat and want to automate it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016

Well, thanks to both of you for your patience. I guess I should know better than to make assumptions. I actually just tried to download the SDK and our IT department has blocked it. Some things we can d/l and some we cannot. So I am back to square 1.

I kind of like the idea of using Distiller if it is like using Print to PDF, but if I have to have the SDK to automate Distiller, I guess I am out of luck. We will see if the IT gods approve. Thank you again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 31, 2016 Mar 31, 2016

No, you are not back to square one unless the online document is also blocked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016

Oh, I can open and view the documentation. So I do not need and other dll's then?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016
LATEST

Never mind. I will read the documentation and find out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2016 Mar 31, 2016

Take a look at how to automate Distiller: You want to print from your application to the "Adobe PDF" virtual printer. This will by default prompt for a filename, but there is a documented method of suppressing that dialog and specifying a filename via the registry.

See here for more details: http://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FDi...

A while ago I wrote a blog post about how to do this, but using VBScript: Prevent the Save Dialog when Printing to the Adobe PDF Printer

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 31, 2016 Mar 31, 2016

Thanks for that khkremer. Unfortunately we are not allowed to modify the registry either. That includes developers and users. IT Admins are the only ones who are allowed. So if a user was trying to print to pdf, and a registry modification needed to be made, an Admin would have to approve it.

With that being said, I will take a look at Distiller. Is this something that I can automate without the SDK?

Thanks,

David

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2016 Mar 31, 2016

Your software is modifying the registry all the time. What you would be doing is not different from Acrobat or Word or Access storing information in the registry so that it is available the next time you run the application. There are registry areas that are locked down, which you cannot modify without the help of your IT department, but there are large areas that have to be open because otherwise your operating system and your applications would not be able to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines