• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

How to print horizonal by using a java script ?

New Here ,
Feb 15, 2021 Feb 15, 2021

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

TOPICS
Acrobat SDK and JavaScript

Views

390

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 23, 2021 Feb 23, 2021

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

Likes

Translate

Translate
Community Expert ,
Feb 17, 2021 Feb 17, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

How many pages are there in your file?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

9 Pages , I tried also (0,9,90).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Page numbers in JS are zero-based, so use 8, not 9.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

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. :(((

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Post your exact code and the error message you're getting.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

In the picture bellow you can see

-my test page

-exact code

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

Thanks!!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

LATEST

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

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines