Mailing List Archive

Opening existing PDF with Catalyst::View::PDF::API2
Hi,

I am trying to use Catalyst::View::PDF::API2 to open an existing PDF, modify it and then send it to the user. Looking at the documentation, it says that you can reuse existing PDF's but it doesn't show how to do it. I have tried this in the template

[% page = pdf.open('my.pdf') %]

But this gives the error:

undef error - Attempt to bless into a reference at /opt/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/PDF/API2.pm line 188.

Has anyone managed to get this to work? Or does anyone know what this error means?

Thanks for any help

Adam

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Opening existing PDF with Catalyst::View::PDF::API2 [ In reply to ]
I haven't used it, but looking at the last paragraph of the docs for
``process`` https://metacpan.org/pod/Catalyst::View::PDF::API2#process I
notice they say to use $c->stash->{pdf_filename} = 'myfile.pdf'; to set
the PDF filename. They also mention what filename is assumed by default.

->open is a class method of PDF::API2, and I think you only get object
methods with the object provided by Catalyst::View::PDF::API2

The error itself happens when you use a reference as a class. Run this
to get the full message from diagnostics: perl -Mdiagnostics -e 'bless
{}, {};'

Hope this helps!

Cheers,
ZZ



On Sun, 2014-10-12 at 11:56 +0000, Adam Witney wrote:
> Hi,
>
> I am trying to use Catalyst::View::PDF::API2 to open an existing PDF, modify it and then send it to the user. Looking at the documentation, it says that you can reuse existing PDF's but it doesn't show how to do it. I have tried this in the template
>
> [% page = pdf.open('my.pdf') %]
>
> But this gives the error:
>
> undef error - Attempt to bless into a reference at /opt/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/PDF/API2.pm line 188.
>
> Has anyone managed to get this to work? Or does anyone know what this error means?
>
> Thanks for any help
>
> Adam
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Opening existing PDF with Catalyst::View::PDF::API2 [ In reply to ]
Hi, thanks for your reply

> I haven't used it, but looking at the last paragraph of the docs for ``process`` https://metacpan.org/pod/Catalyst::View::PDF::API2#process I notice they say to use $c->stash->{pdf_filename} = 'myfile.pdf'; to set the PDF
> filename. They also mention what filename is assumed by default.

I think this "filename" defines the filename of the downloaded file rather than an input file

> ->open is a class method of PDF::API2, and I think you only get object methods with the object provided by Catalyst::View::PDF::API2

I think that this is the problem, I can in fact get it to work if I change PDF::API2.pm from

184 sub open_scalar {
185 my ($class, $content, %options) = @_;
186
187 my $self = {};
188 bless $self, $class;

To

184 sub open_scalar {
185 my ($class, $content, %options) = @_;
186
187 my $self = {};
188 if ( ref($class) ) {
189 $self = $class;
190 } else {
191 bless $self, $class;
192 }

This is obviously not an ideal fix but I don't understand how C::V::PDF::API2 interacts with PDF::API2, ie where does the TT pdf object come from?

Thanks again for your help

Adam


On Sun, 2014-10-12 at 11:56 +0000, Adam Witney wrote:
> Hi,
>
> I am trying to use Catalyst::View::PDF::API2 to open an existing PDF,
> modify it and then send it to the user. Looking at the documentation,
> it says that you can reuse existing PDF's but it doesn't show how to
> do it. I have tried this in the template
>
> [% page = pdf.open('my.pdf') %]
>
> But this gives the error:
>
> undef error - Attempt to bless into a reference at /opt/perlbrew/perls/perl-5.14.1/lib/site_perl/5.14.1/PDF/API2.pm line 188.
>
> Has anyone managed to get this to work? Or does anyone know what this error means?
>
> Thanks for any help
>
> Adam
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Opening existing PDF with Catalyst::View::PDF::API2 [ In reply to ]
On 12/10/2014 13:56, Adam Witney wrote:
> Hi,
>
> I am trying to use Catalyst::View::PDF::API2 to open an existing PDF, modify it and then send it to the user.

Why did not use Catalyst::View::PDF::Reuse instead?

> Thanks for any help

You are welcome. \ferz



_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Opening existing PDF with Catalyst::View::PDF::API2 [ In reply to ]
>> I am trying to use Catalyst::View::PDF::API2 to open an existing PDF, modify it and then send it to the user.

>Why did not use Catalyst::View::PDF::Reuse instead?

Only really because it was last updated in 2010, and C::V::PDF::API2 had a recent update. Is that easier to use?


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Opening existing PDF with Catalyst::View::PDF::API2 [ In reply to ]
On 12/10/2014 19:56, Adam Witney wrote:
>>> I am trying to use Catalyst::View::PDF::API2 to open an existing PDF, modify it and then send it to the user.
>
>> Why did not use Catalyst::View::PDF::Reuse instead?
>
> Only really because it was last updated in 2010, and C::V::PDF::API2 had a recent update. Is that easier to use?

I don't think that time of last update is a good index of quality of a
module.

Anyway Catalyst::View::PDF::API2 was my first view for Catalyst
and I've used Catalyst::View::PDF::Reuse as starting template.

Sorry, I've just updated few documentation, and part you wanted was left
there for my mistake.

PDF::Reuse has built in capability to modify existing PDF, while
my view was bornt to permit the PDF::API2 interface from Template
Toolkit.

Anywa, thank you, I can improve the C::V::PDF::API2 POD and I'll insert
a note: look at Catalyst::View::PDF::Reuse if you want to use an
existing PDF.

Best regards, \ferz




_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/