ErrorException in class.pdf.php line 3154 - laravel-5

I'm new in Laravel, I use laravel 5.2 and I'm trying to generate a report using DomPdf but I'm getting error:
ErrorException in class.pdf.php line 3154
Undefined index:
in class.pdf.php line 3154
at HandleExceptions->handleError('8', 'Undefined index: ', 'C:\xampp\htdocs\balai\vendor\dompdf\dompdf\lib\class.pdf.php', '3154', array('size' => '12')) in class.pdf.php line 3154
at Cpdf->getFontHeight('12') in cpdf_adapter.cls.php line 740
at CPDF_Adapter->get_font_height('C:/xampp/htdocs/balai/vendor/dompdf/dompdf/lib/fonts/Times-Roman', '12') in font_metrics.cls.php line 122
at Font_Metrics::get_font_height('C:/xampp/htdocs/balai/vendor/dompdf/dompdf/lib/fonts/Times-Roman', '12') in text_frame_reflower.cls.php line 167
at Text_Frame_Reflower->_layout_line() in text_frame_reflower.cls.php line 332
at Text_Frame_Reflower->reflow(object(Block_Frame_Decorator)) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow(object(Block_Frame_Decorator)) in block_frame_reflower.cls.php line 750
at Block_Frame_Reflower->reflow(null) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow() in page_frame_reflower.cls.php line 123
at Page_Frame_Reflower->reflow(null) in frame_decorator.cls.php line 711
at Frame_Decorator->reflow() in dompdf.cls.php line 973
at DOMPDF->render() in PDF.php line 208
at PDF->render() in PDF.php line 154
at PDF->output() in PDF.php line 166
at PDF->save('documents.pdf') in LlajRambuController.php line 247
at LlajRambuController->printRambu('52', '1')

I was having this same problem, and I found a solution that makes no sense to me.
The HTML I was passing to dompdf didn't have any line breaks, like:
<html><body>content here<body></html>
Adding a break after the body tag fixed the problem.
<html><body>
content here
</body></html>
No clue what's going on, but now it works. Hope this fixes your problem too.

Related

Missing ',' in line when Biopython reads a nexus tree

I want to edit a tree that I got from BEAST2 treeannotator in nexus-format.
Usually I use the module Phylo from Biopython for such work but Phylo.read(r"filename.tree", "nexus") gave me the next exception:
---------------------------------------------------------------------------
NexusError Traceback (most recent call last)
Input In [29], in <cell line: 1>()
----> 1 Phylo.read(r"filename.tree", "nexus")
File ~\miniconda3\lib\site-packages\Bio\Phylo\_io.py:60, in read(file, format, **kwargs)
58 try:
59 tree_gen = parse(file, format, **kwargs)
---> 60 tree = next(tree_gen)
61 except StopIteration:
62 raise ValueError("There are no trees in this file.") from None
File ~\miniconda3\lib\site-packages\Bio\Phylo\_io.py:49, in parse(file, format, **kwargs)
34 """Parse a file iteratively, and yield each of the trees it contains.
35
36 If a file only contains one tree, this still returns an iterable object that
(...)
46
47 """
48 with File.as_handle(file) as fp:
---> 49 yield from getattr(supported_formats[format], "parse")(fp, **kwargs)
File ~\miniconda3\lib\site-packages\Bio\Phylo\NexusIO.py:40, in parse(handle)
32 def parse(handle):
33 """Parse the trees in a Nexus file.
34
35 Uses the old Nexus.Trees parser to extract the trees, converts them back to
(...)
38 eventually change Nexus to use the new NewickIO parser directly.)
39 """
---> 40 nex = Nexus.Nexus(handle)
42 # NB: Once Nexus.Trees is modified to use Tree.Newick objects, do this:
43 # return iter(nex.trees)
44 # Until then, convert the Nexus.Trees.Tree object hierarchy:
45 def node2clade(nxtree, node):
File ~\miniconda3\lib\site-packages\Bio\Nexus\Nexus.py:668, in Nexus.__init__(self, input)
665 self.options["gapmode"] = "missing"
667 if input:
--> 668 self.read(input)
669 else:
670 self.read(DEFAULTNEXUS)
File ~\miniconda3\lib\site-packages\Bio\Nexus\Nexus.py:718, in Nexus.read(self, input)
716 break
717 if title in KNOWN_NEXUS_BLOCKS:
--> 718 self._parse_nexus_block(title, contents)
719 else:
720 self._unknown_nexus_block(title, contents)
File ~\miniconda3\lib\site-packages\Bio\Nexus\Nexus.py:759, in Nexus._parse_nexus_block(self, title, contents)
757 for line in block.commandlines:
758 try:
--> 759 getattr(self, "_" + line.command)(line.options)
760 except AttributeError:
761 raise NexusError("Unknown command: %s " % line.command) from None
File ~\miniconda3\lib\site-packages\Bio\Nexus\Nexus.py:1144, in Nexus._translate(self, options)
1142 break
1143 elif c != ",":
-> 1144 raise NexusError("Missing ',' in line %s." % options)
1145 except NexusError:
1146 raise
NexusError: Missing ',' in line 1 AB298157.1_2015_-7.9133750332192605_114.8086828279248, 2 AB298158.1_2007_-8.41698974207…
Using Nexus.read(Nexus(), input=r"filename.tree") gave the same result. Please could anyone help with this? I cannot understand the reason of this error because nexus file looks correct.
The reason is that Biopython cannot read nexus trees with links, constituent from translations & a newick tree. So it is required previously to convert this to the form with full names into the tree (as hereinbelow).
Begin
tree TREE1 = (((your,tree),(in,(the, newick))),format);
End;
P.S. It is allowed in the newick format to surround the label with quotes, & some programmes or scripts add them to those names that have ambiguous characters. But it can lead to exceptions during the following phylogenetic analysis, for instance, in BEAST. I wish you would be careful with this.

Win Error 5 has occurred when I tried to execute Pytorch code

I'm new to Anaconda. I tried to execute Pytorch Adversarial Neural Network in anaconda. It shows some error that I have no clue. Here is the code that downloads dataset
# MNIST Test dataset and dataloader declaration
test_loader = torch.utils.data.DataLoader(datasets.MNIST('../data', train=False, download=True, transform=transforms.Compose([
transforms.ToTensor(),])),batch_size=1, shuffle=True)
This is the error message I got :
PermissionError Traceback (most recent call last)
<ipython-input-4-59310f6a37f8> in <module>
41
42 # MNIST Test dataset and dataloader declaration
43 test_loader = torch.utils.data.DataLoader(datasets.MNIST('../data', train=False, download=True, transform=transforms.Compose([transforms.ToTensor(),])),batch_size=1, shuffle=True)
44
45 # Define what device we are using
~\anaconda3\lib\site-packages\torchvision\datasets\mnist.py in __init__(self, root,
train,
transform, target_transform, download)
77
78 if download:
79 self.download()
80
81 if not self._check_exists():
~\anaconda3\lib\site-packages\torchvision\datasets\mnist.py in download(self)
138 return
139
140 os.makedirs(self.raw_folder, exist_ok=True)
141 os.makedirs(self.processed_folder, exist_ok=True)
142
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
211 if head and tail and not path.exists(head):
212 try:
213 makedirs(head, exist_ok=exist_ok)
214 except FileExistsError:
215 # Defeats race condition when another thread created the path
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
211 if head and tail and not path.exists(head):
212 try:
213 makedirs(head, exist_ok=exist_ok)
214 except FileExistsError:
215 # Defeats race condition when another thread created the path
~\anaconda3\lib\os.py in makedirs(name, mode, exist_ok)
221 return
222 try:
223 mkdir(name, mode)
224 except OSError:
225 # Cannot rely on checking for EEXIST, since the operating system
PermissionError: [WinError 5] Access is denied: '../data' .
How about changing the '../data' to another directory, like '/Users/***/Downloads/data' or somewhere else.

Apk unzipping. Not a valid zip file, but unzip worked perfect

I have problem with golang zip reader. We have apk builder which build apk and then encrypted this apk with dex protector.
When i try to open apk file, go return err "zip: not a valid zip file". But when i try to open with unzip or zipinfo, worked fine.
(Also I noticed something interesting: in php 5.5 apk file opened with ZipArchive fine, but in 5.6 return error like golang)
I try open to debug golang archive/zip pckage and found that error returned in this line https://github.com/golang/go/blob/master/src/archive/zip/reader.go#L269.
Then i try to debug this line like this:
fmt.Printf("%+v", f)
fmt.Println(
"len(f.Extra):", len(f.Extra),
"len(b):", len(b),
"tag:", tag,
"size:", size,
)
And have this results:
&{FileHeader:{
Name:META-INF/MANIFEST.MF CreatorVersion:20 ReaderVersion:20 Flags:2056 Method:8
ModifiedTime:23093 ModifiedDate:18230 CRC32:2569174240
CompressedSize:359 UncompressedSize:570 CompressedSize64:359 UncompressedSize64:570
Extra:[] ExternalAttrs:0 Comment:
} zipr:0xc208038038 zipsize:276893 headerOffset:0}
&{FileHeader:{
Name:res/drawable/ic_launcher.png CreatorVersion:10 ReaderVersion:10 Flags:2048 Method:0
ModifiedTime:22030 ModifiedDate:18230 CRC32:2310989215
CompressedSize:20418 UncompressedSize:20418 CompressedSize64:20418 UncompressedSize64:20418
Extra:[] ExternalAttrs:0 Comment:
} zipr:0xc208038038 zipsize:276893 headerOffset:2066}
...
---------------->PROBLEM HERE:-------------------=>
&{FileHeader:{
Name:AndroidManifest.xml CreatorVersion:10 ReaderVersion:10 Flags:2048 Method:0
ModifiedTime:22030 ModifiedDate:18230 CRC32:1929033187
CompressedSize:7268 UncompressedSize:7268 CompressedSize64:7268 UncompressedSize64:7268
Extra:[204 94 136 27 148 14 49 95 154 4 231 53 127 242 4 199 243 207 229 161 103 90 116 69 45 31 54 220 113 43 172 4 159 109 211 57 217 2 161 17 196 16 168 19 174 138 107 15 36 181 223 22 15 21 106 153]
ExternalAttrs:0 Comment:
} zipr:0xc208038038 zipsize:276893 headerOffset:22954}
len(f.Extra): 56
len(b): 52
tag: 24268
size: 7048
Problem in extra headers (i think this extra headers add dex protector when encrypt apk). Size more then length of extra bytes.
But unzip util and ZipArchive in php5.5 woked perfect with this extras. How to fix this ?
I want to rewrite this piece in go archive/zip package, so that the extras do not interfere golang zip reader.
It's very important for me, because i rewrite build apk from php to golang and I came across a problem that can not decide :(. Please help me.

Notice: Undefined offset: 0 in smarty

I got the following notices and would like to clarify:
Notice: Undefined offset: 0 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434
Notice: Undefined offset: 1 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434
Notice: Undefined offset: 2 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434
Notice: Undefined offset: 9 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434
Code lines in the compiled tpl are:
<?php if ($_smarty_tpl->tpl_vars['TablesLinked']->value[$_smarty_tpl->getVariable('smarty')->value['section']['i']['index']]){?>
This is the uncompiled line:
{if $TablesLinked[i]}
One line above starts the section:
{section name=i loop=$NumberFields}
Do I have to change the start index because offset means wrong index ?
TablesLinked does not appear in every field, because fields consist of linkedtables and normal fields, thats why I use an if-clause.
I hope you can help.
Although it is a very good practice set error_reporting to E_ALL during development phase and trying to eliminate all notices, personally I wouldn't worry about these messages. It just won't find the elements on the specified indices during the loop. In any case, if you insist on eliminating the notices, you can change
{if $TablesLinked[i]}
to
{if isset($TablesLinked[i]) && $TablesLinked[i]}

Why is RLIMIT_NOFILE rlim_max of -1 on BSD?

In the following code:
139 struct rlimit limit;
140
141 method = "rlimit";
142 if (getrlimit(RLIMIT_NOFILE, &limit) < 0) {
143 perror("calling getrlimit");
144 exit(1);
145 }
146
147 /* set the current to the maximum or specified value */
148 if (max_desired_fds)
149 limit.rlim_cur = max_desired_fds;
150 else {
151 limit.rlim_cur = limit.rlim_max;
152 }
153
154 if (setrlimit(RLIMIT_NOFILE, &limit) < 0) {
155 perror("calling setrlimit");
156 exit(1);
157 }
the setrlimit line fails (I get the error "calling setrlimit"). Further investigation shows that limit.rlim_max is -1, which is not a valid value. Any ideas why would this be? This is on Mac OSX.
If setrlimit fails, try again with rlim_cur set to OPEN_MAX. For example, see http://source.winehq.org/source/libs/wine/loader.c#L653. (The comment mentioning Leopard means that Leopard first introduced that behavior. Read it as Leopard-and-later.)
ETA: See the note in COMPATIBILITY in the setrlimit(2) man page.

Resources