Solved

API for merging PDFs

Posted on 2012-04-02
3
498 Views
Last Modified: 2012-04-04
I need to create a single PDF and merge in other child-PDFs.   I will also be using bookmarks, and I need a bookmark to the page(s) where the child-PDFs are inserted.   I need a product with an API.  I will be using .NET (VB.NET)

I need a clean, straight forward of creating a single PDF, which will include text and other PDF's, and I need the ability to add a bookmark whose target is anywhere in the PDF, including the child PDFs that are inserted.

Any suggestions?
0
Comment
Question by:HLRosenberger
3 Comments
 
LVL 14

Accepted Solution

by:
binaryevo earned 250 total points
ID: 37797077
Try iTextSharp its open source and adopted from the java library.
0
 
LVL 9

Assisted Solution

by:wasiftoor
wasiftoor earned 250 total points
ID: 37797155
PDFSharp www.pdfsharp.net is one of the most widely used PDF processing libararies for .NET.

It has both the merging and bookmarking features that you are looking for.

For Bookmarking, the following sample code can be helpful:

----------------------------------------------------------------------------------------------------

// Create a new PDF document
PdfDocument document = new PdfDocument();
 
// Create a font
XFont font = new XFont("Verdana", 16);
 
// Create first page
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
gfx.DrawString("Page 1", font, XBrushes.Black, 20, 50, XStringFormats.Default);
 
// Create the root <B class=searchkeyword>bookmark</B>. You can set the style and the color.
PdfOutline outline = document.Outlines.Add("Root", page, true, PdfOutlineStyle.Bold, XColors.Red);
 
// Create some more pages
for (int idx = 2; idx <= 5; idx++)
{
  page = document.AddPage();
  gfx = XGraphics.FromPdfPage(page);
 
  string text = "Page " + idx;
  gfx.DrawString(text, font, XBrushes.Black, 20, 50, XStringFormats.Default);
 
  // Create a sub <B class=searchkeyword>bookmark</B>
  outline.Outlines.Add(text, page, true);
}
 
// Save the document...
const string filename = "<B class=searchkeyword>Bookmark</B>s_tempfile.pdf";
document.Save(filename);
// ...and start a viewer.
Process.Start(filename);


----------------------------------------------------------------------------------------------------

Good Luck.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 37809379
Thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

772 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