Mubeenali's avatar

The connection was reset laravel setasign/fpdi

i installed the setasign to edit pdf file.All works fine.It works as it was supposed to be work.But i change a code but i went on my old code and it is not working now saying the connection was reset.if i dd anything before the $pdf->Output() it returns the value.The problem is with pdf-Output().Please help me to solve it .My previously working code in my method is:

  $pdf = new Fpdi();
        
        // add a page
        $pdf->AddPage();
        

        // set the source file
        $countPage = $pdf->setSourceFile(__DIR__."\quotation.pdf");
         
        // import page 1
        $tplIdx = $pdf->importPage(1,PdfReader\PageBoundaries::MEDIA_BOX);
        // use the imported page and place it at position 10,10 with a width of 210 mm A4
       //$pdf->useTemplate($tplIdx,10, 10, 100);
        //return $tplIdx;
        //$tempateSize = $pdf->getTemplateSize($tplIdx);
       // return $tempateSize;
       $pdf->useTemplate($tplIdx,0, 0,210,297); 
       
      // $pdf->useImportedPage($tplIdx,0, 0,210,297);
      
        
        // now write some text above the imported page
        $pdf->SetFont('Helvetica');
        $pdf->SetTextColor(0, 0, 0);
        $pdf->SetFontSize(15);
        $pdf->SetXY(10,30);
       // $pdf->Write(10,'Name:');  //first argument moves from top 
        
        $pdf->Text(10,40,"Company Name:");  //2nd argument moves from top to bottom
        $pdf->Text(50,40,"Mubeen Company");    // first argument moves from let to right 

        $pdf->Text(10,50,"Mobile:");
        $pdf->Text(50,50,"923029837061");

        $pdf->Text(10,60,"Contact Person:");
        $pdf->Text(50,60,"Mubeen Khan");
        
        $pdf->Text(10,70,'Quotation');
        $pdf->setFont('Arial','B',12);
       // $pdf->Cell(0,80);
        //  move from  left to right
         $pdf->setY(75);
         // first argument width 

         $pdf->cell(15);  // move the cell from left to right
         /**
            * cell 
            * first argument  ====> width 
            * second argument ====> height
            * thir argument   ====> Column name
            * 4th argument    ====> 0 means borderless 1 means with border
            * 5th argument    ====> column text in center or in left or in right align 
            */ 

        $pdf->Cell(80,10,'Prouct Name',1,0,'C');   // first argument width 
     
        $pdf->Cell(30,10,'Original Price',1,0,'C');   // first argument width 
        $pdf->Cell(30,10,'Offered Price',1,0,'C');   // first argument width  
        
        $pdf->Ln();

        for($i=0;$i <= 100 ;$i++)
        {
              
            $pdf->cell(15);  // move the cell from left to right

            $pdf->Cell(80,10,"Some Product naem will go here Some",1,0,'L');   // first argument width 
     
            $pdf->Cell(30,10,"200",1,0,'L');   // first argument width 
            $pdf->Cell(30,10,"300",1,0,'L');   // first argument width  
        
            $pdf->Ln();


        }

        echo $pdf->Output();
        die();

Now it is not working.Please help me to solve this.

0 likes
10 replies
bugsysha's avatar

You have die(); in your code and that is killing the page 😆

Just kidding. I'm having hard time figuring what is working and what is not from your explanation and code sample. Can you explain again?

Mubeenali's avatar

helo i am trying to edit an existing pdf file via setasign package.All works fine before.but after a little change in code it is not working.Now it is my old code tat was working fine.Please tell me how to problem at page

This site can’t be reachedThe connection was reset.

bugsysha's avatar

My English is not good and yours also so I'm unable to understand you. Please try to explain without using "little change" and "is not working" cause it does not provide any valuable information.

Write here specifically what have you changed and what is not working.

Mubeenali's avatar

The code mentioned above is the old code.that was working fine.i have specified that the problem is $pdf->Output() ..need help

bugsysha's avatar

And what have you changed so it is not working anymore? If you can not explain than I do not know how to help. Repeating same sentence does not help.

Mubeenali's avatar

i just created a custom class to add the same header for this template.But after i removed that class.And now it is saying the This site can’t be reachedThe connection was reset.

bugsysha's avatar

Sorry, still not enough info for me. Can't help. Best luck.

1 like
Mubeenali's avatar

To add same header for every page of pdf file i created a custom class and extends that class to main FDI class..After it in my controller method i made an object of this class.after this the old code is not working ..may be it is store in cache .i tried to clear my cache again and again.but nothing works for me.

bugsysha's avatar

can you understand it ?

Not from the code you've showed.

This site can’t be reached. The connection was reset.

Is the error Chrome presents you with. Open Chrome Dev Tools and see what is the actual error for that request and then post that back.

What I might try to guess is that you have some wrong comment in blade file or something like that.

Please or to participate in this conversation.