Pdfsharp and margins when generating pdf - pdfsharp

I discovered something strange when I added margins to my document.
I am setting the pagesize to A4 (210x297mm) then I am adding left and top margin of 10mm (yes I am sure the calculation to point is right) and bottom and right marigins are 0.
What happens is that the document size of the generated pdf-file is 220x307mm.
What I have to do is, after setting the pagesize and setting the margins, is to recalculate the pagesize.
page.TrimMargins.Top = top;
page.TrimMargins.Left = left;
page.TrimMargins.Bottom = bottom;
page.TrimMargins.Right = right;
page.Height = page.Height - page.TrimMargins.Top - page.TrimMargins.Bottom;
page.Width = page.Width - page.TrimMargins.Left - page.TrimMargins.Right;
I got it working, but is this the way it is supposed to work?
I also tried to set the margins before the page size, but no, it does not work.

I found some internal sample code. It seems adjusting the page size is not required when PDFsharp is used as in the sample.
First the trim margin trim is set for the Setting member of the instance of the PdfDocument class:
pdfDocument.Settings.TrimMargins.All = trim;
Later on, after creating a page, page.Width and page.Height are set without any adjustments.
Note: Using the All member applies the same trim margin to all four sides. It should work the same using individual values for individual sides.

Related

HighCharts Organization Nodes Overlapping

I have a HighCharts organization chart that loads data from our db so it can have a variable number of nodes. I've added
.highcharts-container { overflow: scroll !important; min-width: 100px; }
to my css so that the scrollbars appear and it seems to be growing as needed vertically. However, the nodes overlap horizontally for some reason. I've added
nodePadding: 15
to my js which seems to space them out vertically but doesn't help the horizontal issue. I feel like there should be an option or setting for this, but when I search on overlapping issues, all I get are label issues. Any ideas on how to get my nodes to space out? Thanks!
Here's a jsFiddle which has overlapping data like mine - https://jsfiddle.net/ubmzs5qf/
In case things get unconnected at some point, here's a function given to me by Sebastian here: https://www.highcharts.com/forum/viewtopic.php?f=9&t=42435&p=149331 that handles resizing for the amount of data:
events: {
load() {
let chart = this,
series = chart.series[0],
newWidth = series.options.nodeWidth * series.nodeColumns[2].length;
chart.update({
chart: {
width: newWidth
}
})
}
}
I used this to set both the height and width but it's being overwritten by something, possibly a higher angular limit on dialog size. I think I need a way to space out the icons and make everything small since I can't just make the chart bigger.
You can achieve it by decreasing nodes width eg. nodeWidth: 50.
Demo:
https://jsfiddle.net/BlackLabel/d9cmt0oy/
API reference:
https://api.highcharts.com/highcharts/series.organization.nodeWidth
EDIT
Another way is to decrease `dataLabels font size and set manually the height and offset of each larger node.
Demo:
https://jsfiddle.net/BlackLabel/8om5hc34/1/

UIStackView inside a UICollectionViewCell is out of screen

I'm trying to use a UIStackView in my cell, but I'm with some problems with the constraints.
When I put the constraints in my stack, the whole content go to outside the view. Note in my screenshots:
this first one is the UIStackView without any constraint. Note, the content has a margin of 5.
now, I've set the constraint in my UIStackView. Note that margin right of content doesn't exists anymore. And now its a negative margin.
Obs: the distribution is fill proportionally
Anyone knows what Im doing wrong?
Everything works just fine. Make sure you have added constraints to all other elements.
Inside UIView with margins:

triple caption over image are work bad

I have some problem. I tried to position the title over the image
first title (cat1) can be small or long
second title (cat 2) juste after the first title
third title (after the 2nd title to right)
these title must be on inline
see my demo jsfiddle http://jsfiddle.net/cyphos/jntea/]
thank you for your response
As I understand it, how you accomplish this depends on what you are OK with creating. If you can specify the width of each element, then it isn't a problem to accomplish. You could then simply specify widths for both the left and right elements, then position the center one directly in between. See this fiddle as an example:
CSS only Fiddle
This uses the box-sizing border-box model to simplify things. Read this for clarification
basically:
.cta1 {left:0;width:150px;}
.cta2 {left:150px;right:150px;}
.cta3 {right:0;width:150px;}
OR
if you want these items to be dynamic, you will need to use Javascript/jQuery to get the width of the elements and then set the left and right properties of the center one accordingly. An example in jQuery
jQuery based fiddle
var cat1Width = $('.cat1').width();
cat1Width = cat1Width + 26; //26 being a pixel measure of the padding of the element
$('.cat2').css('left', cat1Width);
With this, you will have to then add the padding values to the cta1Width variable, as jQuery does not return a width value that includes the padding. Either do this manually (by adding the pixel value yourself), or you can also extract the padding width with the jQuery see this thread for info

GWT: Flextable having fixed column size

I need a FlexTable in GWT where I can add items at run time. The FlexTable is inside a ScrollPanel, so that when horizontal content exceeds display area a scroll bar appears.
The problem is when there are 2-3 columns they are spaced widely but as column count increases, the cell takes the minimum required area of 100px.
I need to ensure that Cell always takes 100px only. I have been doing following but no success.
myflextable.getCellFormatter().setWidth(0, col, "100px");
Please try with getFlexCellFormatter().setWidth() method.
Please check also that have you given flextable width to 100%.
The problem may be that the flextable is set to be too wide initially. It will fill the scrollpanel by default, and then as a result the columns will stretch to their maximum width.
You should set the width of the flextable explicitly in the beginning, and it will automatically resize correctly when more columns are added at run time.
Here is an example for when you have initially one row and two 100px columns:
ft = new FlexTable();
ft.addStyleName("flextable");
ft.setWidth("200px");
for (int x = 0; x < 2; x++) {
ft.setText(x, 0, "cell");
ft.getCellFormatter().addStyleName(x, 0, "testcell");
}
scrollpanel.add(ft);
and your css should say this:
.flextable {
table-layout: fixed;
}
.testcell {
width : 100px;
}
Note that the flextable is initially set to 200px width, as we start with two columns.
In the CSS file, the table-layout attribute must be set otherwise the columns will get smaller than 100px as you add more (until the cells reach their minimum width, defined by their content).
Also, remember to add the stylename "testcell" to any new cells that you add at runtime.

How to style nested panel controls in ASP.NET

I have a panel sitting in a div, and I want to use that panel as a container to add more panels! Why would I want to add a panel to a panel? Because the panel that I'm adding to the existing panel, is also made to contain objects, but only and image and label.
The existing master container panel is created during design time, and goes by the lovely name of "toolboxpanel". During run time, I have a for/next loop that dynamically creates an image, a label, adds them both to a panel, then adds that panel to the toolboxpanel, as can be seen here:
For i = 0 To imageholder.Count - 1 'create a control
insertpanel = New Panel 'these object types have been DIM'd up above
insertimage = New Image
inserttext = New Label
inserttext.ID = "text" + partnumberholder(i) + i.ToString 'the "holder" arrays hold the goodies from my db
inserttext.Text = brandholder(i) + " " + partnumberholder(i)
insertimage.ID = "image" + partnumberholder(i) + i.ToString
insertimage.ImageUrl = ".\Images\Display\" + imageholder(i) + ".jpg"
insertpanel.CssClass = "drag" 'this allows the panel to be dragged around using a JQuery script elsewhere
'insertpanel.BackImageUrl = "~\Images\Display\" + imageholder(i) + ".jpg" 'commented out because this method looks awful
insertpanel.ID = "panel" + partnumberholder(i) + i.ToString
insertpanel.Controls.Add(insertimage)
insertpanel.Controls.Add(inserttext)
toolboxpanel.Controls.Add(insertpanel)
Next
The problem is, that each panel I add to the panel gets stuffed into 1 column and totally violates the css rules of the toolboxpanel that say max height is only 700px. It seems to stretch the panel, and the div its sitting in, to way higher than its supposed to be!
My main questions are:
1) How do I get it so I can add panel objects (with my image/label guts) to the main panel in a way where it will display with 3 columns, fixed viewable height, and tidy scroll bar?
2) Is there a better way of doing this? There has to be :(
You can see the current mess on the homepage of: http://www.mobiuspc.com
I appreciate any help!
Bill
You need two things:
A clearfix stylesheet
To float your inner panels
Floating is simple but can sometimes be a bit daunting at first. Read these tutorials on floats to learn all about them.
Essentially, all you need to do is add the following style to your inner panels' styles:
float: left;
Floating will automatically make the div, and all its contents, as narrow as possible, so be sure to specify a width, as you already have.
Next you'll need to apply the clearfix style to your outer panel so that all floating contents inside it don't suffer from the "guillotine effect". Because floating blocks don't have "layout", they're not part of the normal document flow, and therefore, are ignored by their parent containers. The clearfix solves this by forcing the container to recognize floats as having layout.
Panels should usually, but not always, render as div tags, the IDs get borked by the naming container, so easier to add a cssclass attribute.. the set your css accordingly.
If you want overfow to allow for scrolling, you'll want your positioning, and height set to allow for that.
.myContainter {
position: relative; /* or absolute, or a float */
height: 700px;
overflow: auto;
}
should do it. :)

Resources