Copy link to clipboard
Copied
Hello together,
I need to print my PDF Document via JavaScript.
These are my printParams which I use and which works very well:
pp.interactive = pp.constants.interactionLevel.silent;
pp.firstPage = 0;
pp.lastPage = 0;
pp.pageHandling = pp.constants.handling.fit;
pp.nUpAutoRotate = true;
Is there any possible Java Code which makes it possible to rotate my print page from vertical to horizonal?
I tried everything could you please help me?
Best regards
OK, pretty much everything there is wrong.
Use this code:
this.setPageRotations(0,0,90);
this.print({
bUI:true,
nStart:0,
nEnd:0,
bShrinkToFit:true
});
Copy link to clipboard
Copied
See the setPageRotations parameter explained below:
nRotate (optional) The amount of rotation that should be applied to the target pages. Can be 0, 90, 180, or 270. The default is 0. Example Rotate pages 0 through 10 of the current document.
this.setPageRotations(0, 10, 90);
You can read more about it in the Adobe Acrobat SDK JavaScript API JavaScript for Acrobat API Reference, setPageTabOrder, page 342
Copy link to clipboard
Copied
Hello,
thanks for yout idea. I tried your code and different variations of it but it doesnt work. I will show you what I have done. I run the following script:
this.print({
bUI:true,
nStart:0,
nEnd:0,
bShrinkToFit:true
setPageRotations:(0,10,90)
})
but the print option(look at my screenshot) does not switch to horizontal (yellow marked area). I need to turn ON the yellow marked option by javascript.
Thankyou and Best regards
Copy link to clipboard
Copied
setPageRotations has nothing to do with the print command. It's its own command to rotate the pages.
You should use the code provided by ls_rbls, before calling the print command (and after, if you want to rotate the pages back to their original views).
Copy link to clipboard
Copied
Okay thanks, I tried to do it befor printing, but it also doesnt work.
Thats my code:
//___________________________________first run
this.setPageRotations(0, 10, 90);
TypeError: Ungültiger Argumenttyp.
Doc.setPageRotations:1:Console undefined:Exec
===> Parameter nEnd.
undefined
//__________________________________second run
nStart:0;
nEnd:0;
setPageRotations:(0,10,90);
Copy link to clipboard
Copied
How many pages are there in your file?
Copy link to clipboard
Copied
9 Pages , I tried also (0,9,90).
Copy link to clipboard
Copied
Page numbers in JS are zero-based, so use 8, not 9.
Copy link to clipboard
Copied
Yes in JS it is zero based, right. I also tried to use 8 not 9.
But same it does not work.
Its very frustrating because its an easy requirement in my opinion. :(((
Copy link to clipboard
Copied
Post your exact code and the error message you're getting.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK, pretty much everything there is wrong.
Use this code:
this.setPageRotations(0,0,90);
this.print({
bUI:true,
nStart:0,
nEnd:0,
bShrinkToFit:true
});
Copy link to clipboard
Copied
And if you want it to work with a file of any length, use this:
this.setPageRotations(0,this.numPages-1,90);
this.print({
bUI:true,
nStart:0,
nEnd:this.numPages-1,
bShrinkToFit:true
});