PDFResult from path gives error


When using the PDFResult() from a path I get this error message when running the viktor-cli start.

Hope you can help me out. Thanks!

Traceback (most recent call last):
  File "viktor_connector\connector.pyx", line 761, in connector.ManifestHandler.run
  File "C:\Users\bart\viktor-apps\spreadsheet-test\app\__init__.py", line 2, in <module>
    from .calculation.controller import CalculationController
  File "C:\Users\bart\viktor-apps\spreadsheet-test\app\calculation\controller.py", line 20, in <module>
    class CalculationController(ViktorController):
  File "C:\Users\bart\viktor-apps\spreadsheet-test\app\calculation\controller.py", line 70, in CalculationController
    @PDFResult(file=None, url=None)
  File "viktor\views.pyx", line 1645, in viktor.views.PDFResult.__init__
  File "viktor\views.pyx", line 1080, in viktor.views._PDFSubResult.__init__
ValueError: Either provide file or url named argument

2022-07-25 21:57:54.077 ERROR   : Either provide file or url named argument

This is my code:

    @PDFResult(file=None, url=None)
    def get_pdf_view(self, params, **kwargs):
        file_path = Path(__file__).parent / 'sample.pdf'
        return PDFResult.from_path(file_path)

Hi BartG,

I noticed that you accidentally decorated your View with the PDFResult() instead of the PDFView(). I believe that this is causing the problem. Could you try it using the PDFView() (see the docs)

As a rule of thumb, for every visualization/view that we provide, we require roughly the following structure:

    @xxxxView("View Label Here", duration_guess=<int>)
    def get_view(self, params, **kwargs):
        return xxxxResult(...)

I hope this solves your problem!

Hi Bart,

Did the proposed solution solve your problem?

Yes! Thanks for your help!