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

No content in outputPath! #97

Closed
AureliusHogan opened this issue Oct 17, 2018 · 12 comments
Closed

No content in outputPath! #97

AureliusHogan opened this issue Oct 17, 2018 · 12 comments
Assignees
Labels

Comments

@AureliusHogan
Copy link

I upgraded from version 1.x to version 2.0 and did all of the upgrading changes.

<pdf:document sourceFile="fileadmin/template.pdf" outputPath="typo3temp/registration.pdf">

This statement leads to a registration.pdf equal template.pdf. If I use outputDestination="inline" the result has the content of template.pdf inlcuding all pdf:text statements I've set.

Why does registration.pdf don't carry any content? What could be missing?

@maechler
Copy link
Member

maechler commented Oct 17, 2018

If you use outputDestination="inline" then it is only returned inline to the browser, but not saved to the filesystem. If you want to save it to the filesystem you should use outputDestination="file" or outputDestination="file-inline" to save it AND return it to the browser.

Please see: https://docs.typo3.org/typo3cms/extensions/pdfviewhelpers/ConfigurationReference/TypoScriptReference/Index.html#document-outputdestination

I tested the different outputDestination values with the following example and everything seems to work as expected, the document is correctly saved to the filesystem.
https://docs.typo3.org/typo3cms/extensions/pdfviewhelpers/Examples/ExtendExistingPDFs/Index.html

Does this solve your issue? Or else, does it work with the example Extend Existing PDFs?

@maechler maechler self-assigned this Oct 17, 2018
@AureliusHogan
Copy link
Author

No that doesn't change anything. Thx. for the fast reply.

It's not that the file is not generated. The problem is that the content inside of the document is not generated. If I use "file-inline" the document shown is correct but the document saved is without content.

@maechler
Copy link
Member

maechler commented Oct 17, 2018

@AureliusHogan Currently I can not reproduce that issue. It seems strange to me, that the document that is returned inline, has different content than the file that is saved, because TCPDF actually reads the saved file to return it's content. See:

$f = TCPDF_STATIC::fopenLocal($name, 'wb');
if (!$f) {
$this->Error('Unable to create output file: '.$name);
}
fwrite($f, $this->getBuffer(), $this->bufferlen);
fclose($f);

and

TCPDF_STATIC::sendOutputData(file_get_contents($name), filesize($name));

Does this also happen with the example Extend Existing PDFs?
Does it work if you do not use the option sourceFile?
Did this work with v1.x? If yes, you could try to use an older version of TCPDF (v6.2.17, https://github.com/tecnickcom/TCPDF/releases)
Can you try to open the document that is saved to the filesystem with your browser?
Are there any errors in the error log?
Can you try to debug that place in TCPDF?
Can you provide your template and maybe corresponding controller action?

@AureliusHogan
Copy link
Author

Yes, it worked with 1.x!
No errors in log file.
And now the realy strange thing. This is what I see in the browser:
image

And this is the file which is saved:
test-doc.pdf

And this is the file I get, when I save the inline file:
test-inline.pdf

That's crazy!!

@maechler
Copy link
Member

maechler commented Oct 17, 2018

I can view both files:

screenshot 2018-10-17 at 19 22 28

Maybe there is an issue with your PDF viewer?
Can you try to view the document test-doc.pdf in the browser? (Probably you can just drag and drop the document to your browser)
Or try to view test-inline.pdf with the viewer you used for test-doc.pdf.

@AureliusHogan
Copy link
Author

Yes, I just now noticed, that Adobe Acrobat says the document has an error. So I tried to validate it as you mention in your documentation. The result is:
image

Now the question is, how to find the problem? The code I use is rather simple:

<pdf:document sourceFile="typo3conf/ext/pdfviewhelpers/Resources/Public/Examples/ExtendExistingPDFs/pdf_template.pdf" title="ESM PDF-Test" outputDestination="file-inline" outputPath="typo3temp/test.pdf">
	<pdf:page autoPageBreak="1" importPage="1" margin="{top: 58, right: 20, bottom: 40, left: 20}">
		<pdf:text>
			wir freuen uns, dass Sie sich für den folgenden Kurs angemeldet haben:
		</pdf:text>
		<pdf:text> </pdf:text>
		<pdf:headline><f:format.case mode="upper">Innerer Garten</f:format.case></pdf:headline>
		<pdf:text><f:format.raw>Hier kannst Du pflanzen was immer Du moechtest. Wichtig ist lediglich der Bezug zur Natur. Nutze die Demeter Gedanken.</f:format.raw></pdf:text>
		<pdf:text> </pdf:text>
	</pdf:page>
</pdf:document>

@maechler maechler added the bug label Oct 17, 2018
@maechler
Copy link
Member

There seems to be an issue with the renderHeader and renderFooter methods in BasePDF. You could try to provide your own class and overwrite these methods:

<?php
namespace Vendor\YourExtension\Model;

class MyPDF extends \Bithost\Pdfviewhelpers\Model\BasePDF
{
    public function renderHeader()
    {
    }

    public function renderFooter()
    {
    }
}
plugin.tx_pdfviewhelpers.settings {
    config {
       class = Vendor\YourExtension\Model\MyPDF
    }
}

As long as you do not need the header and footer ViewHelpers, this should work. I will investigate that issue. Thanks again for reporting!

@AureliusHogan
Copy link
Author

Perfect!!
That does the job for my purposes.

Thanx for the prompt support!!

@maechler
Copy link
Member

Actually it is even enough to just overwrite the footer method renderFooter .

@maechler
Copy link
Member

@AureliusHogan I just released a new version v2.0.1 that should fix that issue. It would be nice if you could update the extension, remove the fix from yesterday and test whether this works for you.

If you like the project, please consider giving it a star :)

@AureliusHogan
Copy link
Author

Yes, now everything is fine. And it seems like it is a little faster even.
Good job!
Perfekt support!

@maechler
Copy link
Member

Perfect, thanks for reporting and testing!

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

No branches or pull requests

2 participants