Page number resets when new section starts - MigraDoc - pdfsharp

I am using MigraDoc to create a PDF. As per my requirement, I have to add different headers according to the contents of the page\section. I am able to achieve it by adding new section and defining new header for every section. Till here, it works fine.
In footer, I am showing page numbers using "AddPageField". But I realized that whenever a new section starts, page field reset to 1. Is there any way that footer continues the page count across all sections?
If I use only one section throughout the document, then page number continues. But in this case, I can not use different headers.

This appears to be a bug in MigraDoc up to version 1.50 beta 1.
The bug wasn't fixed yet, but it should require a small modification only and I hope it will be corrected with the next release.
I had to change my mind: it is not a bug, it is a feature.
To achieve what the OP wants you have to assign a PageSetup to the first section that sets the StartingNumber and also assign a PageSetup to the second section that does not set the StartingNumber.
If no PageSetup is set for the second section then this section will inherit the PageSetup from the first section and the StartingNumber will be applied to both sections. This is the desired behaviour if each section is e.g. a serial letter.
Here is my testcode (just a code snippet):
var sec1 = document.LastSection;
sec1.PageSetup = document.DefaultPageSetup.Clone();
sec1.PageSetup.StartingNumber = 17;
sec1.Footers.Primary = new HeaderFooter();
var para = sec1.Footers.Primary.AddParagraph();
para.AddPageField();
var sec2 = document.AddSection();
sec2.PageSetup = document.DefaultPageSetup.Clone();
The second section inherits the footer from the first section, but a new PageSetup overrides the StartingNumber.
The Clone() comes handy here.

Related

Change text of PAGE N OF M of mvcgrid.net

I am using mvcgrid.net for showing my information in tables in a mvc project
How ever it is working properly I want to change
Showing 1 to 10 of 27 entries
of footer and
next and previous
texts of grid but I didn't find an API for that , Can anyone help me with this.
I am configuring my Grid as:
GridDefaults gridDefaults = new GridDefaults()
{
RenderingMode = RenderingMode.Controller,
ViewPath = "~/Views/MVCGrid/_Grid.cshtml",
NoResultsMessage = "Sorry, no results were found",
ItemsPerPage = 25,
MaxItemsPerPage = 200
};
and I update the text of anything I need in the _Grid.cshtml file or any custom View I use instead.
Custom Style
To use a custom style for your table, you can implement the IMVCGridRenderingEngine to create your table. Everything you need to populate your table will be given to you in the RenderingModel object. Once you have the implementation, set the property on your grid definition to use your new rendering engine:
gridDef.DefaultRenderingEngine = typeof(CustomHtmlRenderingEngine);
This same method could also be used to create custom export formats.
You can find it from the link.
http://mvcgrid.net/demo/customstyle

How to refresh after changing ValueNumericOptions.Format?

I'm using the DevExpress xtraChart to display some data. In the CustomDrawSeries event, I'm checking the series name and changing SeriesTemplate.Label.PointOptions.ValueNumericOptions.Format. It works... partially.
The idea is to change ValueNumericOptions.Format from NumericFormat.FixedPoint to NumericFormat.Percent and vice versa based on the name. The problem is the change is not displayed immediately. In order to see the change, the user must select another cell and then the change is visible immediately.
How can I force a refresh to the series and see the changes immediately without needing to select another cell?
Update -
After the change is made via code, I inspected Format and it is being set correctly. This confirms, in my mind anyway, this is a refresh issue.
I do not know what the real cause of the problem, but your approach seems to be not quite optimal. You modify the global settings (template) while your goal is just to change settings for a certain series.
What you want to achieve can be done during the ChartControl initialization, without having to handle events. The following code can be used to apply a percent format to a certain series:
DevExpress.XtraChartsPointOptions pointOptions = new DevExpress.XtraChartsPointOptions();
pointOptions.ValueNumericOptions.Format = DevExpress.XtraCharts.NumericFormat.Percent;
DevExpress.XtraCharts.SideBySideBarSeriesLabel label = new DeveExpress.XtraCharts.SideBySideBarSeriesLabel();
label.PointOptions = pointOptions;
DevExpressXtraChartsSeries series = xtraChart1.Series["Series Name"];
series.Label = label;
series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
By the sounds of it you are registering to the Refresh event of the view controller which will change the format of the chart on refresh, assign your code also in the OnViewControlsCreated event to initialize your code upon first creating the view.

How can I always force most recent articles with the exact phrase using Drupal Apache Solr?

I want to find exact phrase results looking anywhere in the body or the title. It has to be ordered from the most recent to oldest. The only way I get pretty close results is by forcing quotes around all my searches via this hook:
/**
* Implements hook_apachesolr_query().
*/
function hcp_node_apachesolr_query_prepare($query) {
// Adding quotes to all searches so it gives an accurate search result
$search_result = $query->getParam('q');
$has_quotes = preg_match('/^(["\']).*\1$/m', $search_result);
if(!$has_quotes) {
$query->replaceParam('q', '"' . $search_result . '"');
}
}
My Bias Settings:
Results Biasing: All are set to ignore but More recently created is set to 10
Type Biasing: All set to ignore
Field Biasing: All set to omit.
This seems to work well with two or three word phrase but if for example I search a whole title of an article it can't find anything.
I tried setting the Title and The full, rendered content field bias to the same thing (21). Again it would show good results but it wouldn't be in most recent order(I think this was pretty close but just wish it displayed most recent first).
I also tried updating my schema.xml: updated WhitespaceTokenizerFactory to KeywordTokenizerFactory but I didn't get good results.
This is how I fixed this:
Installed Apache Solr Term Proximity Module Updated field bias to .3
for both Title and the full rendered content (the rest are set to
omit) Set the term proximity to .1
Set the Most recent created to 10
FYI I tried different settings and this seems like the best.

How can you extend the default behavior of Tridion.Cme.Commands.Open.prototype._execute()?

I have written a GUI extension which adds an additional tab to many of the Item views in the SDL Tridion CME (e.g. Component, Page and Schema etc.). I have also written some JavaScript which loads that tab directly if when the view is loaded with a tab name is specified in the URL.
The result is that if a page is loaded with the tab name added as follows:
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64&tab=InfoTab
Rather than the default of
http://localhost/WebUI/item.aspx?tcm=64#id=tcm:1-48-64
The Info Tab will be loaded on top, instead of the General Tab. This is performed with the following code snippet and works very well:
$evt.addEventHandler($display, "start", onDisplayStarted);
// This callback is called when any view has finished loading
function onDisplayStarted() {
$evt.removeEventHandler($display, "start", onDisplayStarted);
var tabname = $url.getHashParam("tab");
if (tabname != '') {
var tabControl = $controls.getControl($("#MasterTabControl"), "Tridion.Controls.TabControl");
tabControl.selectItem(tabname);
}
}
Now I would like to make a context menu item to open items and link to the tabs using my new functionality. My first thought was to construct the Item URL myself and simply open a new window in my execute method. So I looked at the default functionality in the standard Open.prototype_execute() functionality of the GUI. This is stored in the navigation.js file of the CME, and is performed by the Tridion.Cme.Commands.Open.prototype._execute method. The code is a lot more complicated than I had anticipated as it deals with shared items, and permissions etc.
Rather than just copying all of this code to my own function, I was wondering if there is a way to elegantly extend the existing Open.prototype_execute() function and append my “&tab=MyTab” to the $cme.Popups.OPEN_ITEM_OPTIONS.URL constant for my own functions.
Any advice would be greatly appreciated.
At the end the Open command uses $config.getEditorUrl(item_type) to get the url for the item view (item_type - $const.ItemType.COMPONENT, etc). There are no extension points for this part of the functionality, but you could always try to overwrite it on your own risk.

How to change Drupal input filter behaviour based on output location

I have a Drupal filter module whose output I would like to alter, depending on where the output is going to be displayed. Specifically, I want to the filter to give the full output for nodes, but trim the content down for blocks.
I don't think this would be possible. It's hard enough to figure out what context something is being displayed in. It's doable but quite hard to code on your own. However the way the filter system works I don't think its possible within a filter to determine then context of the text being filtered. It's simply not made for something like that.
I'm the OP (but just registered an account).
I did manage to find a solution/workaround. Here's what I did:
Create block.tpl.php in my module which is a copy from system/block.tpl.php, with a constant added at the top.
Put my template file at the head of the theme registry using hook_theme_registry_alter():
function hook_theme_registry_alter(&$theme_registry) {
// using our own block.tpl.php file.
$theme_registry['block']['template'] = 'block';
$theme_registry['block']['path'] = drupal_get_path('module', 'module_name');
$theme_registry['block']['type'] = 'module';
$theme_registry['block']['theme path'] = drupal_get_path('module', 'module_name');
$theme_registry['block']['theme paths'] = Array();
}
Checked for the constant while constructing the filter output, changing as necessary.
Celebrated the outcome.

Resources