Skip to main content
Participating Frequently
Feb 15, 2021 8:24 AM UTC
Answered

How to print horizonal by using a java script ?

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

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Feb 23, 2021 2:22 PM UTC

In the picture bellow you can see

-my test page

-exact code

-message after executing the code (yellow marked) no error

Thanks!!


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
});

12 replies

ls_rbls
Community Expert
Community Expert
Feb 18, 2021 6:03 AM UTC

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

Translate
Technical Generalist
Participating Frequently
Feb 23, 2021 8:51 AM UTC

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

Translate
try67
Community Expert
Community Expert
Feb 23, 2021 8:56 AM UTC

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).

Translate