The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mxpress::PDF::Mechanize - Take a screenshot and add it to the pdf

VERSION

Version 0.04

SYNOPSIS

This is a quick example of how to expand Mxpress::PDF...

use Mxpress::PDF;
use Mxpress::PDF::Mechanize;
use WWW::Mechanize::Chrome;
use Log::Log4perl qw(:easy);

my $file = Mxpress::PDF->new_file($file_name, 
	plugins => [qw/screenshot/]
);

my $url = 'https://www.gohawaii.com/trip-planning';
$file->screenshot->take($url, %screenshot_args);

$file->save;

Description

This extends Mxpress::PDF currently with a single plugin 'screenshot'. tbc

Factory

screenshot

Returns a new Mxpress::PDF::Plugin::Mechanize::Screenshot Object. This object is for assisting with mechanizing browser screenshots..

my $page = Mxpress::PDF->page(%page_args);

Screenshot

Mxpress::PDF::Plugin::Mechanize::Screenshot extends Mxpress::PDF::Plugin::Image and is for taking screenshots and adding them to a Mxpress::PDF::Page.

You can pass default attributes when instantiating the file object.

Mxpress::PDF->add_file($filename,
	screenshot => { %screenshot_attrs },
);

or when calling the objects add method.

$file->screenshot->take(
	%screenshot_attrs
);

my $screenshot = $file->screenshot;

Attributes

The following attributes can be configured for a Mxpress::PDF::Plugin::Screenshot object, they are all optional.

$screenshot->$attrs();

mech_class (type => Str);

Mechanize class - WWW::Mechanize::Chrome

$screenshot->mech_class

mech_open_args (type => HashRef)

Args that are passed to $mech_class->new;

$screenshot->mech_open_args

mech

The Instantiated mech_class

$screenshot->mech->$methods

selector (type => Str);

Select the node wrapper.

$screenshot->selector('#my-id');

js (type => Str);

Execute some JS.

$screenshot->js($js_string);

sleep (type => Str);

Sleep while the JS does it's thing.

$screenshot->sleep;

screenshot_scale (type => Num);

Scaling the screenshot

$screenshot->screenshot_scale;	

screenshot_left_offset (type => Num);

Set a left offset before taking the screenshot.

$screenshot->screenshot_left_offset

screenshot_top_offset (type => Num);

Set a top offset before taking the screenshot.

$screenshot->screenshot->top_offset;

width (type => Num);

The width of the image added to the pdf.

$screenshot->width($pt);

height (type => Num);

The height of the image added to the pdf.

$screenshot->height($pt);

align (type => Str);

Align the image - fill|left|center|right

$screenshot->align('right');

AUTHOR

LNATION, <thisusedtobeanemail at gmail.com>

BUGS

Please report any bugs or feature requests to bug-mxpress-pdf-mechanize at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mxpress-PDF-Mechanize. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Mxpress::PDF::Mechanize

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)