Hi,

I need to split the pdf document into two parts,like i have a pdf which consists 100 pages,i need to split the pdf into two parts where first part consits 10 pages and second part consists 1 to 100 pages?how to do that using php?

Funny enough I'm doing a very similar thing right now. I couldn't find a solution native to the language I originally used (VBScript) by googling so what I did was create a custom ghostscript script PDF2PDF and call it from the OS shell. I'm now porting the program to PHP and was going to just use the same solution - I'd be interested to see if the geniuses here have a native PHP solution! My docs start off as BZ2 postscript, so I shell out to decompress, shell out to convert to PDF then shell out again to extract the desired pages from the PDF. ouch...

hi ....any solution how to split pdf using php code??..any one from php in daniweb?

Ok thanks for your reply,

Am using fpdf to extract the pages,and its extracting pages for some pdf's and for some [df's its showing error as file is encrypted?

Here is my code to extract pages using fpdf.

<?php
require_once('fpdf.php');
require_once('fpdi.php');
class ConcatPdf extends FPDI {
    public $files = array();
    public function setFiles($files) {
        $this->files = $files;
    }
    public function concat($sample) {
        foreach ($this->files AS $file) {
            $pageCount = $this->setSourceFile($file);

            for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
                $tplIdx = $this->ImportPage($pageNo);
                $s = $this->getTemplatesize($tplIdx);
                $this->AddPage($s['w'] > $s['h'] ? 'L' : 'P', array($s['w'], $s['h']));
                $this->useTemplate($tplIdx);
                if ($pageNo == 1 && $sample == 1) {
                    break;
                }
                if ($pageNo == 30) {
                    break;
                }
            }
        }
    }

}

$pdf = new ConcatPdf();
$pdf->setFiles(array("blank.pdf", "one.pdf")); 
$pdf->concat(0);
$pdf->Output('concat.pdf', 'D'); //D-download I-view 

?>

Any solution?

How i can sprit two portions from pdf file .
Ex. Aadhar or Pan Card pdf file i want sprit font and back protion from single pdf

Afsa, this should really be its own question instead of hijacking this old thread. However, you can use Adobe Acrobat. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.