I am viewing pdf files for printing, using TCPDF on CakePHP 2.4.
All browsers print exactly the same expected results, in addition to Adobe Acrobat reader too. The only exception is FireFox! It adds an additional blank page. I tried all suggested solutions mentioned in other questions here (and there), and none worked.
Here is my code:
<?php
App::import('Vendor', 'xtcpdf');
header('Content-type: application/pdf');
//see tcpdf_config.php for constants definitions
$pdf = new XTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', FALSE);
// set margins
$PDF_MARGIN_LEFT = $PDF_MARGIN_TOP = $PDF_MARGIN_RIGHT = $PDF_MARGIN_BOTTOM = 0;
$pdf->SetMargins($PDF_MARGIN_LEFT, $PDF_MARGIN_TOP, $PDF_MARGIN_RIGHT, $PDF_MARGIN_BOTTOM);
$pdf->setPrintHeader(FALSE); //$pdf->SetHeaderMargin(25);
$pdf->setPrintFooter(FALSE); //$pdf->SetFooterMargin(25);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setFontSubsetting(FALSE);
$pdf->SetAutoPageBreak(TRUE, 0);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->addPage('L', 'Letter');
//****************** Completion Image *************************************//
$pdf->Image('/img/completion.png', $x = -10, $y = 34, $w = 240, $h = 30, $type = 'PNG', $link = '', $align = 'C', $resize = TRUE, $dpi = 900, $palign = 'C', $ismask = false, $imgmask = false, $border = 0, $fitbox = TRUE, $hidden = false, $fitonpage = TRUE);
//************************************************** TITLE Body **************************************************//
$pdf->SetFont('times', '', 20);
$title = $information['title'] ;
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 0, $y = 66, $title, $border = 0, $ln = 0, $fill = 0, $reseth = true, $align = 'C', $autopadding = true);
//****************** Description *********************************//
$pdf->SetFont('times', 'I', 16);
$description = 'bla bla bla bla bla';
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 0, $y = 93, $description, $border = 0, $ln = 0, $fill = 0, $reseth = true, $align = 'C', $autopadding = TRUE);
//************************** NAME **********************************//
$pdf->SetFont('times', 'B', 24);
$fullName = $information['Student']['first_name'] . ' ' . (!empty($information['Student']['middle_initial']) ? ($information['Student']['middle_initial'] . ' ') : '') . $certificate['Student']['last_name'];
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 0, $y = 127, $fullName, $border = false, $ln = 0, $fill = 0, $reseth = true, $align = 'C', $autopadding = FALSE);
//***************** Line/OFFICE ************************//
$pdf->SetFont('times', 'B', 12);
$office = '__________________________________________________<br/> Bla Bla Bla <br/>Office of bla bla blat<br/>bla bla bla bla';
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 3, $y = 151, $office, $border = 0, $ln = 10, $fill = 0, $reseth = FALSE, $align = 'C', $autopadding = FALSE);
//******************************* Certificate No. ************************************//
$pdf->SetFont('times', 'B', 10);
$certNo = 'No. ' . $information['Certificate']['certificate_No'];
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 32, $y = 154, $certNo, $border = 0, $ln = 0, $fill = 0, $reseth = FALSE, $align = 'L', $autopadding = false);
//*************************** Date of Issuance ****************************//
$pdf->SetFont('times', '', 10);
$issueDate = 'Date of Issuance: ' . date('F, Y', strtotime($information['Certificate']['award_date']));
$pdf->writeHTMLCell($w = 0, $h = 0, $x = 31, $y = 157, $issueDate, $border = 0, $ln = 0, $fill = 0, $reseth = false, $align = 'L', $autopadding = FALSE);
echo $pdf->Output('PDF' . $information['Certificate']['certificate_number'] . '.pdf', 'I');
$pdf->endPage();
questions I looked at:
Extra blank page with TCPDF
how TCPDF prevent the extra blank page
Firefox prints extra blank page
I found no documentation, no articles, no one can explain such weird behavior.
After all, an extra blank paper won't do any harm!
Related
I am trying to get proper synchronization working in trying to get a compute shader writing to an image. However, when I enable validation layers I get the following errors:
[ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0x4b7df1000000002f, type = VK_OBJECT_TYPE_IMAGE_VIEW; | MessageID = 0x5c0ec5d6 | vkCmdDispatch: Hazard WRITE_AFTER_WRITE for VkImageView 0x4b7df1000000002f[], in VkCommandBuffer 0x558d7b2aec00[], and VkPipeline 0x95a125000000001a[], VkDescriptorSet 0x944a2c0000000039[], type: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, imageLayout: VK_IMAGE_LAYOUT_GENERAL, binding #0, index 0. Access info (usage: SYNC_COMPUTE_SHADER_SHADER_STORAGE_WRITE, prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: 0, command: vkCmdPipelineBarrier, seq_no: 1, reset_no: 1).
[ SYNC-HAZARD-WRITE-AFTER-WRITE ] Object 0: handle = 0xb12fb2000000002c, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x5c0ec5d6 | vkCmdPipelineBarrier: Hazard WRITE_AFTER_WRITE for image barrier 0 VkImage 0xb12fb2000000002c[]. Access info (usage: SYNC_IMAGE_LAYOUT_TRANSITION, prior_usage: SYNC_COMPUTE_SHADER_SHADER_STORAGE_WRITE, write_barriers: 0, command: vkCmdDispatch, seq_no: 2, reset_no: 1).
The relevant code is as follows:
vkBeginCommandBuffer(cmdBuffer, &cmdBufBeginInfo);
VkImageMemoryBarrier toGeneralBarrier = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = NULL,
.srcAccessMask = 0,
.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = vr.swapImages[imageIndex],
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
},
};
vkCmdPipelineBarrier(
cmdBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
0,
0,
NULL,
0,
NULL,
1,
&toGeneralBarrier);
// vkCmdBindPipeline, vkCmdBindDescriptorSets is left out, not interesting
vkCmdDispatch(cmdBuffer, dispatchX, dispatchY, 1); // hazard here
VkImageMemoryBarrier toPresentBarrier = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.pNext = NULL,
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
.dstAccessMask = 0,
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
.image = vr.swapImages[imageIndex],
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
},
};
vkCmdPipelineBarrier( // hazard here?
cmdBuffer,
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
0,
0,
NULL,
0,
NULL,
1,
&toPresentBarrier);
// vkEndCommandBuffer, vkQueueSubmit, vkQueuePresentKHR, ... left out
I have tried searching for a mistake in my code that code have caused these errors but I could not find one. Is there something wrong with my pipeline barriers and how do I fix this?
I am using the following AFL code for "Initial Balance with Range Extension" in AmiBroker -
_SECTION_BEGIN("Initial Balance with Range Extensions");
P11 = Param("IB Start Time",091500, 0 , 235959, 1 ) ;
P12 = Param("IB END Time",101500, 0 , 235959, 1 ) ;
START = (TimeNum()>= P11);
END = (TimeNum()<= P12);
ZONE = START AND END;
ST = (TimeNum()>= P12);
NewTime = ZONE!= Ref(ZONE, -1);
highestoftheday = HighestSince(NewTime,H,1);
Lowestoftheday = LowestSince(NewTime,L,1);
IBHigh = ValueWhen(ZONE,highestoftheday,1);
IBLow = ValueWhen(ZONE,lowestoftheday,1);
ORBClose = ValueWhen(zone,C,1);
IBrange = IBHigh - IBLow; // First Hour Range
IBM = IBLow+IBrange/2;
IB1xh = IBHigh+IBrange ; // Target 1 for range extension upside
IB2xh = IBHigh+2*IBrange ;
IB3xh = IBHigh+3*IBrange ;
IB1xl = IBLow-IBrange ;
IB2xl = IBLow-2*IBrange ; // target 1 for range extension downside
IB3xl = IBLow-3*IBrange ;
PlotGrid(LastValue(IBHigh, True), colorPlum, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IBLow, True), colorPlum, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IBM, True), colorBrown, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB1xh, True), colorGreen, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB2xh, True), colorGreen, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB3xh, True), colorGreen, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB1xl, True), colorRed, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB2xl, True), colorRed, pattern=10, width = 2, label = True);
PlotGrid(LastValue(IB3xl, True), colorRed, pattern=10, width = 2, label = True);
_SECTION_END();
This code is plotting continuous horizontal lines. But I need disjointed horizontal lines for individual sessions. How can I get that? Please help me to fix this issue. Thanks for your time and effort. Regards.
I've been trying to find this by myself but I'm not entirely sure even how to phrase the question. Essentially what I'm doing here is taking an array of Names, and from that creating a checkbox for each name. Edit: I thought the code snippet below was working too but it looks like this might not be actually working?
New-object System.Windows.Forms.CheckBox | New-Variable -Name ("checkbox" + $_)
The main problem I'm having is this: How do I actually set the properties on these variable named checkboxes once they've been created? Essentially how to get the variable name for each iteration, then do the $checkbox.margin and such settings. I've posted my entire script below, it's very WIP and I know there's some other stuff that's weird but I'm planning to sort that out once I can fix this.
$form = New-Object System.Windows.Forms.Form
$flowlayoutpanel = New-Object System.Windows.Forms.FlowLayoutPanel
$buttonOK = New-Object System.Windows.Forms.Button
$usernames = "andrew", "beth", "charlie", "dave", "james", "george"
$totalvalues = ($usernames.count)
$formsize = 85 + (30 * $totalvalues)
$flowlayoutsize = 10 + (30 * $totalvalues)
$buttonplacement = 40 + (30 * $totalvalues)
$form_Load = {
0..$totalvalues|%{
New-object System.Windows.Forms.CheckBox | New-Variable -Name ("checkbox" + $_)
('$checkbox' + $_).Margin = '10, 8, 0, 0'
$checkbox.Margin = '10, 8, 0, 0'
$checkbox.Name = 'checkbox' + $_
$checkbox.Size = '200, 22'
$checkbox.Text = "" + $usernames[$_]
$checkbox.TextAlign = 'MiddleLeft'
$flowlayoutpanel.Controls.Add($checkbox)
}
}
$form.Controls.Add($flowlayoutpanel)
$form.Controls.Add($buttonOK)
$form.AcceptButton = $buttonOK
$form.AutoScaleDimensions = '8, 17'
$form.AutoScaleMode = 'Font'
$form.ClientSize = "500 , $formsize"
$form.FormBorderStyle = 'FixedDialog'
$form.Margin = '5, 5, 5, 5'
$form.MaximizeBox = $False
$form.MinimizeBox = $False
$form.Name = 'form1'
$form.StartPosition = 'CenterScreen'
$form.Text = 'Form'
$form.add_Load($form_Load)
$flowlayoutpanel.BorderStyle = 'FixedSingle'
$flowlayoutpanel.Location = '48, 13'
$flowlayoutpanel.Margin = '4, 4, 4, 4'
$flowlayoutpanel.Name = 'flowlayoutpanel1'
$flowlayoutpanel.Size = "400, $flowlayoutsize"
$flowlayoutpanel.TabIndex = 1
$buttonOK.Anchor = 'Bottom, Right'
$buttonOK.DialogResult = 'OK'
$buttonOK.Location = "383, $buttonplacement"
$buttonOK.Margin = '4, 4, 4, 4'
$buttonOK.Name = 'buttonOK'
$buttonOK.Size = '100, 30'
$buttonOK.TabIndex = 0
$buttonOK.Text = '&OK'
$form.ShowDialog()
Replace your foreacheach loop with this code
$form_Load = {
foreach($user in $usernames){
$DynamicCheckBox = New-Variable -Name ("checkbox" + $user)
$DynamicCheckBox = New-object System.Windows.Forms.CheckBox
$DynamicCheckBox.Margin = '10, 8, 0, 0'
$DynamicCheckBox.Name = 'checkbox' + $_
$DynamicCheckBox.Size = '200, 22'
$DynamicCheckBox.Text = "" + $user
$DynamicCheckBox.TextAlign = 'MiddleLeft'
$flowlayoutpanel.Controls.Add($DynamicCheckBox)
}
}
I have a script that runs a Windows form and a textbox in it.
My question is: when the GUI is running and presented to the user, I change the content of the textbox, how can I refresh the GUI and see the changes?
$formText = New-Object 'System.Windows.Forms.Form'
$richtextbox1 = New-Object 'System.Windows.Forms.RichTextBox'
$buttonFind = New-Object 'System.Windows.Forms.Button'
$textboxFind = New-Object 'System.Windows.Forms.TextBox'
$buttonCopy = New-Object 'System.Windows.Forms.Button'
$buttonExit = New-Object 'System.Windows.Forms.Button'
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
#endregion Generated Form Objects
#region FindFunction
function FindText
{
if ($textboxFind.Text.Length -eq 0)
{
return
}
$index = $richtextbox1.Find($textboxFind.Text,$richtextbox1.SelectionStart+ $richtextbox1.SelectedText.Length,[System.Windows.Forms.RichTextBoxFinds]::None)
if ($index -ge 0)
{
$richtextbox1.Select($index,$textboxFind.Text.Length)
$richtextbox1.ScrollToCaret()
#$richtextbox1.Focus()
}
else
{
$index = $richtextbox1.Find($textboxFind.Text,0,$richtextbox1.SelectionStart,[System.Windows.Forms.RichTextBoxFinds]::None)
#
if ($index -ge 0)
{
$richtextbox1.Select($index,$textboxFind.Text.Length)
$richtextbox1.ScrollToCaret()
#$richtextbox1.Focus()
}
else
{
$richtextbox1.SelectionStart = 0
}
}
}
#endregion
$formText_Load = {
#TODO: Initialize Form Controls here
}
$buttonExit_Click = {
#TODO: Place custom script here
$formText.Close()
}
$buttonLoad_Click = {
Load-Text
}
$buttonCopy_Click = {
#The following requires STA mode
# if ($textbox1.Text.Length -gt 0)
# {
# [System.Windows.Forms.Clipboard]::SetText($textbox1.Text)
# }
#Alternative - Does not require STA
$richtextbox1.SelectAll() #Select all the text
$richtextbox1.Copy() #Copy selected text to clipboard
$richtextbox1.Select(0,0); #Unselect all the text
}
$textboxFind_TextChanged = {
$buttonFind.Enabled = $textboxFind.Text.Length -gt 0
}
$buttonFind_Click = {
#TODO: Place custom script here
FindText
}
#################################################
# Customize LoadText Function
#################################################
$Form_StateCorrection_Load = {
#Correct the initial state of the form to prevent the .Net maximized form issue
$formText.WindowState = $InitialFormWindowState
}
$Form_StoreValues_Closing = {
#Store the control values
$script:MainForm_richtextbox1 = $richtextbox1.Text
$script:MainForm_textboxFind = $textboxFind.Text
}
$Form_Cleanup_FormClosed = {
#Remove all event handlers from the controls
try
{
$buttonFind.remove_Click($buttonFind_Click)
$textboxFind.remove_TextChanged($textboxFind_TextChanged)
$buttonCopy.remove_Click($buttonCopy_Click)
$buttonExit.remove_Click($buttonExit_Click)
$formText.remove_Load($formText_Load)
$formText.remove_Load($Form_StateCorrection_Load)
$formText.remove_Closing($Form_StoreValues_Closing)
$formText.remove_FormClosed($Form_Cleanup_FormClosed)
}
catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
}
$formText.Controls.Add($richtextbox1)
$formText.Controls.Add($buttonFind)
$formText.Controls.Add($textboxFind)
$formText.Controls.Add($buttonCopy)
$formText.Controls.Add($buttonExit)
$formText.AcceptButton = $buttonFind
$formText.AutoScaleDimensions = '10, 20'
$formText.AutoScaleMode = 'Font'
$formText.ClientSize = '828, 594'
$formText.Margin = '8, 8, 8, 8'
$formText.Name = 'formText'
$formText.StartPosition = 'CenterScreen'
$formText.Text = 'Wake On Lan'
$formText.add_Load($formText_Load)
$formtext.TopMost = $True
$richtextbox1.Anchor = 'Top, Bottom, Left, Right'
$richtextbox1.BackColor = 'Window'
$richtextbox1.Font = 'Courier New, 12pt'
$richtextbox1.HideSelection = $False
$richtextbox1.Location = '20, 55'
$richtextbox1.Margin = '5, 5, 5, 5'
$richtextbox1.Name = 'richtextbox1'
$richtextbox1.ReadOnly = $True
$richtextbox1.Size = '784, 467'
$richtextbox1.TabIndex = 6
$richtextbox1.WordWrap = $False
#
# buttonFind
#
$buttonFind.Anchor = 'Top, Right'
$buttonFind.Enabled = $False
$buttonFind.Location = '748, 1'
$buttonFind.Margin = '5, 5, 5, 5'
$buttonFind.Name = 'buttonFind'
$buttonFind.Size = '60, 35'
$buttonFind.TabIndex = 5
$buttonFind.Text = '&Find'
$buttonFind.UseVisualStyleBackColor = $True
$buttonFind.add_Click($buttonFind_Click)
#
# textboxFind
#
$textboxFind.Anchor = 'Top, Right'
$textboxFind.Location = '420, 15'
$textboxFind.Margin = '8, 8, 8, 8'
$textboxFind.Name = 'textboxFind'
$textboxFind.Size = '316, 26'
$textboxFind.TabIndex = 4
$textboxFind.add_TextChanged($textboxFind_TextChanged)
#
# buttonCopy
#
$buttonCopy.Anchor = 'Bottom'
$buttonCopy.Location = '20, 540'
$buttonCopy.Margin = '5, 5, 5, 5'
$buttonCopy.Name = 'buttonCopy'
$buttonCopy.Size = '125, 35'
$buttonCopy.TabIndex = 3
$buttonCopy.Text = '&Copy'
$buttonCopy.UseVisualStyleBackColor = $True
$buttonCopy.add_Click($buttonCopy_Click)
#
# buttonExit
#
$buttonExit.Anchor = 'Bottom, Right'
$buttonExit.Location = '683, 540'
$buttonExit.Margin = '5, 5, 5, 5'
$buttonExit.Name = 'buttonExit'
$buttonExit.Size = '125, 35'
$buttonExit.TabIndex = 2
$buttonExit.Text = 'E&xit'
$buttonExit.UseVisualStyleBackColor = $True
$buttonExit.add_Click($buttonExit_Click)
$formText.ResumeLayout()
#endregion Generated Form Code
$Results = "1","2"
#---------------------------------------------
$richtextbox1.Text = foreach ($Result in $Results) {
($Result+[Environment]::NewLine)
}
#Save the initial state of the form
$InitialFormWindowState = $formText.WindowState
#Init the OnLoad event to correct the initial state of the form
$formText.add_Load($Form_StateCorrection_Load)
#Clean up the control events
$formText.add_FormClosed($Form_Cleanup_FormClosed)
#Store the control values when form is closing
$formText.add_Closing($Form_StoreValues_Closing)
#Show the Form
$formText.ShowDialog()
I have a problem with a function and an array since yesterday. It seems that lever ID is not declared or something...
Here is my code:
function tpp(leverID, from, to)
if item.uid == leverID and item.itemid == 1945 then
local count_players = #to
local store = {}
for i = 1, count_players do
local pid = getTopCreature(from[i]).uid
if (pid == 0 or not isPlayer(pid)) then
return doPlayerSendCancel(cid, 'You need ' .. count_players .. ' players to use this lever.')
end
store[i] = pid
end
for i = 1, count_players do
doSendMagicEffect(from[i], CONST_ME_POFF)
doTeleportThing(store[i], to[i], false)
doSendMagicEffect(to[i], CONST_ME_TELEPORT)
end
doTransformItem(item.uid, item.itemid + 1)
elseif item.uid == leverID and item.itemid == 1946 then
doTransformItem(item.uid, item.itemid -1)
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = {
['pos_start'] = {
{['x'] = 1059, ['y'] = 1034, ['z'] = 7},
{['x'] = 1060, ['y'] = 1034, ['z'] = 7}
},
['pos_end'] = {
{['x'] = 1059, ['y'] = 1032, ['z'] = 7},
{['x'] = 1060, ['y'] = 1032, ['z'] = 7}
}
}
tpp(10150, pos['pos_start'], pos['pos_end'])
return true
end
I get the this error:
attempt to index global 'item' (a nil value)
I am new to lua. Can someone help me? Thanks!
Probably you forgot to pass 'item' variable to tpp() function when you called it from onUse() function.
Since there was no 'item variable in scope of tpp() function, or in its arguments, variable considered to be global, and there's no global variable with that name.