image in tcpdf doesn't fit enterely the pdf - tcpdf

I can't define a background image on all the width of the pdf.
pdf is Letter US, format 'L' in parameters the size of the pdf is 279.4x215.9
the image size is 3300x2550px
for the print 27.94mm 21.59mm
dpi 300
the image take 80% of the width and height. I would want 100% with no marge, no padding, no footer, no header...
tcpdf 6.3.2
php 7.2
$diplomas->SetAutoPageBreak(TRUE, 0);
$diplomas->setCellPaddings(0,0,0,0);
$diplomas->setCellMargins(0,0,0,0,false);
$diplomas->setPrintHeader(false);
$diplomas->SetFooterMargin(0);
$diplomas->SetRightMargin(0);
$diplomas->setPrintFooter(false);
$diplomas->Image($img_file, 0, 0, 279, 216, '', '', '', false, 300, '', false, false);
//$diplomas->writeHTMLCell(0, 0 , 0, 0, $fond, $border=0, $ln=1, $fill=0, $reseth=false, $align='', $autopadding=false);
$diplomas->writeHTMLCell(0, 0, $x_nom, $y_nom, $nom, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$diplomas->writeHTMLCell(0, 0, $x_ph, $y_ph, $ph, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$diplomas->writeHTMLCell(0, 0, $x_date, $y_date, $date_diploma, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
Do you have any idea, please?
Thanks
Chris

Related

Metadict in ffmpeg does not have rotate information

My aim is to extract frames out of a video but many times the frames are inverted. This is happening because "VideoCapture" in cv2 does read the rotate flag data present in the video metadata. I am running it on mac and installed "ffmpeg" package (5.0.1) using brew package manager. This is my code to check rotation present in a video using ffmpeg.
import ffmpeg
import cv2
import pprint
pp = pprint.PrettyPrinter(depth=4)
def check_rotation(path_video_file):
# this returns meta-data of the video file in form of a dictionary
meta_dict = ffmpeg.probe(path_video_file)
pp.pprint(meta_dict)
# from the dictionary, meta_dict['streams'][0]['tags']['rotate'] is the key
# we are looking for
rotateCode = None
if int(meta_dict['streams'][0]['tags']['rotate']) == 90:
rotateCode = cv2.ROTATE_90_CLOCKWISE
elif int(meta_dict['streams'][0]['tags']['rotate']) == 180:
rotateCode = cv2.ROTATE_180
elif int(meta_dict['streams'][0]['tags']['rotate']) == 270:
rotateCode = cv2.ROTATE_90_COUNTERCLOCKWISE
return rotateCode
Here the meta_dict is supposed to have information about the rotation but it is not there.
printing out meta_dict gives:
{'format': {'bit_rate': '18498544',
'duration': '3.584000',
'filename': 'video.mp4',
'format_long_name': 'QuickTime / MOV',
'format_name': 'mov,mp4,m4a,3gp,3g2,mj2',
'nb_programs': 0,
'nb_streams': 2,
'probe_score': 100,
'size': '8287348',
'start_time': '0.000000',
'tags': {'com.android.version': '11',
'compatible_brands': 'isommp42',
'creation_time': '2021-12-08T10:56:57.000000Z',
'major_brand': 'mp42',
'minor_version': '0'}},
'streams': [{'avg_frame_rate': '990000/34997',
'bit_rate': '18804651',
'bits_per_raw_sample': '8',
'chroma_location': 'left',
'closed_captions': 0,
'codec_long_name': 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
'codec_name': 'h264',
'codec_tag': '0x31637661',
'codec_tag_string': 'avc1',
'codec_type': 'video',
'coded_height': 1080,
'coded_width': 1920,
'color_primaries': 'bt470bg',
'color_range': 'pc',
'color_space': 'bt470bg',
'color_transfer': 'smpte170m',
'display_aspect_ratio': '16:9',
'disposition': {'attached_pic': 0,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0},
'duration': '3.499700',
'duration_ts': 314973,
'extradata_size': 35,
'field_order': 'progressive',
'film_grain': 0,
'has_b_frames': 0,
'height': 1080,
'id': '0x1',
'index': 0,
'is_avc': 'true',
'level': 40,
'nal_length_size': '4',
'nb_frames': '99',
'pix_fmt': 'yuvj420p',
'profile': 'High',
'r_frame_rate': '120/1',
'refs': 1,
'sample_aspect_ratio': '1:1',
'side_data_list': [{...}],
'start_pts': 3168,
'start_time': '0.035200',
'tags': {'creation_time': '2021-12-08T10:56:57.000000Z',
'handler_name': 'VideoHandle',
'language': 'eng',
'vendor_id': '[0][0][0][0]'},
'time_base': '1/90000',
'width': 1920},
{'avg_frame_rate': '0/0',
'bit_rate': '128986',
'bits_per_sample': 0,
'channel_layout': 'stereo',
'channels': 2,
'codec_long_name': 'AAC (Advanced Audio Coding)',
'codec_name': 'aac',
'codec_tag': '0x6134706d',
'codec_tag_string': 'mp4a',
'codec_type': 'audio',
'disposition': {'attached_pic': 0,
'captions': 0,
'clean_effects': 0,
'comment': 0,
'default': 1,
'dependent': 0,
'descriptions': 0,
'dub': 0,
'forced': 0,
'hearing_impaired': 0,
'karaoke': 0,
'lyrics': 0,
'metadata': 0,
'original': 0,
'still_image': 0,
'timed_thumbnails': 0,
'visual_impaired': 0},
'duration': '3.584000',
'duration_ts': 172032,
'extradata_size': 2,
'id': '0x2',
'index': 1,
'nb_frames': '168',
'profile': 'LC',
'r_frame_rate': '0/0',
'sample_fmt': 'fltp',
'sample_rate': '48000',
'start_pts': 0,
'start_time': '0.000000',
'tags': {'creation_time': '2021-12-08T10:56:57.000000Z',
'handler_name': 'SoundHandle',
'language': 'eng',
'vendor_id': '[0][0][0][0]'},
'time_base': '1/48000'}]}
Can someone please help me to find if rotation is present in a video?

TCPDF: Rotate Text in cell

I am trying to rotate text in the cell with TCPDF.
This is what I am expecting to have
With the following sample code:
$pdf->Cell(30, 40, 'Text 1', 1, 0);
$pdf->StartTransform();
$pdf->Rotate(90);
$pdf->Cell(30, 0, 'Value 1', 1, 0);
$pdf->StopTransform();
$pdf->Cell(30, 40, 'Value 2', 1, 0,'L',0,''); // skipped rotation for testing
$pdf->Cell(30, 40, 'Text 2', 1, 1);
I am able to get rotate the cell which gives an output of:
I would appriciate some pointers on what I could be missing, and how could I achieve only the text rotation with TCPDF.

GMOD 3D2D Sign with website

I'm trying to make a 3D2D Sign that has text on it and displays a website, so that i can walk around it and the website will stay in the same position. So far I have got this code but don't know how to import the website.
include("shared.lua")
function ENT:Initialize()
self:SetMaterial("models/shiny")
self:SetRenderMode(RENDERMODE_NORMAL)
self:SetColor(Color( 0, 0, 0, 255 ))
end
function ENT:Draw()
self:DrawModel()
local ENTPos = self:GetPos()+Vector(0,0,26)
local ENTAng = self:GetAngles()
ENTAng:RotateAroundAxis(ENTAng:Forward(), 0)
ENTAng:RotateAroundAxis(ENTAng:Right(), 270)
ENTAng:RotateAroundAxis(ENTAng:Up(), 90)
local url = "https://www.google.com/"
local webPage = vgui.Create("F1HTML")
webPage:OpenURL(url)
cam.Start3D2D(ENTPos + ENTAng:Up() * 2, ENTAng, 0.5)
draw.RoundedBox( 2, -220, -62.5, 440, 227, Color(0, 0, 0, 255) );--Black Body
draw.RoundedBox( 2, -220, -62.5, 440, 30, Color(255, 0, 0, 255) );--Red Title
local FontNameTitle = "HUDNumber5"
draw.SimpleText( "Server", FontNameTitle, 0, -33, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
cam.End3D2D()
end
To display a website in 3D space like you are trying to do, I'd recommend using the 3D2D derma project by HandsomeMatt.
Derma can, as you may already know, be used to open a website in a panel.
Check the Derma Basic Guide on how to use derma.
It allows for you to draw derma panels in a 3D2D space, like you want!

gawk: change 5th element on every other line

I want to add a line break (\n) in front of the 5th element on every other line:
2, 0, 0, 0, 2
4, 0, 0, 0, 4
6, 0, 0, 0, 6
8, 0, 0, 0, 8
... in order to get:
2, 0, 0, 0, 2
4, 0, 0, 0, \n4
6, 0, 0, 0, 6
8, 0, 0, 0, \n8
What I have so far in gawk doesn't work:
gawk '{if (NR % 2) {$5=\n$5; print} else print}'
You could say:
awk '{NR%2 || $5="\\n"$5 }1' filename
Note that you'll need to escape the \ in order to get a literal \.
For your input, it'd produce:
2, 0, 0, 0, 2
4, 0, 0, 0, \n4
6, 0, 0, 0, 6
8, 0, 0, 0, \n8
Alternatively, (as pointed out by #WilliamPursell), you could say:
awk '!(NR%2) {$5="\\n"$5 }1' filename

In PDFKitten Special Character Searching not possible

I am using PDFKitten search functionality and found that in this the Special Characters are not able to search (e.g. let say in PDF ther is a word RAVI's and if I search the word it will return NULL value. Please suggest me how do I resolve this issue.
Thanks
In scanner.m there is a function didScanString
void didScanString(CGPDFStringRef pdfString, Scanner *scanner)
{
NSString *tempStr = (NSString *)CGPDFStringCopyTextString(pdfString);
NSLog(#"ScanString==%#",tempStr);
NSString *string = [[scanner stringDetector] appendPDFString:pdfString withFont:[scanner currentFont]];
NSLog(#"didScanString====>>>%#",string);
[ss appendString:string];
[[scanner content] appendString: string];
//NSLog(#"TOTAL: %#",[scanner content]);
}
For example the Search PDF String is MGR KL445's
In the above function two NSLog out put 1st one showing ScanString==MGR KL445™s
and 2nd one nothing will showing.
Your search text RAVI's contains a vertical apostrophe; have you checked whether the PDF does not contain a forward or backward slanted version of that character instead? Those different versions have different character codes after all.
In the context of question PDFKitten is highlighting on wrong position, it became appearant that that library returns ligatures as single ligatured characters instead of 'de-ligaturized' character groups. If your text contains ligatures, that might be the reason.
In the context of the same question, PDFKitten font data parsing turned out to be deficient in some respects. In reaction to that question, a workaround for one such deficiency has been added to the code which in my eyes didn't fix the general case, merely some special cases, cf. the proposal in my answer there.
Furthermore some fonts simply do not contain the information for mapping their glyphs back to unicode characters. You say the Special Characters are not able to search --- maybe those special characters are taken from a different font not supporting parsing.
Theoretically the apostrophe might even have been drawn using graphic, non-text operators. In that case text parsing won't find it.
If none of these ideas explain your case (or you cannot check whether they do), please supply the sample PDF for inspection.
EDIT (taking into account your Brivo MR355 copy.pdf sample file)
I assume that again the apostrophe is troublesome, this time in MR355’s. There are two accurances in the raw page content,
/TT1 1 Tf
0.559 0 Td
(Brivo MR355\222s Ready Bar technology replaces 30 complex inputs with a single control, simplifying scan optimization )Tj
and
/TT1 1 Tf
0.559 0 Td
(Brivo MR355\222s Ready Interface)Tj
Both time the font resource /TT1 is used, and both times the apostrophe is encoded as \222 which is octal for 146 decimal, quoteright in WinAnsiEncoding, trademark in PDFDocEncoding.
/TT1 is
/LastChar 146
/BaseFont /REEDOQ+GEInspira
/Type /Font
/Subtype /TrueType
/Encoding /WinAnsiEncoding
/Widths [232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 198, 0, 0, 0, 530, 0, 0, 530, 0, 530, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 570, 0, 0, 0, 0, 0, 0, 243, 0, 0, 0, 764, 0, 0, 0, 0, 556, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 545, 545, 482, 545, 509, 297, 545, 544, 210, 0, 0, 210, 836, 544, 537, 545, 545, 341, 437, 317, 544, 474, 736, 471, 474, 427, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 190]
/FontDescriptor 32 0 R
/FirstChar 32
/LastChar being 146 and /Encoding being /WinAnsiEncoding should make it easy for PDFKitten to recognize the \222 as quoteright character.
As one of your comments indicated that you are not using the most current PDFKitten version, I'll do the code analysis based on an older copy, too.
PDFKitten while parsing that font dictionary (setEncodingNamed in Font.m) recognizes the string "WinAnsiEncoding" and stores WinAnsiEncoding (3) from the enum CharacterEncoding (Font.h) in self.encoding; lateron, when converting the raw PDF data to unicode (stringWithPDFString in SimpleFont.m), it calls and returns
NSString *string = [[NSString alloc] initWithData:rawBytes encoding:self.encoding];
But the encoding constants in nsstring.h map
NSJapaneseEUCStringEncoding = 3,
Thus, PDFKitten here tries to decode the raw data as EUC-JP encoded which for byte values >127 should fail miserably while byte values <= 127 are interpreted as ASCII characters.
NSString initWithData returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding). Thus, PDFKitten drops the whole fragment while processing the PDF data.
At first glance the relevant code parts still are the same in the current code base. Thus, you might want to report an issue at the PDFKitten site concerning character codes > 127 for fonts with /Encoding /WinAnsiEncoding and most likely with `/Mac*Encoding' , too.

Resources