Printing from TWebBrowser with margins set to 0 - delphi

I'm printing an HTML document from my application using a TWebBrowser:
var WebHTML : TWebBrowser;
//Code to set up my TWebBrowser...
//Print the document:
WebHTML.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER); //or OLECMDEXECOPT_DONTPROMPTUSER
How can I set the margins to zero in the printout?
I've tried using WebHTML.Margins.SetBounds(0, 0, 0, 0);, but the printout still has margins 0.75in. I've also set the padding and margins to zero in my CSS:
#page {
margin: 0in;
padding: 0in;
}

Related

Expand VerticalLayout width to match Grid width

I am writing a Vaadin SearchDialog which contains :
A search TextField
A Grid containing search results
Two action buttons to confirm or cancel
Basically this is my layout structure :
Dialog
|- MainLayout (VerticalLayout)
| - - SearchField(TextField)
| - - ResultGrid (Grid)
| - - ButtonLayout (HorizontalLayout)
| - - - CancelButton
| - - - ConfirmButton
My issue is that I try to expand the grid's width to it's maximum size. I used Grid::setWidthFull and this code
resultGrid.getColumns().forEach(column -> column.setAutoWidth(true));
But it seems that the mainLayout width still set to the "ButtonLayout" :
My technical context is :
Vaadin flow 14.7 (full java)
Java 16
Spring Boot
VaadinDialog has a predefined padding applied to it. To remove it (let the Dialog take up full space, add the CSS below to your shared-styles.js file:
<dom-module id="my-dialog-styles" theme-for="vaadin-dialog-overlay">
<template>
<style>
[part="content"] {
padding: 0;
}
</style>
</template>
</dom-module>
Or add this so your shared-styles.css file to make it fullscreen
vaadin-dialog-overlay {
top: 0;
left: 0;
right: 0;
bottom: 0;
}
vaadin-dialog-overlay::part(overlay) {
width: 100%;
height: 100%;
padding: 0;
}
vaadin-dialog-overlay::part(content) {
padding: 0;
}
Grid::setWidthFull -- This means that you set the Grid's width to 100%, which in turn means that the Grid will use up as much or as little space as the parent layout has available regardless of its own contents.
If you want to expand the grid to accommodate all the contents, you don't want any width setting for it. I can't remember what the default is for Vaadin 14, but setWidth(null); should remove any previously set width.
For clearing the size settings in both directions at once there is also setSizeUndefined(), but that might not be optimal with your Grid (unless you have very few rows).

how to make text vertically center in fabric js TextBox

I am working on one fabric js editor, in which I need to implement TextBox as a Button look and feel,
For that, I Have implemented TextBox with Background, But Problem is that Height of TextBox.
I am trying this kind of code :
var text = new fabric.Textbox("this is text", {
top: 0,
left: 0,
width: 300,
height: 500,
fill: 'red'
})
canvas.add(text);
Now my Textbox is rendered of width: 300 but height is not rendered. how can I set Height to My TextBox
And another Thing, when I set Height to TextBox, I need to keep text in Center of height (vertical center)
what should I do, I can't understand, how to override default fabtic.Textbox class.
Please help me, If any one have Any suggestion.

How to get horizontal padding in Photoswipe?

I'm using photoswipe with disabled zoom, like suggested here, but also want to avoid very landscapish images to reach beneath the prev/next arrows. Is there an easy way to achieve this?
Just found a solution, by
1) giving "padding" to the .pswp__item, like so:
.pswp__item {
left: 50px;
right: 50px;
}
2) updating the horizontal viewport size before resize:
pswp.listen('beforeResize', function(){
pswp.viewportSize.x = pswp.viewportSize.x - 100;
);
I can't comment on #johjoh's answer, so I'm going to copy it here and add the 3rd step required to get this working if you are using PhotoSwipe's getThumbBoundsFn.
1) giving "padding" to the .pswp__item, like so:
.pswp__item {
left: 50px;
right: 50px;
}
2) updating the horizontal viewport size before resize:
pswp.listen('beforeResize', function(){
pswp.viewportSize.x = pswp.viewportSize.x - 100;
);
3) Ensuring the getThumbBoundsFn properly calculates the x value by subtracting one side (50px in this example) from your calculated value:
bounds = {
x: {x} - 50,
y: ...,
w: ...,
}

Flexbox Orientation Change Width / Height Issues

I am attempting to use flexbox to achieve a series of sections that fill 100% width and height of the viewport. This works perfectly on desktop without any issues when resizing the browser window. On mobile however, whenever I change the orientation, the section sizing does not adjust correctly.
I have made a pen of my issue:
http://codepen.io/beefchimi/full/LlInw/
The flexbox css is:
main {
display: flex;
flex-flow: row wrap;
}
section {
display: flex;
flex: 1 0 100%;
height: 100vh;
}
article {
margin: auto;
}
I believe my implementation is correct... but I'm very surprised to see iOS not behaving as expected. Any suggestions on solving this problem?
Thanks!
Turns out this is an iOS 6 - 7 bug. More information can be found here:
https://github.com/scottjehl/Device-Bugs/issues/36
The github issue thread suggests a js plugin:
https://github.com/rodneyrehm/viewport-units-buggyfill
For my particular case, I simply implemented my own bit of jQuery that will measure the window height on window load, apply that value to all sections, then track the window height during window resize and reapply. An unfortunate work around :(
var $window = $(window),
$sections = $('section'),
windowHeight;
function adjustHeight() {
// get height of browser window on page load and resize events
windowHeight = $window.height();
// apply windowHeight to each <section>
$sections.height(windowHeight);
}
$window.resize(function() {
adjustHeight();
});
$window.load(function() {
adjustHeight();
});

Titanium: UI.Slider in horizontal layout

I have 4 objects in a view with a horizontal layout in this order:
label
slider
label
button
labels and button are set to Ti.UI.SIZE and slider is set to Ti.UI.FILL
I am basically making my own video controls so
currentTimeLabel, slider, totalTimeLabel, playPauseButton
My issue is when I set the slider to FILL it fills the parent (which it should do I suppose) and pushes the 2nd label and button to a new line.
I need all 4 items on the same line. I've tried turning horizontalWrap to false on the parent view, but that just makes it so I cannot see the remaining two items.
The reason I am not using static widths is I need this slider to adjust its width based off the phone being in portrait and landscape modes.
If I use SIZE instead of fill, the slider basically has 0 width.
My simplified code is below:
var win = Ti.UI.currentWindow;
var transportBg = Ti.UI.createView({
bottom:0,
height:50,
width:'100%',
backgroundColor:'#50000000'
});
win.add(transportBg);
var transportControls = Ti.UI.createView({
layout:'horizontal',
width:'100%'
});
transportBg.add(transportControls);
var currentTimeText = Ti.UI.createLabel({
left:25,
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
text: '0:00',
color:'#fff',
font: {
fontSize: 10
},
shadowColor: '#000',
shadowOffset: {x:0, y:1}
});
var transport = Titanium.UI.createSlider({
min:0,
max:100,
value:0,
width:Ti.UI.FILL,
backgroundColor:'red'
});
var totalTimeText = Ti.UI.createLabel({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
text: '0:00',
textAlign: Ti.UI.TEXT_ALIGNMENT_RIGHT,
color:'#fff',
font: {
fontSize: 10
},
shadowColor: '#000',
shadowOffset: {x:0, y:1}
});
var playPauseBtn = Ti.UI.createButton({
backgroundImage:'/images/pause.png',
width:Ti.UI.SIZE,
height:Ti.UI.SIZE
});
transportControls.add(currentTimeText);
transportControls.add(transport);
transportControls.add(totalTimeText);
transportControls.add(playPauseBtn);
And a screen shot of the current layout
In your case horizontal layout isn't very helpful and best effects can be achieved with absolute layout and setting left, right properties. The only problem which you have is that you have to make sure how much space you have to leave on both sides of slider.
Here are changes to your code which I've made:
var transportControls = Ti.UI.createView();
Removed width and layout property
var transport = Titanium.UI.createSlider({
left: 50,
right: 70,
…
});
Removed width property and set left/right property.
var totalTimeText = Ti.UI.createLabel({
right: 40,
…
});
var playPauseBtn = Ti.UI.createButton({
right: 0,
…
});
Add right property.

Resources