Its not possible to put a artbox and trimbox on a page with iText7.0.5.0
The source states then only a trimbox or a ArtBox can exist on a page.
This is not true, they can exist both on a page.
Line 615 of PdfPage.java
/**
* Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.
*
* #param rectangle the {#link Rectangle} object to set, expressed in default user space units.
* #return this {#link PdfPage} instance.
*/
public PdfPage setTrimBox(Rectangle rectangle) {
if (getPdfObject().getAsRectangle(PdfName.ArtBox) != null) {
getPdfObject().remove(PdfName.ArtBox);
Logger logger = LoggerFactory.getLogger(PdfPage.class);
logger.warn(LogMessageConstant.ONLY_ONE_OF_ARTBOX_OR_TRIMBOX_CAN_EXIST_IN_THE_PAGE);
}
put(PdfName.TrimBox, new PdfArray(rectangle));
return this;
}
/**
* Sets the ArtBox object, that define the extent of the page’s meaningful content
* (including potential white space) as intended by the page’s creator.
*
* #param rectangle the {#link Rectangle} object to set, expressed in default user space units.
* #return this {#link PdfPage} instance.
*/
public PdfPage setArtBox(Rectangle rectangle) {
if (getPdfObject().getAsRectangle(PdfName.TrimBox) != null) {
getPdfObject().remove(PdfName.TrimBox);
Logger logger = LoggerFactory.getLogger(PdfPage.class);
logger.warn(LogMessageConstant.ONLY_ONE_OF_ARTBOX_OR_TRIMBOX_CAN_EXIST_IN_THE_PAGE);
}
put(PdfName.ArtBox, new PdfArray(rectangle));
return this;
}
Proposed solutions:
/**
* Gets the {#link Rectangle} object specified by page's ArtBox, that define the extent of the page’s
* meaningful content (including potential white space) as intended by the page’s creator.
*
* #return the {#link Rectangle} object specified by page's ArtBox, expressed in default user space units.
* CropBox by default.
*/
public Rectangle getArtBox() {
Rectangle artBox = getPdfObject().getAsRectangle(PdfName.ArtBox);
return artBox == null ? getCropBox() : artBox;
}
/**
* Sets the TrimBox object, that define the intended dimensions of the finished page after trimming.
*
* #param rectangle the {#link Rectangle} object to set, expressed in default user space units.
* #return this {#link PdfPage} instance.
*/
public PdfPage setTrimBox(Rectangle rectangle) {
put(PdfName.TrimBox, new PdfArray(rectangle));
return this;
}
Related
My app has a very standard user comment feature with also standard possibility for any visitor to mark comments as inappropriate.
In the resolution process for these marked comments the admin will decide which action to take, between no action, edit the comment or remove it.
The CommentReport entity includes Assert\Choice to allow only the 3 choices above.
The issue is that it is accepting any string.
On the Comment entity the set up is as follows:
....
* graphql={
* "withCustomArgsMutation"={
* "security"="is_granted('ROLE_ADMIN')",
* "mutation"=CommentReputationTypeResolver::class,
* "args"={
* "id"={"type"="ID!"},
* "resolutionType"={"type"="String!"},
* },
* "denormalization_context"={"groups"={"put-resolution"}},
* "normalization_context"={"groups"={"get"}}
* },
.....
/**
* #ORM\OneToMany(targetEntity=CommentReport::class, mappedBy="comment")
* #Groups({"get", "get-admin", "get-owner", "put-resolution"})
*/
private $commentReports;
Then the CommentReports entity:
class CommentReport
{
const RESOLUTION_TYPES = [
'no_action',
'edit',
'remove',
];
.....
/**
* #ORM\Column(type="string", length=10, nullable=true)
* #Assert\NotBlank(
* message="commentReport.resolutionType.notBlank",
* groups={"put-resolution"}
* )
* #Assert\Choice(
* choices=CommentReport::RESOLUTION_TYPES,
* message="commentReport.resolutionType.choice",
* groups={"put-resolution"}
* )
* #Groups({"get-admin", "put-resolution"})
*/
private $resolutionType;
Then on the DeserializeStage the request is intercepted to handle the setting of each individual CommentReport made for that Comment:
/Stage/DeserializeStage.php
if ($this->isAdmin($user) && $resourceClass === 'App\Entity\Comment' && $operationName === 'withCustomArgsMutation') {
// get all comment reports
$commentReports = $deserializeObject->getCommentReports();
foreach($commentReports as $report) {
$report->setResolutionType($context['args']['input']['resolutionType']);
}
}
All of this works but I can input any string and it will be accepted.
Of course, the expected result would be that Symfony would throw an exception for any string not on the RESOLUTION_TYPES array.
For info, this is the front-end mutation that triggers input:
`mutation putCommentReport(
$commentId: ID!
$resolutionType: String!
) {
withCustomArgsMutationComment(input: {
id: $commentId
resolutionType: $resolutionType
}){
comment{
id
}
}
}`;
As #Jeroen van der Laan pointed out, the validation group annotation was missing on the operation, which should be as follows;
App\Entity\Comment
* graphql={
* "withCustomArgsMutation"={
* "security"="is_granted('ROLE_ADMIN')",
* "mutation"=CommentReputationTypeResolver::class,
* "args"={
* "id"={"type"="ID!"},
* "resolutionType"={"type"="String!"},
* },
* "normalization_context"={"groups"={"get"}},
* "validation_groups"={"put-resolution"}
* },
Additionally, the Valid() assertion needs to be added to the CommentReport relation on Comment:
/**
* #ORM\OneToMany(targetEntity=CommentReport::class, mappedBy="comment")
* #Assert\Valid()
* #Groups({"get", "get-admin", "get-owner"})
*/
private $commentReports;
I have just installed Laragon on my new laptop. I have used Laragon before with no problems.
This time when I came to log in to phpMyAdmin I get "Cannot log in to the MySQL server" as an error.
I followed the instructions as before, and tried using Username:'root' and password:'' which is what it should be. No good, I have tried uninstalling and re-installing. Also no good.
This is my config.inc.php
Any ideas anyone. I have tried a few other configs but to no avail
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <http://docs.phpmyadmin.net/>.
*
* #package PhpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['port'] = 3306;
/*
* Laragon: set phpmyadmin to not timeout so quickly
*/
$cfg['LoginCookieValidity'] = 72000;
/*
* phpMyAdmin configuration storage settings.
*/
/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Storage database and tables */
// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
// $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
// $cfg['Servers'][$i]['relation'] = 'pma__relation';
// $cfg['Servers'][$i]['table_info'] = 'pma__table_info';
// $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
// $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
// $cfg['Servers'][$i]['column_info'] = 'pma__column_info';
// $cfg['Servers'][$i]['history'] = 'pma__history';
// $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['favorite'] = 'pma__favorite';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
// $cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
// $cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
/*
* End of servers configuration
*/
/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
/**
* Whether to display icons or text or both icons and text in table row
* action segment. Value can be either of 'icons', 'text' or 'both'.
*/
//$cfg['RowActionType'] = 'both';
/**
* Defines whether a user should be displayed a "show all (records)"
* button in browse mode or not.
* default = false
*/
//$cfg['ShowAll'] = true;
/**
* Number of rows displayed when browsing a result set. If the result
* set contains more rows, "Previous" and "Next".
* default = 30
*/
//$cfg['MaxRows'] = 50;
/**
* disallow editing of binary fields
* valid values are:
* false allow editing
* 'blob' allow editing except for BLOB fields
* 'noblob' disallow editing except for BLOB fields
* 'all' disallow editing
* default = blob
*/
//$cfg['ProtectBinary'] = 'false';
/**
* Default language to use, if not browser-defined or user-defined
* (you find all languages in the locale folder)
* uncomment the desired line:
* default = 'en'
*/
//$cfg['DefaultLang'] = 'en';
//$cfg['DefaultLang'] = 'de';
/**
* default display direction (horizontal|vertical|horizontalflipped)
*/
//$cfg['DefaultDisplay'] = 'vertical';
/**
* How many columns should be used for table display of a database?
* (a value larger than 1 results in some information being hidden)
* default = 1
*/
//$cfg['PropertiesNumColumns'] = 2;
/**
* Set to true if you want DB-based query history.If false, this utilizes
* JS-routines to display query history (lost by window close)
*
* This requires configuration storage enabled, see above.
* default = false
*/
//$cfg['QueryHistoryDB'] = true;
/**
* When using DB-based query history, how many entries should be kept?
*
* default = 25
*/
//$cfg['QueryHistoryMax'] = 100;
/**
* Should error reporting be enabled for JavaScript errors
*
* default = 'ask'
*/
//$cfg['SendErrorReports'] = 'ask';
/*
* You can find more configuration options in the documentation
* in the doc/ folder or at <http://docs.phpmyadmin.net/>.
*/
?>
Any help please
change this line:
$cfg['Servers'][$i]['host'] = 'localhost';
to this:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
and consider using a password for the root user anyway. I discourage using no password for mysql.
I was wondering why on the Java8 API the Optional class have the method ifPresent(Consumer< T> consumer) and not the ifNotPresent(Runnable** consumer)?
What's the intent of the API? Isn't it to emulate the functional pattern matching?
** Java doesn't have a zero argument void functional interface...
As Misha said, this feature will come with jdk9 in the form of a ifPresentOrElse method.
/**
* If a value is present, performs the given action with the value,
* otherwise performs the given empty-based action.
*
* #param action the action to be performed, if a value is present
* #param emptyAction the empty-based action to be performed, if no value is
* present
* #throws NullPointerException if a value is present and the given action
* is {#code null}, or no value is present and the given empty-based
* action is {#code null}.
* #since 9
*/
public void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction) {
if (value != null) {
action.accept(value);
} else {
emptyAction.run();
}
}
I have an enum in a file:
goog.provide('animals.Fish');
animals.Fish = function(obj) {
this.name_ = obj[animals.Fish.Properties.NAME];
this.awesomenessLevel_ = obj[animals.Fish.Properties.AWESOMENESS];
}
/**
* Public list of properties.
* #enum {string}
*/
animals.Fish.Properties = {
NAME: 'name',
AWESOMENESS: 'awesomenessLevel',
}
How come I can't access this enum as a static field of Fish in another class like this?
goog.require('animals.Fish');
...
var tuna = new animals.Fish(
animals.Fish.NAME: 'tuna',
animals.Fish.AWESOMENESS: '100'
)
...
Closure enumeration types are based on the concept of Enum Types from languages such as Java and C++. In Java, enum types are defined as follows:
An enum type is a type whose fields consist of a fixed set of constants. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.
In your example above, animals.Fish.Properties should probably be represented as a record type, since the assigned values are not constants. In the example below, animals.Fish.Properties has been renamed animals.Properties so that it could be applied to any type of animal (not just fish).
fish.js
goog.provide('animals.Fish');
goog.provide('animals.Properties');
/** #typedef {{name: string, awesomeness: string}} */
animals.Properties;
/**
* #param {animals.Properties} properties Animal properties.
* #constructor
*/
animals.Fish = function(properties) {
/** #type {string} */
this.name_ = properties.name;
/** #type {string} */
this.awesomenessLevel_ = properties.awesomeness;
};
/**
* #return {string} The name of the fish.
*/
animals.Fish.prototype.getName = function() {
return this.name_;
};
animals_app.js
goog.provide('animals.app');
goog.require('animals.Fish');
animals.app.tuna = new animals.Fish({name: 'tuna', awesomeness: '100'});
alert(animals.app.tuna.getName()); // alerts 'tuna'
On a side note, in the original example there should not be a comma after: AWESOMENESS: 'awesomenessLevel' in the definition of animals.Fish.Properties. In addition, in your second file you need to use the fully qualified enum name. So instead of animals.Fish.NAME it would be animals.Fish.Properties.NAME.
Looks like _compile_select is deprecated and get_compiled_select is not added to 2.1.0. Are there any other functions like those two? And also I am curious. Is there any particular reason to not adding get_compiled_select() to Active Record and removing _compile_select?
I've added get_compiled_select() to DB_active_rec.php and it seems to work without problem, but i wouldn't remove _compile_select() since it's used in many other methods.
The pull request for adding this method is here, with some other useful methods like:
get_compiled_select()
get_compiled_insert()
get_compiled_update()
get_compiled_delete()
https://github.com/EllisLab/CodeIgniter/pull/307
if you want just the method, it's just this:
/**
* Get SELECT query string
*
* Compiles a SELECT query string and returns the sql.
*
* #access public
* #param string the table name to select from (optional)
* #param boolean TRUE: resets AR values; FALSE: leave AR vaules alone
* #return string
*/
public function get_compiled_select($table = '', $reset = TRUE)
{
if ($table != '')
{
$this->_track_aliases($table);
$this->from($table);
}
$select = $this->_compile_select();
if ($reset === TRUE)
{
$this->_reset_select();
}
return $select;
}