Hello!
I would like to create custom PDF document - kind of small sticker label size 5x3cm.
In my custom module (I run it in GenericAgent when process changes its Activity):
[...]
my $nalepka = $Kernel::OM->Get('Kernel::System::PDF');
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
my $result = $nalepka->DocumentNew(
Title => 'Nalepka',
Encode => $LayoutObject->{UserCharset},
);
$result = $nalepka->PageBlankNew(
Width => 141,
Height => 85,
PageOrientation => 'landscape',
ShowPageNumber => 0,
);
my %textResult = $nalepka->Text(
Text => 'Własność Komputronik S.A.',
Font => 'ProportionalBold', # (optional) default Proportional (see DocumentNew())
FontSize => 6, # (optional) default 10
Width => 139,
Height => 83,
Type => 'Cut',
Align => 'center', # (optional) default left (left|center|right
);
[...]
Unfortunately the result pdf file ignores my page height, and sets DIN ISO A4 page height, which is 297mm (ca 842pt). Size width is accepted! Using trial-and-error method I have determined the smallest acceptable height value, which is 100. (ca 35mm, 5mm too high )
What am I doing wrong, or maybe PDF object cannot generate such small pages?
Daniel Lisiecki
[SOLVED] custom PDF document
-
- Znuny newbie
- Posts: 55
- Joined: 13 Apr 2017, 11:27
- Znuny Version: 6.5.4
- Real Name: Daniel
- Company: Komputronik S.A.
[SOLVED] custom PDF document
Last edited by lis9 on 14 Apr 2023, 12:00, edited 1 time in total.
-
- Znuny newbie
- Posts: 55
- Joined: 13 Apr 2017, 11:27
- Znuny Version: 6.5.4
- Real Name: Daniel
- Company: Komputronik S.A.
Re: custom PDF document
I have found that problem is in Kernel::System::PDF file. In function _CurPageDimSet
[...]
[...]
Don't know why 100 - I think that 72 (which is 1 inch in pt) would be better, but...
Anyway, I placed PDF.pm in my Custom/Kernel/System directory and changed this values to 72. Now my code works as expected.
Daniel Lisiecki
[...]
Code: Select all
# set CurPageWidth
if ( defined( $Param{Width} ) && $Param{Width} >= 100 && $Param{Width} <= 10000 ) {
$Self->{Current}->{PageWidth} = int( $Param{Width} );
$NewValue = 1;
}
# set CurPageHeight
if ( defined( $Param{Height} ) && $Param{Height} >= 100 && $Param{Height} <= 10000 ) {
$Self->{Current}->{PageHeight} = int( $Param{Height} );
$NewValue = 1;
}
Don't know why 100 - I think that 72 (which is 1 inch in pt) would be better, but...
Anyway, I placed PDF.pm in my Custom/Kernel/System directory and changed this values to 72. Now my code works as expected.
Daniel Lisiecki