TCPDF User Units - tcpdf

I'm having a strange behaviour of the user units in TCPDF.
I created a new PDF with the following construct:
$pdf = new Pdf("P", "mm", "A4", true, 'UTF-8', false);
The strange thing is that getPageDimensions() is getting me strange user units:
$pageDimensions = $this->getPageDimensions();
$pageDimensions['wk']: 50.4000346667
$pageDimensions['hk']: 71.28002
$this->getPageWidth(): 50.4000346667
$this->getPageHeight(): 71.28002
I cannot understand what's wrong.
Could you help me, please?
Thank you very much!
Bye.

I discovered and solved my problem.
I my custom class (which extends TCPDF) I was redeclaring and so rewriting the value of the "dpi" variable.

Related

Grails 3 Entity not saved when properties set in EntityClass

I occure a problem which I do not understand. Following code does not work:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setLifecycleStatusToArchived();
accountingEntity.save(flush:true);
Where the method setLivecylceStatusToArchived looks like:
void setLifecycleStatusToArchived() {
this.lifecycleStatus = AccountingEntity.LIFECYCLE_ARCHIVED; //predefined static variable
this.considerForRankingJob = false;
this.dateArchived = new Date();
}
Problem is, that the entity is not updated.
No validation erros when I use accountingEntity.validate() in advance.
However, this code works:
AccountingEntity accountingEntity = AccountingEntity.get(params.id);
accountingEntity.setDateArchived(new Date());
accountingEntity.setConsiderForRankingJob(false);
accountingEntity.setLifecycleStatus(AccountingEntity.LIFECYCLE_ARCHIVED);
accountingEntity.save(flush:true);
The code did not work any more after update from Grails 3.2.9 to 3.3.0.RC1 (Gorm 6.1.5) unless I followed all the steps in the guide (http://docs.grails.org/3.3.x/guide/upgrading.html) and the rest of the code is working properly (also database accesses etc.)
Has anybody an idea? What the problem could be?
Thanks in advance and best regards!
The short answer is dirty checking. When you are setting properties inside the instance method Grails doesn't know they are dirty.
See the following github issue for how to resolve the problem:
https://github.com/grails/grails-data-mapping/issues/961
you have 2 options:
call markDirty every time you change an internal field. This will be
better for performance or as per
http://gorm.grails.org/latest/hibernate/manual/index.html#upgradeNotes
use
hibernateDirtyChecking: true

Specific attributes are being excluded from darts Element.setInnerHtml()

I've encountered the following problem:
Before mods may click 'duplicate', it isn't. I've searched the problem, found 'solutions', applied 'solutions' and they didn't work. So the question could be 'Why is my 'solution' not working?' or the question could be 'What is the actual solution?'
The responsible code for this is
querySelector("#element").setInnerHtml(some_element.outerHtml, treeSanitizer: NodeTreeSanitizer.trusted);
What am I doing wrong?
I found out to apply the sanitizer to the Element.
Element element = new Element.html('<a data-tag="value">thing</a>'), treeSanitizer: NodeTreeSanitizer.trusted)
I haven't gone back recently to double check that is the best way, but we've ended up building a common NodeValidator that we keep up to date with our various custom attributes.
NodeValidator get commonValidator => _commonValidator;
/// Create a NodeValidator which passes common values.
final NodeValidator _commonValidator = new NodeValidatorBuilder.common()
..allowHtml5()
..allowInlineStyles()
..allowNavigation(_policy)
..allowImages()
..allowTextElements()
..allowElement("a", attributes: [
"data-version",
"data-attribute-add"])
..allowElement("div", attributes: [
"data-sec"]);
foo.setInnerHtml(someOddHtml, validator: commonValidator);

How to edit an attribute using Xtext?

I want to use Xtext's editor to edit a String attribute of an EObject instead of editing a text file. How can I achieve this? I found this thread but it only mentions the workaround of creating a temp file. There must be a more elegant solution. I thought of creating a custom EditorInput but I'm not sure where to start. Thanks in advance for any pointers!
Since 2.2, the supported solution is using IEditedResourceProvider with an EmbeddedEditorFactory (since editing an attribute belongs to an embedded editor anyway). Sample code in Xtend (the attribute is updated whenever the editor changes):
val injector = MyDslActivator.instance.getInjector(MyDslActivator.COM_EXAMPLE_MY_DSL)
val resourceSet = injector.getInstance(IResourceSetProvider).get(null)
val fileExtension = injector.getInstance(Key.get(String, Names.named(Constants.FILE_EXTENSIONS)))
val resourceProvider = [|
resourceSet.createResource(createURI('''temp.«fileExtension»''')) as XtextResource
]
injector.getInstance(EmbeddedEditorFactory).newEditor(resourceProvider).withParent(parent) => [
createPartialEditor("", editedAttribute ?: "", "", false)
document.addModelListener[_ | editedAttribute = document.get]
]
Based on: EditTemplateDialog source, StackOverflow, Eclipse Forum.

How to change translator for validator messages in Zend framework 2?

I try to set the default translator by using PhpArray in resources/languages/fr/Zend_validate :
$translator = new Translator();
$translator->addTranslationFile(
'phpArray',
'resources/languages/fr/Zend_Validate.php',
'default',
'fr_FR'
);
AbstractValidator::setDefaultTranslator($translator);
But it doesn't work !
I have this error :
Fatal error: Class 'Application\Model\AbstractValidator' not found in...
Otherwise I take care of import this class :
use Zend\Validator;
Thanks for your help
Are you missing a use statement?
use Zend\Validator\AbstractValidator;
or try:
\Zend\Validator\AbstractValidator instead of AbstractValidator;
Edit: I noticed you mentioned the use Zend\Validator; you should then be able to use Validator\AbstractValidator
Try this:
\Zend\Validator\AbstractValidator::setDefaultTranslator(new \Zend\Mvc\I18n\Translator($translator));

change the layout html encoding in symfony

I'm doing a web application in Symfony 1.4, and its character encoding is set to utf-8 (default). That is ok, but I would like to change the character encoding to s-jis depending on some situations.
I tried with the code below in the module (action.class.php), but it does not work properly:
if('some situation')
{
$context = $this->getContext();
$response = $context->getResponse();
$response->setContentType('application/xhtml+xml; charset=Shift_JIS');
mb_internal_encoding('SJIS-win');
mb_http_output('SJIS-win');
}
Does someone know how to change the character encoding to sjis temporaly?
Thanks!
You can try this at the beginning of your actions.class.php
$this->getResponse()->initialize(new sfEventDispatcher(), array('charset' => '<something>'));
I could not answer till now. There you go.
We have to use a class that inherits from sfFilter class.
Put the new class file in apps/frontend/lib
Add the new class to apps/frontend/config/filters.yml
Change the encoding of setContentType and the Content of sfResponse in the new class function.

Resources