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

Need to print document WITHOUT margins using javascript, please

New Here ,
Mar 16, 2016 Mar 16, 2016

G'day Javascripters.

I really, really need to print without page margins (edge to edge). I'm trying to use Java as the print setter (using Applescript Objective C), and so far it's been successful, but we're getting a 36 point margin around each page, and we want zero on tiled pages.

I'm try to use a java script I found here... remove white margin with javascript (JavaScript) with no success. According to the documentation, margins for printers don't have a setting. I do NOT want to go back to using the GUI with the print dialog, it's much, much slower.

Can anyone tell me please why this does not work? I've tried all sorts of alterations, but just get a 'Can't understand 'do script'' message. Even though I've found the java documentation, I simply don't know what I'm doing!

tell application "Adobe Acrobat"

  activate

  tell page 1 of document 1

  set t to my removePDFMargins

  do script t

  end tell

end tell

on removePDFMargins()

  set Params to ""

  set Params to Params & "function CropPage()" & return

  set Params to Params & "{" & return

  set Params to Params & "console.clear();" & return

  set Params to Params & "console.show();" & return

  set Params to Params & "Media = this.getPageBox(\"" & "Media" & "\");" & return

  set Params to Params & "this.setPageBoxes(\"" & "Media" & "\", 0, 0, Media);" & return

  set Params to Params & "Crop = this.getPageBox(\"" & "Crop" & "\");" & return

  set Params to Params & "this.setPageBoxes(\"" & "Crop" & "\", 0, 0, Crop);" & return

  set Params to Params & "Trim = this.getPageBox(\"" & "Trim" & "\");" & return

  set Params to Params & "this.setPageBoxes(\"" & "Trim" & "\", 0, 0, Trim);" & return

  set Params to Params & "BBox = this.getPageBox(\"" & "BBox" & "\");" & return

  set Params to Params & "this.setPageBoxes(\"" & "Crop" & "\", 0, 0, BBox);" & return

  set Params to Params & "Bleed = this.getPageBox(\"" & "Bleed" & "\");" & return

  set Params to Params & "this.setPageBoxes(\"" & "Bleed" & "\", 0, 0, Bleed);" & return

  set Params to Params & "}" & return

  return Params

end removePDFMargins

TOPICS
Acrobat SDK and JavaScript
1.3K
Translate
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
LEGEND ,
Mar 17, 2016 Mar 17, 2016

Are you able to achieve this - edge to edge printing - from the print dialog? If so, what settings do you choose?

The code you posted has nothing to do with printing.

Translate
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 ,
Mar 17, 2016 Mar 17, 2016

No, not really edge to edge, just very narrow margins, simply by choosing the printer called 'Large Page Printer'.

However, calling this printer from JavaScript adds 1/2" margins for some reason, that's why I thought reducing the margins to 0 might help.

BTW, what is the 'console' and it's role?

Regards

Brian Christmas

Translate
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
LEGEND ,
Mar 17, 2016 Mar 17, 2016

The JavaScript console is for developers to develop and debug scripts to be used within a PDF. It is also possible to create lists in the console using Adobe Reader or Acrobat and then cut and paste the data into other applications.

Translate
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
LEGEND ,
Mar 17, 2016 Mar 17, 2016

Take a look at the Page Scaling option in the print dialog. There is "none" and "fit to page" or similar. See if one of these settings matches the JavaScript printout. If so, we may have something to try. But forget margins. What you see as margins are I suspect something else.

Translate
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 ,
Mar 17, 2016 Mar 17, 2016
LATEST

Thank you both.

The settings I'm using in Javafor the printer are...

on Add_Printer_Parameters()

  set Params to ""

  set Params to Params & "var pp = this.getPrintParams();" & return

  set Params to Params & "pp.printerName = \"" & theLargePagePrinter & "\";" & return

  set Params to Params & "pp.interactive = pp.constants.interactionLevel.automatic;" & return

  set Params to Params & "pp.tileMark = pp.constants.tileMarks.west; " & return

  set Params to Params & "pp.tileOverlap = 36; " & return

  set Params to Params & "pp.tileScale = 1; " & return

  set Params to Params & "pp.tileLarge = true; " & return

  set Params to Params & "pp.nUpAutoRotate=true; " & return

  set Params to Params & "pp.fontPolicy = pp.constants.fontPolicies.everyPage;" & return

  set Params to Params & "pp.useT1Conversion = pp.constants.usages.auto; " & return

  set Params to Params & "fv = pp.constants.flagValues;" & return

  set Params to Params & "pp.flags =  fv.setPageSize; " & return

  set Params to Params & "this.print(pp);" & return

  set javaScript to Params

  return javaScript

  end Add_Printer_Parameters

Translate
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