?
Solved

Extract Pages from PDF file with Acrobat Professional

Posted on 2011-04-28
6
Medium Priority
?
368 Views
Last Modified: 2012-05-11
Hi,

I am just starting a project that I think is going to be a real pain in the #$%%.   I was hoping someone could point me in the right direction or give me a link.  I have a large PDF file containing many 2-page policies.  I have a report of these policy numbers and what page the first page is in the PDF file.  

My task is to create individual PDF files for eacy policy with their unique policy number as the file name.  

I have thousands of polices to extract for input to another system.  Any direction you can provide would be greatly appreciated.  Thanks,

josh
0
Comment
Question by:joshcallahan1
5 Comments
 
LVL 30

Expert Comment

by:Randy Downs
ID: 35487404
0
 

Author Comment

by:joshcallahan1
ID: 35491151
Number-1,

Thanks for the comment, these don't directly solve my problem but the same company puts out a spitter that may work with a little vbscripting to liven it up.  The program splits the specified page ranges, which I know is in intervals of 2.  Depending on the naming conventions that are used I may be able to rename the output files to match the file that I have. here is the command line from the program to split out the pages:

"C:\Program Files\AdvancedReliableSoftware\AdvancedCommandLinePdfSplitter\aclpdfsplit.exe"
-sds "C:\InputDirectory" "C:\OutputDirectory" 1-2, 3-4, 4-5, 6-7 

Open in new window


If Ican rename the outputing using my file with the index and usinge VBscript I may be in business, in the mean time any other comments are welcome as this work around does require a purchase and extra work and multiple steps.

Josh
0
 
LVL 2

Accepted Solution

by:
stuartmorris earned 2000 total points
ID: 35513404
The best library out there for pdf manipulation is the iText one or the iTextSharp .NEt offshoot.

http://sourceforge.net/projects/itextsharp/
The documentation is extensive but you may need to translate stuff from the original Java language iText project to work with .NET
http://itextpdf.com/

The code below isn't perfect, but should get you going towards your solution.

   
public static void splitMyPDF(String inputpdf, String outputFolder) {
	try {
		PdfReader reader = new PdfReader(inputpdf);
		//Loop through
		for (int i = 0; i < YOURPAGECOUNTVARIABLEHERE; i=i+2) {
			extractSubDocToPDF(reader, i, i+2, "PAGE" + i + ".pdf", outputFolder);
		}
	}
	catch (IOException e) {
		Console.WriteLine(e.Message);
	}
}


private static void extractSubDocToPDF(PdfReader reader, int pageFrom, int pageTo, String outputName, String outputFolder) {
	Document document = new Document();
	try {
		// Create a writer for the outputstream
		PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outputFolder + outputName, FileMode.Create));
		document.Open();
		PdfContentByte cb = writer.DirectContent; // Holds the PDF data
		PdfImportedPage page;

		while (pageFrom < pageTo) {
			document.NewPage();
			page = writer.GetImportedPage(reader, pageFrom);
			cb.AddTemplate(page, 0, 0);
			pageFrom++;
		}
		document.Close ();
	}
	catch (Exception ex) {
	   Console.WriteLine(ex.Message);
	}
	finally {
		if (document.IsOpen())
			document.Close ();
	}
}

Open in new window

0
 

Author Comment

by:joshcallahan1
ID: 35515434
stuartmorris:,

Thanks for the comment sounds like you known a bunch about Javascript.  I'm really green on it, I'm going to try (when I get time), to create an Access database to create the batch file commands to split the files.  If that doesn't work I'll try out your example.

Josh

0
 
LVL 31

Expert Comment

by:James Murrell
ID: 36427191
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…
Suggested Courses

588 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