Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use on pdf #11

Closed
firdows opened this issue May 19, 2016 · 2 comments
Closed

How to use on pdf #11

firdows opened this issue May 19, 2016 · 2 comments

Comments

@firdows
Copy link

firdows commented May 19, 2016

No description provided.

@tonydspaniard
Copy link
Member

tonydspaniard commented Jun 22, 2016

You will have to use a library to add the resulting image into your pdf document. Something like https://github.com/mpdf/mpdf

@DBX12
Copy link

DBX12 commented Mar 28, 2017

I have the same issue. I'm using Kartik-v's mpdf extension for Yii2 and your QR-Code extension. The issue I run into is the following:
In my view _pdf I "include" the QR code by <img src="<?= Url::to(['route/qrcode','text'=>$model->qr_code_content]) ?>" />
In my Controller I have this function

public function actionQrcode($text){
    Yii::$app->response->format = Response::FORMAT_RAW;
    Yii::$app->response->headers->set('Content-Type','image/png');
    return QrCode::png($text)
}

The Controller renders the view in the actionPdf

public function actionPdf($id) {
        $model = $this->findModel($id);
        #return $this->renderPartial('_pdf', ['model' => $model]);
        $content = $this->renderPartial('_pdf', ['model' => $model]);
        $pdf = new Pdf([
            'content' => $content,
            'filename' => 'Ticket_' . $model->id . '.pdf',
            'options' => [
                'title' => 'Your ticket as '
            ],
            'cssFile' => '@webroot/css/pdf.css'
        ]);
        $pdf->render();
    }

In the PDF the QR code is displayed as "missing image" icon, if I uncomment the third line (return $this->renderPartial(... the page renders as normal HTML and the QR code is displayed correctly.
I also created an issue for the mpdf extension. Please look up the issue together with kartik-v, thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants