Overlapping Rounded Rectangles causes error in FPDF - fpdf

I am creating a PDF using the script 35 version of the Rounded rectangle function (Author: Christophe Prugnaud) and it works fine.
However, I require a filled rounded rectangle to be drawn inside an outline rounded rectangle and this causes an error e.g.
$this->pdf->RoundedRect($this->myleftmargin, $this->currenty, $this->mywidth, $totalheight, 8, '1234', 'D');
$this->pdf->RoundedRect($this->myleftmargin+2, $this->currenty+2, $this->mywidth-4, $totalheight-4, 8, '1234', 'DF');
In investigating the problem I find that if the top and left edges move in, but the right and bottom do not, there is no problem.
$this->pdf->RoundedRect($this->myleftmargin, $this->currenty, $this->mywidth, $totalheight, 8, '1234', 'D');
$this->pdf->RoundedRect($this->myleftmargin+2, $this->currenty+2, $this->mywidth-2, $totalheight-2, 8, '1234', 'DF');
Is this solvable?
=====
Addendum: This may not be the problem I thought it was, but it is still a problem. Running the code via Insomnia appears to return a PDF without problems - for either of the two sets of code above. BUT using the same URL via an Axios call (in Vue) causes an error in the first case but not in the second.
=====
Oliver (below), fairly, asked what the error is. Unfortunately I am not getting back anything useful for this. From the php error log I know that the problem is with the call ... $this->pdf->Output('a.pdf','I'); ... which create the error that a header has already been sent - but there is no other error before this in the log to know where that header is coming from. Logically the header must come from a error but (as you can see from the code) the difference in the working and failing code is just the value of a number.

Whilst I don't know why the code that worked, worked ... I now have a generic solution. The problem was that the Yii2 code that the PDF code was part of was trying to return a header from the controller. So rather than...
$this->pdf->Output('I');
which returned a PDF to Insomnia, used...
return Yii::$app->response->sendContentAsFile($this->pdf->Output('S'), 'a.pdf');
which returned the data in a form that the axios call could then use to download.

Related

Error handling in Sublime Text Plugin API

I'm creating my first sublime plugin to be used internally and was wondering if there's a way to stop the plugin from executing and display an error message on screen like an alert?
I took a look at view#show_popup() but this didn't render for me. Below is how I attempted to show it:
if "WebContent" in subdirectories:
directory = ROOT_DIR + "/WebContent"
elif "Content" in subdirectories:
directory = ROOT_DIR + "/Content"
else:
self.view.show_popup('Directory not found', location=-1)
Working Principle:
The plugin takes some data from one view and then pastes them in another view. The plugin has two TextCommands. One command takes the data from the first view, opens a new view and then executes the 2nd command on the new view. The above snippet is in the 2nd command.
I was unable to find any resources to help with show_popup() or any other error handling.
Does any one have possible ideas?
view.show_popup() is for showing things like hover popups next to the cursor; it's used for things like the built in functionality for going to references/definitions for functions:
While you could in theory use this for error messages, it may not be the sort of user experience that anyone would expect.
Your code above is technically valid, but since the content is expected to be minihtml it may be hard to see because as just a single string all you're going to see is just the text (i.e. you have no font style, padding, etc):
Perhaps more importantly, when location is -1, the popup appears at the point in the buffer closest to the first cursor position, so depending on your circumstance it may be appearing in a place you don't expect, and then vanishing away before you can scroll to see it, etc.
What you want here is sublime.error_message(); given a string, it will display that string in a dialog for the user to interact with, and it also logs the error into the Sublime console as well so that there's an additional trace.

TTeeGrid is not displaying the data at runtime using data from REST

I created a simple RME for TTeeGrid, a descendant perhaps of TGrid in Firemonkey. As shown below, the data are displayed at design time but not at runtime except the headers.
I've been breaking my head over this for weeks already but not luck.
Let me know if you need more details but what you see in the image are all you get.
I just need help to have the data displayed at runtime as shown in the design time.
UPDATE 1
This issue is not the case with TPrototypeBindSource. The data shown in the design time are displayed at runtime. Something is wrong somewhere.
I've never used the TeeGrid before, but the following worked fine
first time for me in Delphi Tokyo:
Download the TeeGrid trial from Steema.Com & install.
Create new multi-device app and place a TeeGrid and a FDMemTable on the form.
Load FDMemTable1 with the file Parts.Fds from the Delphi samples Data directory. Note, I did not then create any FieldDefs as I mentioned in my comment earlier as what I'm describing works without them.
Set the DataSource property of TeeGrid1 to FDMemTable1. TeeGrid1 immediately
creates columns for each of the Parts fields and populates them with data - see
screenshot below. I don't ordinarily include screenshots but in this case thought
I would as what I got was so clearly at odds with what you've reported.
Your TeeGrid etc are obviously more complicated than mine. so the best I can
suggest is that you backtrack to step 2 and see if you can replicate my result
with your data (either at design time or run time). It might be worth loading
your FDMemTable with some data at design time, as my impression is that live bindings
is less grief-prone when the datasource has some data.
Incidentally, fwiw the results of my own attempts to set up live bindings even with a regular TGrid have been rather patchy, until I discovered that instead of messing with the LB components myself, simply starting with a fresh TGrid, right-clicking on it and leaving the Live Bindings Wizard
to do its stuff consistently works fine.

phpThumb is not setting parameter – fltr[] usm

I am using Brett's Mr. PHP thumb caching script along with phpThumb to create my thumbs. It works extremely well, except for one thing... I cannot get it to set and process the UnSharpMask filter. The relevant part of the script looks like this:
// generate the thumbnail
require('../phpthumb/phpthumb.class.php');
$phpThumb = new phpThumb();
$phpThumb->setSourceFilename($image);
$phpThumb->setParameter('w',$width);
$phpThumb->setParameter('h',$height);
$phpThumb->setParameter('q','95'); // set the quality to 95%
$phpThumb->setParameter('fltr[]','usm|80|0.5|3'); // <--- THIS SHOULD SET THE USM FILTER
$phpThumb->setParameter('f',substr($thumb,-3,3)); // set the output file format
if (!$phpThumb->GenerateThumbnail()) {
error('cannot generate thumbnail');
}
I'm guessing there's a problem with my syntax, since the fltr[] parameter requires brackets. I have tried escaping the brackets like so: 'fltr[]' but that didn't work either.
I've used several other possible parameters with good success (zoom cropping, max height, max width, etc...) Everything seems to work except the filters (including usm - UnSharpMask).
I don't get any errors. It spits out thumbs all day long. They're just not sharpened.
For reference, here's the official phpThumb readme file that discusses all the possible settings and filters.
Thanks for looking.
Well after much trial, error, and aggravation, I finally discovered the solution buried in one of the demo files that come with phpThumb.
It's a matter of removing the brackets all together. Basically changing this line:
$phpThumb->setParameter('fltr[]','usm|80|0.5|3');
to this:
$phpThumb->setParameter('fltr','usm|80|0.5|3');
After that, it's only a matter of tweaking the settings to get the desired amount of sharpness.

Pydev Nodebox: "AttributeError: 'NoneType' object has no attribute 'WIDTH'"

I am trying to create a graph of the connections between the users in my database using nodebox(ubuntu 12.04, python 2.7, django 1.3), but when I enter the following instructions, I get the error message underneath it:
"""
g.draw(weighted=False, directed=False, highlight=[], traffic=None)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2721, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-1-0a219395b690>", line 1, in <module>
g.draw(weighted=False, directed=False, highlight=[], traffic=None)
File "/home/raymond/Documents/exchange/cet/cet/graph/__init__.py", line 453, in draw
self.update()
File "/path/to/myproject//graph/__init__.py", line 416, in update
self.x = _ctx.WIDTH - max.x*self.d - min_.x*self.d
AttributeError: 'NoneType' object has no attribute 'WIDTH'
"""
How can I get nodebox to draw my graph? should I add a try/catch or if statement to graph/init.py in order to prevent object of type none from being written to? I know displaying more code would help solve the problem faster; I am running into formatting problem, but I will add code to the question as soon as I can.
Nodebox has a graph web page which is concise, informative and seemed what I need. As the file to download is on the same page it seemed ideal, BUT it fails to mention it is Nodebox 1 which is for Mac ...only!
Then a further rummage finds NodeBox OpenGL which has a new methodology and is cross platform, BUT it only lists compatibility with python 2.5-2.6 (so with 2.7 should be worth a try?) BUT installing the graphics util Pyglet failed the first time ....so more investigation required.
Sadly Nodebox 3 seems all different and haven't yet seen a comparable graph command
Looking back on the outcome
After achieving an install, I prototyped network viewer with a mouse selectable attribute viewer, low frame rate and a constant data set. A flavour of the interactiveness is demonstrated in this site
http://www.visualthesaurus.com/app/view?word=link
(try a click and drag on the central word)
But problems I needed to solve were how to
show a live data set consistently ie dealing with orphans,
transitions as branches you may be viewing may disappear from the
data
partitioning the viewing of large amounts of data ie view 2 to 20 nodes from several hundred items
displaying data without overlapping/obscuring or going off the display area
displaying differences when not on the current level
portability
...
In my case a periodically updated, structured html table with colours and zoom levels was the best solution

Expected response code 200, got 400. Unable to convert document

In the last 2 weeks or so, I've suddenly started getting reports of users getting an error in our application saying "Expected response code 200, got 400. Unable to convert document." This is code that has been in place for years without any issue. We are using Zend Framework (GData) in conjunction with Google Docs (AuthSub).
We are logging the issue to a text file when it happens. When it gets logged, the user often tries multiple times (sometimes separated by a few seconds, other times separated by longer times) and it continues to fail. The code in question just creates a new Google document in the user's account and gives it a title (no body content).
Originally, I used this code:
// Create new document
$data = new Zend_Gdata_Docs_DocumentListEntry();
$data->setCategory(
array(new Zend_Gdata_App_Extension_Category(
"http://schemas.google.com/docs/2007#document",
"http://schemas.google.com/g/2005#kind"
)));
$data->setTitle(new Zend_Gdata_App_Extension_Title($title, null));
// Add document to your list
$test = $sharedocs->insertDocument($data, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
To experiment and see if there was an issue with that particular function, I tried creating a blank word doc and changing the code to:
$test = $sharedocs->uploadFile('/mypath/empty.doc', $title, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
However, I'm still seeing the "Unable to convert document" errors. They are relatively infrequent, and I am not able to reproduce the issue on my own computers here. The $title variable does not contain anything unusual (special characters, etc.).
This code was all working fine before -- is there a known issue with the Google Docs API right now? What else can I try?
NOTE: Please see my follow-up comments below, where I have identified the reproducible scenario in which this error occurs.
I had exactly the same problem, but I noticed that I could use the api to save a presentation if not a document... so, it is a terrible hack, but I try to save the document (works if the account has already been accessed)... if that fails, I save and delete a presentation and retry to save the document, which then works. Horrible, horrible, horrible hack