Aspose.pdf.Heading text went to out of the page - DOM pdf approach - aspose

I am trying to build list text using the heading objects. While entering the text into heading text, the list text is went to out of the page.
Document pdfDoc = new Document();
pdfDoc.PageInfo.Width = 612.0;
pdfDoc.PageInfo.Height = 792.0;
pdfDoc.PageInfo.Margin = new MarginInfo();
pdfDoc.PageInfo.Margin.Left = 72;
pdfDoc.PageInfo.Margin.Right = 72;
pdfDoc.PageInfo.Margin.Top = 72;
pdfDoc.PageInfo.Margin.Bottom = 72;
Page pdfPage = pdfDoc.Pages.Add();
pdfPage.PageInfo.Width = 612.0;
pdfPage.PageInfo.Height = 792.0;
pdfPage.PageInfo.Margin = new MarginInfo();
pdfPage.PageInfo.Margin.Left = 72;
pdfPage.PageInfo.Margin.Right = 72;
pdfPage.PageInfo.Margin.Top = 72;
pdfPage.PageInfo.Margin.Bottom = 72;
Heading heading = new Heading(0);
heading.Text = "(a) Text contends that the trial incorrectly completed the Support Worksheet that accompanied the trial. Calculation of the resulting Calculation of the resulting modified child support amount.";
pdfPage.Paragraphs.Add(heading);
string outFile = "D:/Text_Xhtmls/Heading.pdf";
Please find the image for your reference- image

Related

GAN discriminator detach

Hello, I am new to the GANs. I wanted to ask why do we need to use detach() in the discriminator. I highlighted it in red. It is a part from Cyclegan by Alladdin person Github. Thank you for response.
with torch.cuda.amp.autocast():
fake_horse = gen_H(zebra) # generating fake horse
D_H_real = disc_H(horse) # classifying real horse
D_H_fake = ***disc_H(fake_horse.detach())***
H_reals += D_H_real.mean().item()
H_fakes += D_H_fake.mean().item()
D_H_real_loss = mse(D_H_real, torch.ones_like(D_H_real))
D_H_fake_loss = mse(D_H_fake, torch.zeros_like(D_H_fake))
D_H_loss = D_H_real_loss + D_H_fake_loss
fake_zebra = gen_Z(horse)
D_Z_real = disc_Z(zebra)
D_Z_fake = disc_Z(fake_zebra.detach())
D_Z_real_loss = mse(D_Z_real, torch.ones_like(D_Z_real))
D_Z_fake_loss = mse(D_Z_fake, torch.zeros_like(D_Z_fake))
D_Z_loss = D_Z_real_loss + D_Z_fake_loss
# put it togethor
D_loss = (D_H_loss + D_Z_loss)/2

how to add extra price to cart programmatically in prestahop 1.7

Am new to prestashop 1.7. I want to add extra cost for customization product on adding to cart in prestashop 1.7. Please any body help me.
add own customization data to cart.
$idProduct = Tools::getValue('pid'); // for me it's always one
$qty=Tools::getValue('qty'); // always add one item
$token = Tools::getValue('token');
$customData_front = Tools::getValue('front_view');
$customData_back = Tools::getValue('back_view');
$customData = Tools::getValue('customdata');
$attribute =Tools::getValue('id_product_attribute')
if (is_null($this->context->cart->id)) {
$this->context->cart->add();
$this->context->cookie->__set('id_cart', $this->context->cart->id);
}
// get cart id if exists
if ($this->context->cookie->id_cart)
{
$cart = new Cart($this->context->cookie->id_cart);
}
// create new cart if needed
if (!isset($cart) OR !$cart->id)
{
$cart = new Cart($this->context->cookie->id_cart);
$cart->id_customer = (int)($this->context->cookie->id_customer);
$cart->id_address_delivery = (int) (Address::getFirstCustomerAddressId($cart->id_customer));
$cart->id_address_invoice = $cart->id_address_delivery;
$cart->id_lang = (int)($this->context->cookie->id_lang);
$cart->id_currency = (int)($this->context->cookie->id_currency);
$cart->id_carrier = 1;
$cart->recyclable = 0;
$cart->gift = 0;
$cart->add();
$this->context->cookie->id_cart = (int)($cart->id);
}
$product = new Product((int)$idProduct);
if ($attribute > 0) {
$minimal_quantity = (int)Attribute::getAttributeMinimalQty($this->id_product_attribute);
} else {
$minimal_quantity = (int)$product->minimal_quantity;
}
// add customizatated text
$check =serialize($customData);
$id_address_delivery = $cart->id_address_delivery;
$customization = $this->context->cart->addTextFieldToProduct((int)($idProduct), 9, Product::CUSTOMIZE_TEXTFIELD, serialize($customData));
$exising_customization = Db::getInstance()->executeS('SELECT id_customization FROM '._DB_PREFIX_.'customized_data ORDER BY id_customization DESC LIMIT 0,1');
$customization = $exising_customization[0]['id_customization'];
Db::getInstance()->execute('UPDATE ps_customization SET in_cart = 1, id_product_attribute = '.$attribute.',id_address_delivery='.$id_address_delivery.',quantity='.$minimal_quantity.' WHERE id_customization = ' .$customization);
// get product to add into cart
$productToAdd = new Product((int)($idProduct), true, (int)($this->context->cookie->id_lang));
$cart->update();
$this->context->cart->updateQty((int)($qty),(int)($idProduct),(int)($attribute),$customization,'up',(int)($id_address_delivery));
$cart->update();
In that I want add additional cost every customization.

"Module already present - choose a different name." vtiger 6.4

I followed all the steps mentioned on create custom module in vtiger 6 to create custom module but I am getting the error Module already present - choose a different name
Please advice.
As your are using vtiger 6.4 , there are lot of difference between vTiger 6 and vtiger6.4.
Try with the below script as I am using same for new module creation. Use new module name. And change the UI Types and field labels as per your requirement.
<?php
$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');
$module = new Vtiger_Module();
$module->name = 'Your_MODULE_NAME';
$module->parent = 'Tools';
$module->save();
$module->initTables();
$module->initWebservice();
$block = new Vtiger_Block();
$block->label = 'LBL_INFORMATION_DETAIL';
$module->addBlock($block); //to create a new block
$field1 = new Vtiger_Field();
$field1->name = 'browse';
$field1->table=$module->basetable;
$field1->label= 'Upload Csv';
$field1->column = 'browse';
$field1->columntype = 'VARCHAR(255)';
$field1->uitype= 28;
$field1->typeofdata = 'V~O';
$block->addField($field1);
$field2 = new Vtiger_Field();
$field2->name = 'fieldid';
$field2->table=$module->basetable;
$field2->label= 'Record ID';
$field2->uitype= 4;
$field2->column = 'fieldid';
$field2->columntype = 'VARCHAR(255)';
$field2->typeofdata = 'V~M';
$block->addField($field2);
$module->setEntityIdentifier($field2);
$field3 = new Vtiger_Field();
$field3->name = 'age';
$field3->table=$module->basetable;
$field3->label= 'Age';
$field3->uitype= 1;
$field3->column = 'age';
$field3->columntype = 'VARCHAR(100)';
$field3->typeofdata = 'V~O';
$block->addField($field3);
$field4 = new Vtiger_Field();
$field4->name = 'statusrecord';
$field4->table=$module->basetable;
$field4->label= 'Status';
$field4->uitype= 15;
$field4->column = 'statusrecord';
$field4->columntype = 'VARCHAR(255)';
$field4->setPicklistValues( Array('new','closed','closedwithfailure','inprogress'));
$field4->typeofdata = 'V~M';
$block->addField($field4);
// Recommended common fields every Entity module should have (linked to core table)
$field5 = new Vtiger_Field();
$field5->name = 'assigned_user_id';
$field5->label = 'Assigned To';
$field5->table = 'Vtiger_crmentity';
$field5->column = 'smownerid';
$field5->uitype = 53;
$field5->typeofdata = 'V~M';
$block->addField($field5);
$field6 = new Vtiger_Field();
$field6->name = 'CreatedTime';
$field6->label= 'Created Time';
$field6->table = 'Vtiger_crmentity';
$field6->column = 'createdtime';
$field6->uitype = 70;
$field6->typeofdata = 'T~O';
$field6->displaytype= 2;
$block->addField($field6);
$field7 = new Vtiger_Field();
$field7->name = 'ModifiedTime';
$field7->label= 'Modified Time';
$field7->table = 'Vtiger_crmentity';
$field7->column = 'modifiedtime';
$field7->uitype = 70;
$field7->typeofdata = 'T~O';
$field7->displaytype= 2;
$block->addField($field7);
// Filter Setup
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$module->addFilter($filter1);
// Add fields to the filter create
$filter1->addField($field7, 2);
$filter1->addField($field3, 3);
$filter1->addField($field4, 5);
/** Set sharing access of this module */
$module->setDefaultSharing();
/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));
$module->disableTools('Merge');
?>
You can also refer Entity-Module-Documentation

NetSuite - error closing return authorization using web services

Within NetSuite when trying to close out Return Authorization line items i receive the following error message:
INSUFFICIENT_PERMISSION
"You do not have permissions to set a value for element item.quantityreceived due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases."
Here is the code:
//Pull down the RA in order to work with the line items in question
RecordRef rec = new RecordRef();
rec.internalId = internalId;
rec.type = RecordType.returnAuthorization;
rec.typeSpecified = true;
ReadResponse response = _service.get(rec);
//create the object from the response record returned
ReturnAuthorization ra = (ReturnAuthorization)response.record;
//cancel the order by updating the qty of each item to zero.
WriteResponse res = null;
ReturnAuthorizationItem[] raItemList = ra.itemList.item;
for (int lineCounter = 0; lineCounter < raItemList.Length; lineCounter++)
{
//only if the qty received is zero are we closing out the item(setting qty to zero)
if (raItemList[lineCounter].quantityReceived == 0)
{
raItemList[lineCounter].quantity = 0;
raItemList[lineCounter].quantitySpecified = true;
}
}
//create a new object and add all the changes in order to update the order lines
ReturnAuthorization updRa = new ReturnAuthorization();
updRa.internalId = internalId;
updRa.itemList = new ReturnAuthorizationItemList();
updRa.itemList.item = new ReturnAuthorizationItem[raItemList.Length];
updRa.itemList.item = raItemList;
res = _service.update(updRa);
I am trying to update the line quantity to zero, which in affect will close the Return Authorization if everything has been zeroed out. Question is how do i correct this permissions issue in order to run this update. I have tried setting other fields on this same call. No matter which field i try and update i get the same error message. This is running under an admin account and all permissions look fine as far as i can see. In fact i am running this very same logic against the SaleOrder object to close out Sales Orders with no issues.
Any help would be much appreciated.
Thanks,
Billy
You can't directly edit that line item field. That field is maintained by Netsuite and reflects Item Receipts received against the RA.
If you want to close the RA without receiving just set the line item column field "Closed" to true.
After looking at this a little closer here is the solution:
Replace the if statement in the loop with this:
//only if the qty received and returned are zero do we close out the item(setting qty to zero)
if (raItemList[lineCounter].quantityReceived == 0 && raItemList[lineCounter].quantityBilled == 0)
{
raItemList[lineCounter].quantity = 0;
raItemList[lineCounter].quantitySpecified = true;
raItemList[lineCounter].isClosed = true;
raItemList[lineCounter].isClosedSpecified = true;
raItemList[lineCounter].quantityReceivedSpecified = false;
raItemList[lineCounter].quantityBilledSpecified = false;
raItemList[lineCounter].costEstimateSpecified = false;
}
else
{
raItemList[lineCounter].quantityReceivedSpecified = false;
raItemList[lineCounter].quantityBilledSpecified = false;
raItemList[lineCounter].costEstimateSpecified = false;
}
I am guessing that the fields i had to specific as false are fields that cannot be edited, hence the need to disclude them from the update.
This is a better sample. Note the comment re orderline
/Pull down the RA in order to work with the line items in question
RecordRef rec = new RecordRef();
rec.internalId = internalId;
rec.type = RecordType.returnAuthorization;
rec.typeSpecified = true;
ReadResponse response = _service.get(rec);
//create the object from the response record returned
ReturnAuthorization ra = (ReturnAuthorization)response.record;
//cancel the order by updating the qty of each item to zero.
WriteResponse res = null;
ReturnAuthorizationItem[] raItemList = ra.itemList.item;
ReturnAuthorization updRa = new ReturnAuthorization();
updRa.internalId = internalId;
updRa.itemList = new ReturnAuthorizationItemList();
ReturnAuthorizationItem[] updateItems = new ReturnAuthorizationItem[raItemList.Length];
for (int lineCounter = 0; lineCounter < raItemList.Length; lineCounter++)
{
updateItems[lineCounter].line = raItemList[lineCounter].line; // you'll need to test this. Setting only the line should result in no changes to the RA line items that are not to be closed. use the &xml=T view before and after to make sure orderline (hidden) is still populated properly.
//only if the qty received is zero are we closing out the item(setting qty to zero)
if (raItemList[lineCounter].quantityReceived == 0)
{
updateItems[lineCounter].isClosed = true;
// raItemList[lineCounter].quantitySpecified = true; // is quantitySpecified a field? it wasn't as of the 2012.2 endpoint
}
}
//create a new object and add all the changes in order to update the order lines
updRa.itemList.item = updateItems;
res = _service.update(updRa);

gSoap Exchange Web Services Connection

I'm trying to write an application that would work with the EWS proxy classes. To generate proxy classes I used gsoap (compiled OpenSSL).
I have implemented a library that works with EWS, but. Net.
The problem is this: I have no idea how to implement a connection to the server.
Doing the following:
ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy("https://192.168.0.49/EWS/exchange.asmx");
soap *pSoap = proxy->soap;
pSoap->userid = "user1";
pSoap->passwd = "password1";
pSoap->recv_timeout = 300;
pSoap->send_timeout = 300;
SOAP_ENV__Header *header = new SOAP_ENV__Header();
header->ns3__RequestServerVersion = new _ns3__RequestServerVersion();
header->ns3__RequestServerVersion->soap = pSoap;
header->ns3__RequestServerVersion->Version = ns3__ExchangeVersionType__Exchange2010;
pSoap->header = header;
//get root folder ID
ns3__DistinguishedFolderIdType *dfit = new ns3__DistinguishedFolderIdType();
dfit->Id = ns3__DistinguishedFolderIdNameType__inbox;
//set the props that we want to retrieve
ns3__FolderResponseShapeType *frst = new ns3__FolderResponseShapeType();
frst->BaseShape = ns3__DefaultShapeNamesType__AllProperties;
//get folder
ns1__GetFolderType *gftRoot = new ns1__GetFolderType();
gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot->FolderShape = frst;
__ns1__GetFolderResponse response;
int error = proxy->GetFolder(gftRoot, response);
As a result, getting the error: SLL_ERROR.
I know, that i`m doing something wrong. But what? What i should to do, to use proxy classes functions?
I resolved it by myself:
Added to project LibNTLM and added to preprocessor WITH_NTLM.
Also changed code, a little bit:
ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy(endpoint.c_str());
soap *pSoap = proxy->soap;
pSoap->userid = "Ivan1";
pSoap->passwd = "1";
pSoap->ntlm_challenge = "";
pSoap->authrealm = "Ursa-Minor";
pSoap->ssl_flags = SOAP_SSL_NO_AUTHENTICATION;
//pSoap->keep_alive = true;
pSoap->mode = SOAP_IO_KEEPALIVE;
//get root folder ID
ns3__DistinguishedFolderIdType *dfit = new ns3__DistinguishedFolderIdType();
dfit->Id = ns3__DistinguishedFolderIdNameType__inbox;
//set the props that we want to retrieve
ns3__FolderResponseShapeType *frst = new ns3__FolderResponseShapeType();
frst->BaseShape = ns3__DefaultShapeNamesType__AllProperties;
//get folder
ns1__GetFolderType *gftRoot = new ns1__GetFolderType();
gftRoot->FolderIds = new ns3__NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__size_NonEmptyArrayOfBaseFolderIdsType = 1;
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType = new __ns3__union_NonEmptyArrayOfBaseFolderIdsType();
gftRoot->FolderIds->__union_NonEmptyArrayOfBaseFolderIdsType->union_NonEmptyArrayOfBaseFolderIdsType.DistinguishedFolderId = dfit;
gftRoot->FolderIds = (ns3__NonEmptyArrayOfBaseFolderIdsType*)dfit;
gftRoot->FolderShape = frst;
__ns1__GetFolderResponse response;
int qq = proxy->GetFolder(gftRoot, response);
return true;
But now i have enother problems: Error 500: Internal Server Error