Splitting Pdf

New Here ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

I am trying to write a cold fusion program which splits up a pdf file with multiple pages into separate files for each page. In other words, let's say I have a pdf document (document.pdf) that has 100 pages, I want the program to break it up so I end up with 100 files, one for each page (document0001.pdf, document0002.pdf,document0003.pdf,document0004.pdf,document0005.pdf etc, etc.). Any help would be greatly appreciated.
TOPICS
Advanced techniques

Views

1.0K

Likes

Translate

Translate

Report

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

Guide , Oct 08, 2006 Oct 08, 2006
Here is a rough example. I only skimmed the API so no guarantees. You can change the numbering of the file names on your own.

Likes

Translate

Translate
Guide ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

This thread has an example of reading/writing a pdf. Its concatenating files instead of splitting, but is should get you started
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1191362

http://itextdocs.lowagie.com/tutorial/index.html

Likes

Translate

Translate

Report

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
Guide ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

..

Likes

Translate

Translate

Report

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
Guide ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

..

Likes

Translate

Translate

Report

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 ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

This thread has an example of reading/writing a pdf. Its concatenating files
instead of splitting, but it might get you started

http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&t
hreadid=1191362

http://itextdocs.lowagie.com/tutorial/index.html

Likes

Translate

Translate

Report

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 ,
Oct 08, 2006 Oct 08, 2006

Copy link to clipboard

Copied

Thanks for your response. I had already seen that posting and struggled with the code. It works great for concatenating files but I am not a good enough programmer to use it to get to spiltting a pdf file. It works extremely fast in concatenating files and I was hoping to use similar coade to split a pdf up.

Likes

Translate

Translate

Report

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
Guide ,
Oct 08, 2006 Oct 08, 2006

Copy link to clipboard

Copied

Here is a rough example. I only skimmed the API so no guarantees. You can change the numbering of the file names on your own.

Likes

Translate

Translate

Report

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 ,
Oct 08, 2006 Oct 08, 2006

Copy link to clipboard

Copied

Fantastic. Thanks. That's exactly what I needed and it works extremely fast.

Likes

Translate

Translate

Report

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 Beginner ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

Hi Foresite,

 I hope you are still active here. 

I noticed your question, and I cannot seem to find the answer that helped you.

I am looking for ways to do exactly what you were looking back than.

Can you help out, please?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Apr 18, 2021 Apr 18, 2021

Copy link to clipboard

Copied

@PCR3TDDV , in software terms, 2006 is quite a number of generations ago. ColdFusion has moved on since then. From ColdFusion 8 onwards, you can use cfpdf to perform operations on a PDF file.

 

For example, the following function will extract each page of a given PDF document as a single PDF document:

 

<cffunction name="extractPDFDocAsSinlePages" output="false" returntype="void">
	<cfargument name="originalPDFDocSource" required="yes" type="string">
	<cfargument name="destinationFolder" required="yes" type="string">
	<cfargument name="totalnumberOfPagesOfOriginalPDFDoc" required="yes" type="numeric">
	
	<cfset var numberOfPages=arguments.totalnumberOfPagesOfOriginalPDFDoc>
	<cfif numberOfPages eq 1><!---Nothing to do.--->
		<cfreturn>
	</cfif>
	
	<cfset var currentPage=0>
	<cfset var pagesToDelete="">
	
	<cfloop index="currentPage" from="1" to="#numberOfPages#">	
		<cfif currentPage eq 1>
			<cfset pagesToDelete="2-#numberOfPages#">
		<cfelseif currentPage eq numberOfPages>
			<cfset pagesToDelete="1-#numberOfPages-1#">
		<cfelse>
			<cfset pagesToDelete="1-#currentPage-1#,#currentPage+1#-#numberOfPages#">
		</cfif>
		
		
		<cfpdf
	    action = "deletepages"
	    pages = "#pagesToDelete#"
	    source = "#arguments.originalPDFDocSource#"
	    overwrite = "yes"
	    destination = "#arguments.destinationFolder#\myDoc_page_#currentPage#.pdf">
	    
	</cfloop>

</cffunction>

<!--- Test Code --->
<!--- testDoc.pdf has 18 pages --->
<!--- The 18 extracted pages are stored in C:\Users\BKBK\Desktop\docs\extracted --->
<!---
<cfoutput>#extractPDFDocAsSinlePages("C:\Users\BKBK\Desktop\docs\testDoc.pdf","C:\Users\BKBK\Desktop\docs\extracted",18)#</cfoutput>
--->

 

Likes

Translate

Translate

Report

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 Beginner ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

LATEST

Thank you very much @ BKBK.

Likes

Translate

Translate

Report

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