Page number in jsreport - jsreport

Is it possible to display page number in jsreport?
I couldn't find this either on the homepage of the tool nor by googling.
Many thanks in advance!

I assume you ask for page numbers in a pdf report created by phantom-pdf recipe...
You can use special tags {#pageNum} and {#numPages} in template.phantom.header for this:
<div style='text-align:center'>{#pageNum}/{#numPages}</div>
Note you can use also javascript in header/footer to customize visibility or value of the page numbers.
<span id='pageNumber'>{#pageNum}</span>
<script>
var elem = document.getElementById('pageNumber');
if (parseInt(elem.innerHTML) <= 3) {
//hide page numbers for first 3 pages
elem.style.display = 'none';
}
</script>
Documentation here
UPDATE 2022:
jsreport now uses primarily chrome for generating pdf. You can now add page numbers using native headers or in complex cases using pdf utils
pdf utils based header playground example can be found here.

Related

typo3 9.5 - how to get rid of gray header box?

When I use my h1 and h2 styles in a text content element in typo3 9.5, they get nicely displayed as I want.
However when I use the header field of the element, I get this grey box and not my h1 format.
How can I configure typo3 to show h1 style there?
If you use fluid styled content (FSC) or packages which are using FSC (like bootstrap package) you will find the templates of your content elements (CE) in these extensions, from where you can copy it to your site extension and after adding your path to the paths list your modified template is used to render that CE.
This is the typoscript configuration to modify the rendering of the extension bootstrap_package:
lib {
contentElement {
layoutRootPaths {
// 0 = EXT:bootstrap_package/Resources/Private/Layouts/ContentElements/
10 = EXT:my_site_extension/Resources/Private/Layouts/ContentElements/
}
partialRootPaths {
// 0 = EXT:bootstrap_package/Resources/Private/Partials/ContentElements/
10 = EXT:my_site_extension/Resources/Private/Partials/ContentElements/
}
templateRootPaths {
// 0 = EXT:bootstrap_package/Resources/Private/Templates/ContentElements/
10 = EXT:my_site_extension/Resources/Private/Templates/ContentElements/
}
}
}
The entries with 0 = are set by the ext:bootstrap_package (or similar by ext:fluid_styled_content) and show you the path to the templates which are used without your override.
The entries with 10 = (you could use any higher number to give preference to your templates) should show to the folders in your site extension (ext:my_site_extension), where you hold your modified copies.
You only need to copy templates you modify as the original paths are fallback to any template file which is referenced as template, layout or partial. Keep an eye on the paths as those files can be referenced with a (relative) path.
EDIT:
For FSC the rendering for a specific CE is done with a template of the same name in the template folder configured in typoscript (see above)
These files normally contain a call to the same layout file (Layouts/Default.html) which renders the header with the partial Header/All and different other html for spacing and anchors.
In the partial Header/All we have further partials which render the fields header, subheader and date if given with appropriate partials.
Note the additional arguments to these partials: layout, positionClass, link, default which will influence the appearance of the header.
Maybe your unusual appearance is given because there is a special header_layout in your records.
Or another extension already has overwritten the default templates (partials) to get those boxed headers instead of the h1-h6 HTML tags which are used in the FSC extension.

Line being added to top of each page of PDF

I have just noticed that a line is being added to the top of all PDF pages. I am using TcpdfFpdi v2 from setasign and everything else seems to work as expected (bringing in Pdf pages, adding a logo and text)
Code as follows…
use setasign\Fpdi\TcpdfFpdi;
public function test($uuid, $date)
{
$pdf = new TcpdfFpdi();
$pdf->output('test.pdf', 'D');
}
I would expect this to give me a blank page but it is giving me a page with a line across the top (about 1cm down and in from each side).
Setasign tech support have answered this for me…
This is the default behavior of TCPDF (why ever) and you need to explicitly disable the default header and/or footer:
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);

Vue.js with widget js file containing document.write

I know how to load external js files to Vue.js or Nuxt.js but I have a specific problem with eg. french Shom Widget files.
Shom (for tides predictions) give access to a widget via a js file containing a lot of dirty document.write (you can see a sample at https://services.data.shom.fr/hdm/vignette/grande/CAP_FERRET?locale=fr)
var rid="vignette_shom_"+Math.round(Math.random()*10000000);
document.write("<iframe width='675' id='"+rid+"' height='900' frameborder='0' scrolling='no'></iframe>");var ifrm = document.getElementById(rid);ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document:ifrm.contentDocument;ifrm.document.open();
ifrm.document.write('<!DOCTYPE html>');ifrm.document.write('<html>');ifrm.document.write('<head>');
.. ans so on...
Trying to load this script into the mounted method is ok, but i'm unable to display content into component.
Any idea ?
thanks

How to use PDDestination class in PDFbox?

How to use PDDestination class in PDFbox ?
whether getPagenumber() method will return the current page number
can any one share u r views
Thanks
The usage of PDDestination or PDAction is very similar to the one of PdfDestination or PdfAction of iText.
So you may want to search iText examples firstly.
Specifically on PDFBox,
e.g.
the following makes the first open page to page 5.
PDDestination dest = new PDPageDestination();
// When you open this PDF, you will see page 5.
dest.setPageNumber(4)
PDActionGoTo action = new PDActionGoTo();
action.setDestination(dest);
document.getDocumentCatalog().setOpenAction(action);

JUI Autocomplete html-encoded suggestions

jQuery UI starting from version 1.8.4 html-encodes Autocomplete suggestions (according to this issue).
This became a problem for me now. I used to theme the output for the suggestions, but now (if I use version 1.8.4 or higher) Autocomplete just html-encodes my theming. All tags like <b>, <span> are being printed to the user instead of displaying the actual styling.
So the suggestions now look like:
<b>su<b>suggestion
another <b>su<b>suggestion
instead of:
suggestion
another suggesion
I've read about custom data, but I use Yii framework and the output is being generated from certain actions (PHP code).
So, how do I theme the output now?
Thank you!
Better use a HTML plugin
You can use open function from jQuery UI to replace the encoded text.
Here's an example:
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>"bug",
'source'=>$this->createUrl('/autocomplete'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'open'=> 'js:function(event, ui){
$("ul.ui-autocomplete li a").each(function(){
var htmlString = $(this).html().replace(/</g, "<");
htmlString = htmlString.replace(/>/g, ">");
$(this).html(htmlString);
});
}'
),
));