[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Combine PDFs in .NET to make PDF Package (not *merge* PDF documents)

Posted on 2008-10-08
5
Medium Priority
?
1,393 Views
Last Modified: 2013-12-17
I have a collection of PDFs, some contain embedded XML forms.  I need to combine these into PDF packages in the same way that Adobe Acrobat allows, with a cover page and the various PDFs "embedded" within the "package".    The issue is that I have *many* of these to combine, and I'm looking for a C# (or VB.NET) solution that I can run as a console application.

Has anyone done this before?  I think I may need to use Adobe API's, the thrid-party solutions I've tried so far don't retain the XML Forms or data, or they just blow up.   :-/
0
Comment
Question by:RichHolt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:RichHolt
ID: 22666806
I should add that I'm using Adobe Acrobat 8.1.2, and have downloaded the Acrobat SDK and a lot of documentation from Adobe... and can't seem to locate any examples of creating a PDF Package.
0
 

Author Comment

by:RichHolt
ID: 22666810
Adobe Acrobat Professional v8.1.2
0
 
LVL 44

Assisted Solution

by:Karl Heinz Kremer
Karl Heinz Kremer earned 200 total points
ID: 22668076
I don't think that at this time there are any API functions to do that. If you analyze a package (or a portfolio as it's now called, but with a few more bells and whistles), you'll notice that the documents in the package are actually file attachments. You can create the structures in the low level PDF that are necessary to actually make it act like a package by using Acobat's COS level interface. For that, you need to write an Acrobat plug-in (which has quite a steep learning curve).
Packages never became that popular, maybe this will now change with portfolios, and that may create a demand for some automation tools.

0
 

Accepted Solution

by:
RichHolt earned 0 total points
ID: 22671183
After a lot if consulting with The Oracle (google), I found some tidbits that eventually led me to the solution.  iTextSharp has the capability, though it isn't easy to find.   In my code snippet below, I show you how to create a very basic PDF Package; Ill leave the PDF Document Properties and special functionality as an exercise for your own edification.

I used iTextSharp v4.1.2, available for download at:  http://sourceforge.net/project/platformdownload.php?group_id=72954


using System.Text;
using System.IO;
 
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
 
namespace PdfPkg
{
  class Program
  {
    static void Main(string[] args)
    {
      // the Cover Page is shown by default when the Pkg is opened.
      // the last arg in the PdfStamper CTOR sets the Acrobat version.
      // not sure what to do with the fileStore arg in AddFileAttachment.
      // PdfReader fails if the PDF does not exist or is not readable.
 
      try
      {
        PdfReader rdrCoverPage =
            new PdfReader("c:\\pdf\\coverPage.pdf");
        FileStream fsNewPDF =
            new FileStream("C:\\pdf\\newPkg.pdf",
            FileMode.Create, FileAccess.Write);
        PdfStamper stampPdf =
            new PdfStamper(rdrCoverPage, fsNewPDF, (char)8);
        stampPdf.AddFileAttachment(
            "Description for the attached file (signed.pdf)", null,
            "c:\\pdf\\signed.pdf", "signed.pdf");
        stampPdf.AddFileAttachment(
            "Description for the attached file (unsigned.pdf)", null,
            "c:\\pdf\\unsigned.pdf", "unsigned.pdf");
        stampPdf.MakePackage(PdfName.T);
        stampPdf.Close();
      }
      catch (IOException e)
      {
        Console.Write(e.StackTrace);
        Console.ReadLine();
      }
      catch (DocumentException e)
      {
        Console.Write(e.StackTrace);
        Console.ReadLine();
      }
 
 
    }
  }
}

Open in new window

0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 22671360
Interesting. Thanks for posting the code.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question