Change page orientation in script
-
Hello I would like to change the orientation of some pages (random) according to the data that we pass to jsreport.
The purpose is to generate a portrait and landscape document in the same report.thank you in advance for your help
-
You can use pdf utils extension
https://jsreport.net/learn/pdf-utils
https://playground.jsreport.net/w/anon/BkujXYfVG-10
-
Thank you for your quick return that allowed me to test several pdf-utils.
Unfortunately, I can not do what I can, but maybe that's not possible.
I pass the following data and I would like that the generated pdf is with the good formatting according to the data of each page
"pdfData": {
"pages": [
{
"width": 595.2,
"height": 841.8,
"orientation":"portrait"
}, {
"width": 595.2,
"height": 841.8,
"orientation":"landscape"
}, {
"width": 595.2,
"height": 841.8,
"orientation":"portrait"
}
],thank you in advance for your help
-
hmm i think that maybe it is possible to create the pages based on the information you page, however i don't understand what is going to be the content of each page generated.
you can try to prepare an example in the playground https://playground.jsreport.net/ with the data that you are going to use, the template content, etc. and describe how you want it to behave. i will check it and tell you if what you have in mind is possible or not, and in case is possible i will try to prepare an example based on your original one.
-
Hi,
I have similar kind of requirement. Use case is like below:- I have word document having multiple pages with different orientation, some are landscape and some are portrait.
- I am saving this word doc as html and as a result I am getting multiple div in html, each represents page having its own style.
- In header of this html, I have separate style for every page mentioning its orientation as below
<head>
.......
<style>
.....
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.WordSection1
{page:WordSection1;}
@page WordSection2
{size:11.0in 8.5in;
mso-page-orientation:landscape;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.WordSection2
{page:WordSection2;}
@page WordSection3
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.WordSection3
{page:WordSection3;}
</style>
</head>
<body>
<div page1>
<div page2>
<div page3>
</body> - I am feeding this HTML to JsReport as Template and my requirement is to generate corresponding pdf and every page should have orientation as per its respective style mentioned in head/style of html, I mean every page should have orientation as it was in original word document.
Can you please give me some pointers on that?
Thank you in advance for your help
-
@meetvishalt chrome doesn't support the @page styles, you need to use pdf utils for combining page orientations in single pdf. As mentioned previously.
-
Thanks Jan for your pointers, I used PdfOperation in utils and it solved my problem.