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

Error "Imported page does not exist" #99

Closed
liayn opened this issue Nov 30, 2018 · 4 comments
Closed

Error "Imported page does not exist" #99

liayn opened this issue Nov 30, 2018 · 4 comments
Assignees
Labels

Comments

@liayn
Copy link
Contributor

liayn commented Nov 30, 2018

This error occurs using latest version from TER 2.0.1 when using sourceFile and importPage and when a PDF is created containing multiple pages. This issue is probably related to #41.

One problem is that there is broken code in
https://github.com/bithost-gmbh/pdfviewhelpers/blob/master/Classes/Model/BasePDF.php#L199

$this->tpl is never defined. A strict comparison against 0 is always true. This leads to calling $this->useTemplate(NULL);, subsequently causing the mentioned error.

@macjohnny
Copy link
Member

@liayn thanks for reporting!
@maechler could you have a look?

@maechler
Copy link
Member

@liayn Thanks for reporting! Maybe $this->tpl has been renamed to $this->templateId in FPDI v2. But it could also be that more things changed, I will test this as soon as possible.

@maechler maechler self-assigned this Nov 30, 2018
@maechler maechler added the bug label Nov 30, 2018
liayn added a commit to liayn/pdfviewhelpers that referenced this issue Nov 30, 2018
Ceveat: A template with multiple pages will only use the first page of it

Fixes bithost-gmbh#99
@liayn
Copy link
Contributor Author

liayn commented Nov 30, 2018

I pushed a very dirty workaround, which fulfills at least our current needs

liayn added a commit to liayn/pdfviewhelpers that referenced this issue Nov 30, 2018
Ceveat: A template with multiple pages will only use the first page of it

Fixes bithost-gmbh#99
@maechler
Copy link
Member

maechler commented Dec 1, 2018

I actually think that it is a good fix for that issue. I had a closer look at FPDI, there is no way to determine the most recently used template anymore, thus we have to keep that information in our own class.

However I changed the implementation to not rely on an additional method, because I think this is less error-prone. I also added functional tests covering that issue.

public function useTemplate($template, $x = 0, $y = 0, $width = null, $height = null, $adjustPageSize = false)
{
$this->currentTemplate = $template;
parent::useTemplate($template, $x, $y, $width, $height, $adjustPageSize);
}

Thanks again for your contribution! If you like the project, please consider giving it a star :)
I just created a new release v2.0.2 that includes your fix.

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

3 participants