I want to split one full PDF page into two half pages without extra white space

13 hours ago 1
ARTICLE AD BOX
public function commerceProcess(Request $request) { $request->validate([ 'files.*' => 'required|mimes:pdf|max:20480', ]); $files = $request->file('files'); if ($request->has('merge')) { return $this->mergePdf($files); } if ($request->has('keepInvoice')) { return $this->keepInvoice($request, $files); } } // === keep invoice === private function keepInvoice($request, $files) { $pdf = new Fpdi(); $file = $files[0]; $path = $file->getRealPath(); $pageCount = $pdf->setSourceFile($path); for ($page = 1; $page <= $pageCount; $page++) { $tplId = $pdf->importPage($page); $size = $pdf->getTemplateSize($tplId); $splitY = 123; // Top page $pdf->AddPage($size['orientation'], [$size['width'], ($size['height'])]); $pdf->useTemplate($tplId, 0, 0, $size['width']); $pdf->SetFillColor(255, 255, 255); // white $pdf->Rect(0, $splitY, $size['width'], $size['height'], 'F'); // Bottom page $pdf->AddPage($size['orientation'], [$size['width'], $size['height']]); $pdf->useTemplate($tplId, 0, -$splitY, $size['width'], $size['height']); $pdf->Rect(0, $splitY, $size['width'], $size['height'], 'F'); } return response($pdf->Output('keepInvoice.pdf', 'S')) ->header('Content-Type', 'application/pdf') ->header('Content-Disposition', 'inline; filename="keepInvoice.pdf"'); }

I am using “Keep Invoice” to split a PDF page into two pages. Currently, both resulting pages are full-size, where only half of the content is visible and the remaining half is blank.

I want each output page to contain only half of the original page (top half and bottom half), so that there is no blank space and each page is properly sized to the half content.

This tool is used for PDF sorting. How can I achieve proper half-page splitting without blank areas?

I have a full PDF page that contains a customer information and Tax Invoice. I want to split this into two separate pages — one for the upper part in customer information and one for the lower part in tax invoice.

So basically, I want to divide one full PDF page into two half-sized pages.

Right now, the pages are getting separated, but each output page is still full-size instead of half-size. Because of this, half of each page remains blank.

I want each page to be properly resized to show only half of the original content, without any blank space.

Read Entire Article