Laravel/Angular アプリケーションがあり、その PDF に表示される変数の内容に基づいて、ページの 1 つで生成された PDF の内容を変更したいと考えています。
PDF はファイルreminder.blade.php
にあり、現在のコンテンツは次のとおりです。
<html>
<head>
...
</head>
<body style="-webkit-font-smoothing: antialiased; font-family: 'Roboto'; font-weight: normal; margin: 0; padding: 0;">
...
</body>
</html>
<body></body>
PDFに表示されるアイテムの数とそれらのアイテムの「ステータス」に応じて、に表示されるコンテンツを変更したいので、このためのHTMLをPHPif
ステートメントで囲みました:
<html>
<head>
...
</head>
@if(( count( {{ $transaction['transactionItem'] }} ) == 1) && {{ $transaction['transactionItem']['currentStatusId'] }} == '1010')
<body style="-webkit-font-smoothing: antialiased; font-family: 'Roboto'; font-weight: normal; margin: 0; padding: 0;">
... Only first page of PDF here
</body>
@else
<body style="-webkit-font-smoothing: antaliased; font-family: 'Roboto'; font-weight: normal; margin: 0; padding: 0;">
... Full PDF content here
</body>
@endif
</html>
ただし、ボタンをクリックして PDF を生成およびダウンロードすると、コンソールの [ネットワーク] タブに次のようなエラーが表示されます。
解析エラー: 構文エラー、予期しない '<' (表示: /home/vagrant/code/resources/views/pdfs/prov/reminder.blade.php)
419cdd3906d761bc1bb55581502a15d04c1fe7a7.php 8 行目 CompilerEngine->handleViewException(object(FatalThrowableError), 1) PhpEngine.php 46 行目
@if
これは、私が追加したステートメントについて不平を言っているように見えるか、またはここunexpected '<'
での回答によると、行の二重引用符内に単一引用符を使用しているという事実によるものです...閉じているにもかかわらずどちらも正しく-少なくとも私が知る限り...<body ...>
ここで私が間違っていることを知っている人はいますか?私がしようとしているように、生成されたPDFのコンテンツを条件付きで取得するにはどうすればよいですか?