Javascript Code to Print Multiple Page Ranges in Acrobat
Hi All,
I am very new to Javascript (used it for the first time this morning) and was looking for some help.
I have built a fillable pdf form in Acrobat that I am required to print on a very regular basis.
However, when I print it, there are only particular pages that I need to print as opposed to the entire document.
I have put in a Print button that executes the below code when pressed:
this.print (true, 1, 25) ;
this.print (true, 27, 28) ;
This allows me to print two different page ranges, but it separates them into two different print jobs.
Is there a code that will allow me to put them into the same print job, so that it selects pages 1-25, 27-28 rather than doing them separately?
I am currently using Adobe Acrobat X Standard.
Any input would be much appreciated.
Thanks!
Acrobat/Reader 11 allows you to use the printRange property of the PrintParams object that's used with the print statement: http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.1013.html
See the sample code included at the link above.
Similar Messages
-
Print multiple page ranges based on radio button group choices
Hi ... I have a PDF that is a combined application form made up of 6 separate forms. On the front page, I have 6 groups of "Yes / No" radio buttons.
If the radio button for one or more of these groups is selected as "Yes" then when the Print button (on the page) is clicked then the appropriate page ranges will print.
It is desireable, though not essential, for these to be printed in one print job.
The Code I have been adjusting to try and achieve the result is below but I have tied myself in knots now and any help would be greatly appreciated:
Many thanks
//<AcroForm>
//<ACRO_source>PrntForms:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:PrntForms:Annot1:MouseUp:Action1 ***********/
var nButton = app.alert({
cMsg: "Your selected forms will be sent to your default printer.\n\nIf you require to print to an alternative printer, press cancel and select 'Print' from the 'File' menu.",
cTitle: "Submit Forms for Printing?",
nIcon: 1, nType: 1
// array for button responses
//var aResponse = new Array("OK", "Cancel");
if(nButton == 1)
{ this.print({ bUI: false, bSilent: true, bShrinkToFit: true, nStart: 1, nEnd: 1 });
} else
if(nButton == 0)
{ this.Exit
var a_app;
if(this.getField("AppForm1”).value=="Yes"){
a_app = "1, 1";
} else a_app = "0, 0"
var b_app;
if(this.getField(“AppForm2”).value=="Yes"){
b_app = "2, 2";
} else b_app = "0, 0"
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.full;
pp.printRange=[[a_app], [b_app]];
this.print(pp);
//</ACRO_script>
//</AcroForm>Hi Gilad D
The 'printRanges.push' function works well on my Mac using Adobe Acrobat Pro XI however when it is used on the systems that the form users will be working on (which runs Adobe Reader 9.4.0.195) the ranges are not pushed to the printer dialogue box and the 'printRange'
in the dialogue is still selecting the 'All Pages' radio button.
Is the printRanges.push function a new and non-backwards-compatible function or is my code the problem
//<AcroForm>
//<ACRO_source>PrntForms:Annot1:MouseUp:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:PrntForms:Annot1:MouseUp:Action1 ***********/
var printRanges = [];
if (this.getField("RBG10").value=="Yes") printRanges.push([0,2]);
if (this.getField("RBG1").value=="Yes") printRanges.push([3,18]);
if (this.getField("RBG2").value=="Yes") printRanges.push([19,27]);
if (this.getField("RBG3").value=="Yes") printRanges.push([28,38]);
if (this.getField("RBG4").value=="Yes") printRanges.push([39,42]);
if (this.getField("RBG5").value=="Yes") printRanges.push([43,54]);
if (this.getField("RBG6").value=="Yes") printRanges.push([14,16]);
if (this.getField("RBG7").value=="Yes") printRanges.push([55,56]);
if (this.getField("RBG8").value=="Yes") printRanges.push([57,65]);
if (this.getField("RBG9").value=="Yes") printRanges.push([66,71]);
if(printRanges.length>0){
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.full;
pp.printRange=printRanges;
this.print(pp);
}else app.alert("No page ranges are selected");
//</ACRO_script>
//</AcroForm>
Any assistance is greatly appreciated.
Many thanks -
Trouble Printing Multiple Pages in Quick Succession - LaserJet P4015x - Networked Printer
Hi,
We are currently experiencing problems printing multiple pages in quick succession. We use a bespoke Microsoft Access Database to run our Sales Order Processing. As part of this software we print 3 part invoices, credit notes etc on different coloured paper. We do this by printing to different printer trays. Originally we tried automating the printer tray configuration through VBA code using one report and changing the print tray as part of the print process but were having problems with Microsoft Access freezing. As result we have resorted to printing 3 different reports straight after each other (using VBA code) but with each report specified to print from a different tray.
We are current using tray 2 (500 sheet feeder - standard A4 paper), tray 3 (500 sheet feeder - standard A4 paper) & tray 4 (500 sheet feeder - standard A4 paper).
The current setup does print a copy from each tray and does give us what we want apart from the whole print process being very slow.
The first page comes out from tray 2 at the normal speed you would expect from a network printer but then we start to have issues.
Sometimes the second page from tray 3 will come out quickly but the third page (from tray 4) will be very slow or both pages 2 & 3 will be slow to print. There seems to be no pattern as to why these are slow. To make matters even worse sometimes it will print correctly and all three pages come out in very quick succession (although rarely).
We are using modern PC's (running Windows XP SP 3 with 2GB RAM & 160GB HDD) and the print command is definately being sent to the printer in quick succession - as far as I can tell. I have tried to setting the printers to print through the server and setting them up to print directly to the printer using the built in print server in P4015x.
The printers are networked to a Windows SBS 2008 server with quad core processors and 16GB RAM. The server is only used as a file and print server and is not under heavy load.
I will also point out that I have tried printing to another HP printer (4250dtn) and it has exactly the same problems.
I have removed advanced printing features from the printer driver setup on the client PC's but it does not seem to make any difference. I have also tried printing directly to the printer rather than spooling.
I have updated the drivers to the latest one on the HP website and still no change.
I would appreciate any ideas any one might have to sort the problem out.Did you ever solve this?
I'm doing the exact same thing: three print outs in succession to a specific tray on a network shared printer and occasionally getting a MS Access printing error 2212 counldn't print you object. Printer setup is saved with the reports one for each printer tray.
I'm printing from bespoke MS Access 2002 application using runtime to HP LJ 4100 on Citrix terminal server session.
Any info you have would be appreciated. -
How to print multiple pages in single spool in smartforms
Hi all,
I have a issue on to print multiple pages in single spool,i can able to print multiple pages in multiple spool .I am doing Check Print smartforms in that i need to print Multiple pages in single spool.Currently i am using the below code please help to solve this issue.
IF gv_tabix = 1.
lwa_outp_option-tdnewid = 'X'.
ELSE.
lwa_outp_option-tdnewid = ' '.
ENDIF.
Thanks,
DeesanthHi
TABLES: spfli.
DATA:
t_spfli type STANDARD TABLE OF spfli.
DATA:
fs_spfli TYPE spfli.
DATA:
w_form TYPE tdsfname,
w_flag TYPE i,
f_nam TYPE rs38l_fnam,
w_input TYPE ssfcompin,
w_control TYPE ssfctrlop.
SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME.
SELECT-OPTIONS s_carrid FOR spfli-carrid.
SELECTION-SCREEN END OF BLOCK blk .
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME.
PARAMETERS:
p_single RADIOBUTTON GROUP rad1,
p_ind RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK block1.
START-OF-SELECTION.
PERFORM display_data.
PERFORM ssf_function_module_name.
PERFORM spool_request.
*& Form display_data
* text
* --> p1 text
* <-- p2 text
FORM display_data .
SELECT * FROM spfli INTO TABLE t_spfli WHERE carrid IN s_carrid.
ENDFORM. " display_data
*& Form ssf_function_module_name
* text
* --> p1 text
* <-- p2 text
FORM ssf_function_module_name .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = ' '
IMPORTING fm_name = f_nam
EXCEPTIONS no_form = 1
no_function_module = 2.
* IF sy-subrc NE 0.
* MESSAGE 'Form cannot be displayed' TYPE 'E' .
* ENDIF. " IF sy-subrc eq 0
ENDFORM. " ssf_function_module_name
*& Form spool_request
* text
* --> p1 text
* <-- p2 text
FORM spool_request .
w_input-dialog = 'X'.
CALL FUNCTION 'SSFCOMP_OPEN'
EXPORTING input = w_input
EXCEPTIONS error = 1.
*" LOOP AT t_spfli .....................................................
LOOP AT t_spfli INTO fs_spfli.
w_control-no_open = ' '.
w_control-no_close = ' '.
*"Single spool request..................................................
IF p_single EQ 'X'.
w_control-no_open = 'X'.
w_control-no_close = 'X'.
ELSE.
*"Individual spool request.............................................
IF w_flag NE '1'.
w_control-no_open = 'X'.
w_control-no_close = ' '.
w_flag = 1.
CALL FUNCTION ' '
EXPORTING control_parameters = w_control
fs_spfli = fs_spfli
EXCEPTIONS formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4.
endif. " IF w_flag ne '1'
ENDIF. " IF p_single eq 'X'.
CALL FUNCTION ' '
EXPORTING
control_parameters = w_control
fs_spfli = fs_spfli
EXCEPTIONS formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4.
ENDLOOP. " LOOP at t_spfli into ...
*&This function module close the spool request *
CALL FUNCTION 'SSFCOMP_CLOSE'
EXCEPTIONS error = 1.
ENDFORM. " spool_request
Regards,
Sravanthi -
I am unable print multiple pages after I upgraded Acrobat 8 Professional. Worked fine with Acrobat 7. I receive a pictwpstops stopped with status 1 message.
G4 iMac
1.5 GByte Ram
Tiger with latest updates
Adobe CS2 with latest updates and Acrobat 8
Brother MFC-5840CN printer with MFC-5840CN CUPS v1.1 PDD / driver (latest available)
I have removed my local fonts, reset printers, reinstalled printer/PDD files, repaired disk permissions to no avail.
Why is this happening and how do I resolve this? This is our proofing printer.
My CUPS debug output is given below.
*** Job 1 ***
D [04/Feb/2007:08:28:57 -0500] [Job 6] Error: /undefined in YDVGLJ+Times.New.Roman.Bold050*1
D [04/Feb/2007:08:28:57 -0500] [Job 6] Operand stack:
D [04/Feb/2007:08:28:57 -0500] [Job 6]
D [04/Feb/2007:08:28:57 -0500] [Job 6] Execution stack:
D [04/Feb/2007:08:28:57 -0500] [Job 6] %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval--
D [04/Feb/2007:08:28:57 -0500] [Job 6] Dictionary stack:
D [04/Feb/2007:08:28:57 -0500] [Job 6] --dict:1059/1123(ro)(G)-- --dict:1/20(G)-- --dict:83/200(L)-- --dict:120/174(L)-- --dict:54/73(L)-- --dict:212/315(L)-- --dict:72/107(L)-- --dict:0/10(G)-- --dict:0/10(L)-- --dict:2/50(G)-- --dict:56/71(L)--
D [04/Feb/2007:08:28:57 -0500] [Job 6] Current allocation mode is local
D [04/Feb/2007:08:28:57 -0500] [Job 6] Last OS error: 2
D [04/Feb/2007:08:28:57 -0500] [Job 6] ESP Ghostscript 7.05.5: Unrecoverable error, exit code 1
E [04/Feb/2007:08:28:58 -0500] PID 1268 stopped with status 1!
E [04/Feb/2007:08:28:58 -0500] PID 1267 stopped with status 1!
E [04/Feb/2007:08:28:58 -0500] [Job 6] error drawing page 2
E [04/Feb/2007:08:28:58 -0500] [Job 6] pictwpstops - got an error disposing of document = -9783
D [04/Feb/2007:08:28:58 -0500] [Job 6] ERROR during execution of pictwpstops. Error number -9783
*** Job 2 ***
D [04/Feb/2007:00:06:09 -0500] [Job 5] cups->header.Duplex = 0
D [04/Feb/2007:00:06:09 -0500] [Job 5] cups->page = 2
D [04/Feb/2007:00:06:09 -0500] [Job 5] cups->ppd = 0x1103b80
D [04/Feb/2007:00:06:09 -0500] [Job 5] cups->ppd->flip_duplex = 0
D [04/Feb/2007:00:06:09 -0500] [Job 5] width = 4950, height = 6450
D [04/Feb/2007:00:06:09 -0500] [Job 5] PageSize = [ 612 792 ], HWResolution = [ 600 600 ]
D [04/Feb/2007:00:06:09 -0500] [Job 5] HWMargins = [ 9.000 9.000 9.000 9.000 ]
D [04/Feb/2007:00:06:09 -0500] [Job 5] matrix = [ 8.333 0.000 0.000 -8.333 -75.000 6525.000 ]
D [04/Feb/2007:00:06:09 -0500] [Job 5] Contrast_Bright() pdev->dm.dmPrivate.epBrightness = 0
D [04/Feb/2007:00:06:09 -0500] [Job 5] Contrast_Bright() pdev->dm.dmPrivate.epContrast = 0
D [04/Feb/2007:00:06:09 -0500] [Job 5] Error: /undefined in YDVGLE+Helvetica-Bold
D [04/Feb/2007:00:06:09 -0500] [Job 5] Operand stack:
D [04/Feb/2007:00:06:09 -0500] [Job 5] false
D [04/Feb/2007:00:06:09 -0500] [Job 5] Execution stack:
D [04/Feb/2007:00:06:09 -0500] [Job 5] %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval--
D [04/Feb/2007:00:06:09 -0500] [Job 5] Dictionary stack:
D [04/Feb/2007:00:06:09 -0500] [Job 5] --dict:1059/1123(ro)(G)-- --dict:1/20(G)-- --dict:83/200(L)-- --dict:120/174(L)-- --dict:54/73(L)-- --dict:212/315(L)-- --dict:72/107(L)-- --dict:0/10(G)-- --dict:0/10(L)-- --dict:2/50(G)-- --dict:56/71(L)-- --dict:1059/1123(ro)(G)--
D [04/Feb/20> a PDF/X-1a setting has fixed the problem
I still have the problem with more simple kinds of PDF: 150 dpi, no PDFX. I can not print multiple pages.
Furthermore I can not use the option
"print screen view" (in german language), both affects the
Reader 8 AND the Acrobat 8: it always only prints the first page of the document without any scaling.
Finally I can not use the printer
"Adobe PDF": it results in an endless spool action to that printer.
Yesterday Acrobat 8 was deinstalled with the
deinstaller. The
new installation failed first because of a missing CD. The "AdobeExtendScriptToolkit2.0.1All.dmg" could fix the installation problem.
After successfull re-installation neither before nor after the update to Acrobat 8.1.0 the printing errors mentioned above were solved.
What can we try next?
===
OSX 10.4.10., MacPro1.1, Dual-Core, Intel-Xeon
Creative Suite CS2 and CS3
===
Weird hint: None of our three older G4 (10.4.10, CS3+4, Acrobat 8.1.0) has this printing or any other Acrobat problem. - So, is it even hardware related?? -
Flex 1.5 -PRINTING MULTIPLE PAGES
hi,
plz tell me how to print multiple pages in flex 1.5.
i hv used the fillowing function.it works well but sometimes
it HANGS OUT the application.
function doPrintForm() {
var currentScaleX:Number = msgnonvisual.scaleX;
var currentScaleY:Number = msgnonvisual.scaleY;
var currentScaleX1:Number = msgnonvisual1.scaleX;
var currentScaleY1:Number = msgnonvisual1.scaleY;
var currentScaleX2:Number = msgnonvisual2.scaleX;
var currentScaleY2:Number = msgnonvisual2.scaleY;
var currentScaleX3:Number = msgnonvisual3.scaleX;
var currentScaleY3:Number = msgnonvisual3.scaleY;
var currentScaleX4:Number = msgnonvisual4.scaleX;
var currentScaleY4:Number = msgnonvisual4.scaleY;
var currentScaleX5:Number = msgnonvisual5.scaleX;
var currentScaleY5:Number = msgnonvisual5.scaleY;
var currentScaleX6:Number = msgnonvisual6.scaleX;
var currentScaleY6:Number = msgnonvisual6.scaleY;
var tempHeight=msgnonvisual.height;
msgnonvisual.height=800;
msgnonvisual1.height=800;
msgnonvisual2.height=800;
msgnonvisual3.height=800;
msgnonvisual4.height=800;
msgnonvisual5.height=800;
msgnonvisual6.height=800;
msgnonvisual.scaleX=65;
msgnonvisual.scaleY=65;
msgnonvisual1.scaleX=65;
msgnonvisual1.scaleY=65;
msgnonvisual2.scaleX=65;
msgnonvisual2.scaleY=65;
msgnonvisual3.scaleX=65;
msgnonvisual3.scaleY=65;
msgnonvisual4.scaleX=65;
msgnonvisual4.scaleY=65;
msgnonvisual5.scaleX=65;
msgnonvisual5.scaleY=65;
msgnonvisual6.scaleX=65;
msgnonvisual6.scaleY=65;
var msgtext:String=msgta.text;
var printtext:String=msgta.text;
var inxnum:Number;
var actendindex:Number;
var srtindstr:String="";
var countindex:Number=0;
var countpj:Number=1;
//var SS:String="";
var srtidx:Number=0;
var pj_array:Array = new Array();
var pj:PrintJob = new PrintJob();
if(pj.start() != true){
delete pj;
return;
try{
for (var
startpoint:Number=0;startpoint<msgtext.length;startpoint++)
var temp = mx.core.UIObject.useLayoutManager;
inxnum=msgtext.indexOf("'",startpoint);
startpoint=inxnum;
// trace("FLEX ERROR
->>>>>>>>>>----->>>.>>>>>>>.>>>>>>>"+startpoint
pj_array[countindex]=inxnum;
countindex++;
if(countindex%49==0 && countindex>48)//
||(printtext.length-startpoint)<34
var endidx:Number=srtidx+48;
actendindex=pj_array[endidx];
actendindex++;
if(countpj==1)
msgnonvisual.text=printtext.substring(0,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual, {xMin:0,xMax:900,yMin:0,yMax:700});
}else if(countpj==2)
msgnonvisual1.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual1,
{xMin:0,xMax:900,yMin:0,yMax:700});
}else if(countpj==3)
msgnonvisual2.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual2,{xMin:0,xMax:900,yMin:0,yMax:700});
}else if(countpj==4)
msgnonvisual3.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual3,
{xMin:0,xMax:900,yMin:0,yMax:700});
}else if(countpj==5)
msgnonvisual4.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual4,{xMin:0,xMax:900,yMin:0,yMax:700});
}else if(countpj==6)
msgnonvisual5.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual5,
{xMin:0,xMax:900,yMin:0,yMax:700});
srtidx=srtidx+48;
countpj++;
if(countindex > 48)
var arrlen:Number=pj_array.length;
// var lendiff:Number=arrlen-srtidx;
// mx.controls.Alert.show("Length Diff"+lendiff,"CCS");
--arrlen;
var actendindex:Number=pj_array[arrlen];
actendindex++;
msgnonvisual6.text=printtext.substring(pj_array[srtidx]+1,actendindex);
mx.controls.Alert.show(pj_array[srtidx]+"\n"+actendindex,"CCS");
var temp = mx.core.UIObject.useLayoutManager;
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual6,
{xMin:0,xMax:900,yMin:0,yMax:700});
}else
msgnonvisual6.text=printtext;
var temp = mx.core.UIObject.useLayoutManager;
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
//pj.orientation == "landscape";
pj.addPage(msgnonvisual6,
{xMin:0,xMax:900,yMin:0,yMax:700});
pj.send();
}finally
msgnonvisual.height=tempHeight;
msgnonvisual1.height=tempHeight;
msgnonvisual2.height=tempHeight;
msgnonvisual3.height=tempHeight;
msgnonvisual4.height=tempHeight;
msgnonvisual5.height=tempHeight;
msgnonvisual6.height=tempHeight;
var temp = mx.core.UIObject.useLayoutManager;
mx.core.UIObject.useLayoutManager = false;
mx.managers.LayoutManager.updateNow();
mx.core.UIObject.useLayoutManager = temp;
msgnonvisual.text="";
msgnonvisual1.text="";
msgnonvisual2.text="";
msgnonvisual3.text="";
msgnonvisual4.text="";
msgnonvisual5.text="";
msgnonvisual6.text="";
msgnonvisual.scaleX=currentScaleX;
msgnonvisual.scaleY=currentScaleY;
msgnonvisual1.scaleX=currentScaleX1;
msgnonvisual1.scaleY=currentScaleY1;
msgnonvisual2.scaleX=currentScaleX2;
msgnonvisual2.scaleY=currentScaleY2;
msgnonvisual3.scaleX=currentScaleX3;
msgnonvisual3.scaleY=currentScaleY3;
msgnonvisual4.scaleX=currentScaleX4;
msgnonvisual4.scaleY=currentScaleY4;
msgnonvisual5.scaleX=currentScaleX5;
msgnonvisual5.scaleY=currentScaleY5;
msgnonvisual6.scaleX=currentScaleX6;
msgnonvisual6.scaleY=currentScaleY6;
delete pj;
msgnonvisual,msgnonvisual1, msgnonvisual2, msgnonvisual3,
msgnonvisual4,msgnonvisual5,msgnonvisual6 are the non visual
TextArea 's filled at runtime.
can anyone guide me?
thanks in advance!
vinayhv anyone managed to see the code?
-
Printing multiple pages in Java...
I have created a JEditorPane that needs to print multiple pages of html text. I have it printing out the first page but that's it. Also, text that is print out is cut off on the right hand side. Can anyone help me with this? My code is below. I left out the import statements for space.public class
Browser_1 extends JFrame implements ActionListener//, HyperlinkListener
public static void main(String[] args)
new Browser_1("http://www.cnn.com/");
protected JEditorPane htmlViewer;
protected String initialURL;
public Browser_1(String initialURL)
setTitle("Browser_1");
//this.initialURL = initialURL;
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton openButton = new JButton("Open");
openButton.addActionListener(this);
JButton printButton = new JButton("Print");
printButton.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.add(openButton);
buttonPanel.add(printButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
try
htmlViewer = new JEditorPane(initialURL);
htmlViewer.setEditable(false);
htmlViewer.addHyperlinkListener(new _LinkListener());
JScrollPane scrollPane = new JScrollPane(htmlViewer);
getContentPane().add(scrollPane, BorderLayout.CENTER);
catch (IOException ioe)
warnUser("Can't build HTML pane for " + initialURL + ": " + ioe);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = screenSize.width * 8 /10;
int height = screenSize.height * 8/10;
setBounds(width/8, height/8, width, height);
setVisible(true);
//openDocument(new File("./htdocs/index.html"));
private void openDocument(File doc)
try {
htmlViewer.setPage(doc.toURL());
catch(MalformedURLException e)
e.printStackTrace();
catch(IOException e)
e.printStackTrace();
public void actionPerformed(ActionEvent event)
String command = event.getActionCommand();
if(command.equals("Open"))
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new _FileFilter());
if(chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
openDocument(chooser.getSelectedFile());
else if(command.equals("Print"))
PrintUtilities.printComponent(htmlViewer);
private void warnUser(String message)
JOptionPane.showMessageDialog(this, message, "Error", JOptionPane.ERROR_MESSAGE);
// Inner class implements the FileFilter interface for '.html' files
class _FileFilter extends javax.swing.filechooser.FileFilter
public boolean accept(File f)
return(f != null && (f.isDirectory() || f.getName().endsWith(".html")));
public String getDescription()
return("HTML Documents (*.html)");
// Inner class implements the HyperlinkListener interface
class _LinkListener implements HyperlinkListener
public void hyperlinkUpdate(HyperlinkEvent event)
if(event.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
return;
if(event instanceof HTMLFrameHyperlinkEvent)
HTMLDocument doc = (HTMLDocument)htmlViewer.getDocument();
doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent)event);
else
try {htmlViewer.setPage(event.getURL());}
catch(IOException e) {e.printStackTrace();}
class PrintUtilities implements Printable
protected Component componentToBePrinted;
public static void printComponent(Component c)
new PrintUtilities(c).print();
public PrintUtilities(Component componentToBePrinted)
this.componentToBePrinted = componentToBePrinted;
public void print()
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog())
try
{printJob.print();}
catch(PrinterException pe)
{System.out.println("Error printing: " + pe);}
public int print(Graphics g, PageFormat pageFormat, int pageIndex)
double height = pageFormat.getImageableHeight();
double width = pageFormat.getImageableWidth();
int totalNumPages = (int)Math.ceil(componentToBePrinted / height);
if (pageIndex >= totalNumPages)
{ return(NO_SUCH_PAGE); }
else
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
disableDoubleBuffering(componentToBePrinted);
componentToBePrinted.paint(g2d);
enableDoubleBuffering(componentToBePrinted);
return(PAGE_EXISTS);
public static void disableDoubleBuffering(Component c)
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(false);
public static void enableDoubleBuffering(Component c)
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(true);A recent article in JavaPro has a nice solution for this problem. Check out
http://www.fawcette.com/javapro/2002_12/online/print_kgauthier_12_10_02/
It describes a way of using Views to break down the pages. -
Print multiple pages with dynamic data from same movieclip
Hi @ all,
like much of us i have a problem with printjob.
I have a printjob routine, that starts a new job, then
handles the following in a loop for printing multiple pages:
1. update content for every page in a sprite. every loop it's
the same sprite. the sprite is visible on stage
2. addPage to Printjob
after that sends the printjob to the printer
Now the Problem:
On Windows it runs perfectly. On Mac only the last page was
printed. the other pages before are empty (white).
Has anyone a idea?
Thanks for answeres.
Her's my code. As you can see i try to print a table on
multiple pages. In every loop i only show the rows for the actually
printing page:the printview function only updates the content in the sprite
that will be printet on every page.
it generates the rows of a table that will be printed on the
actual page and return if all rows are printed (true or false)
this is a very slim function. there is no time overflow or
sth. like this. -
Simple Statement w/ subreport prints multiple pages
Hello all,
I have a CR 2008 migrated from older version (CRW 32 6,0,1,135 with VB6 driving the report) that is printing multiple pages when it should be only printing 1 page.
This report is a Statement that shows customer info and account balances. It has a subreport that typically prints 1 line of report data on each Statement. However, some customers can have 2 or 3 records printed in the subreport. And in the past this all worked fine - it printed 1 page for the Statement even if there were more than 1 record in the subreport.
After converting to CR 2008 (I did successfully implement SP1 then SP2 after a lot of confusion, then joined this forum - thanks much!) the Statement now prints multiple (identical) pages based on how many records are in the subreport data. I've played with it by testing with customers who had 3 records in the subreport and it generates 3 pages. I've tried modifying the Section control values like "Keep together" and others with no success. We are using VB.Net 2008 now to drive the report.
If anyone has any ideas or suggestions, I really would appreciate your input. I'm not an expert with CR by any means but I have developed about 40 or so reports over the years and have a decent working knowledge.
Thanks for anything you may be able to offer.
ChrisThat's a big jump from CR 6 to 2008.
It may be easier to just rebuild your report from the beginning rather than trying to fix this one.
Typically most update a few versions at a time and the import portion of the code can handle the updating relatively the same version. Cr 2008 is now UNICODE and completely different file format.
Thank you
Don -
Print multiple pages on one page in Preview?
I tried to print a PDF in OSX Lion and I was unable to find the option to print multiple pages on one Page. Instead there is an option to print multiple copies of pages on one page. Does anybody know where I can find the old option from (as in Snow Leopard, Leopard, Tiger..)? (See screenshot.)
Thanks!
roboterLook under the "Vorschau" menu for the Layout menu, and then choose "Seiten pro Blatt."
Hope this helps. -
How do you get rid of white space when you are printing multiple pages to one sheet of paper?
How do you get rid of extra white space when you are printing multiple pages to one sheet of paper? When printing multiple pages to one sheet of paper Acrobat won't let you select the "zoom" for printing.
ThanksTake a look at Quite Imposing.
-
How do I print multiple pages (2) to one A4 page?
Hi folks,
How do I print multiple pages (2) to one A4 page (as you can in a PDF) ?
There is no option when I try to print & I have checked advanced etc. I have tried opening as a PDF. I have tried printing to PDF but it won't allow.
Any ideas or suggestions would be greatly welcomed - I don't fancy printing the whole 188 pages, but I need them all!
Thanks,Hi Chris,
Try this, and if you have any trouble get back and we'll trouble shoot, but I think it will work for you.
Open System Preferences.
Select Print & Scan
Click on your printer under Printers in the left pane
Click "Open Print Queue", on the right
The print queue app will appear on your Dock
Open a Finder window containing your files to be printed and select them all
Drag the files from Finder to Print Queue icon in Dock
Regards,
Jerry -
Print multiple pages on a single page in word or from a PDF
I need to print multiple pages on a single page from a PDF (ie: pages 1 and 2 onto a single page, pages 3 and 4 on a single page etc.)
Does anyone know how to do this? Thanks(near the middle in a pull down menu - if you have the small print window click on the triangle next to the printer name to expand the window
In preview the menu shows "preview" until you open it to see more - and
if you have the small print window click on the triangle next to the printer name to expand the window
LN -
Any way to get more than 100% zoom on print jobs when printing multiple pages?
I know how to increase the size of a print job, when I am printing one page at a time. But when I go to print 2 pages at once (the multiple page print function), there are always large margins around the page. I'm ok with saving paper and printing up two pages, but it seems silly to see small print and wide blank margins. Is there any way to increase the print zoom, when printing multiple pages per sheet of paper?
I once overshot the limit by marking too many photos to fit within 99 pages, but I could never figure out how to fool the application and had to give up trying to add those 14 extra photos.
I asked a friend (who practically lives in Terminal) if he had any way of modifying that limit, but he reminded me that if their printing services are set up to bind books and bill for only 99 pages, fooling the application might be useless if the service only prints me a 99 page book and discards the additional pages.
I can understand that you wouldn't want to let people print 1000 page books, but I sent feedback anyway to allow me to increase the limit. Anyone know of any service that lets you print beyond iPhoto's limits? -
Error in smartform when printing multiple pages
Hi,
I m using a smartform which have two pages in it,
i m able to save and activate it without any error message and when i run the function module generated to chk my smartform
it runs fine and diplays two pages i m using.
but as i m attaching this form with my driver program it is giving an error message while running . the error message is " No other output defined in main window."
Please help me out to resolve the issue.Re: error in smartform when printing multiple pages
dharani tadikonda
Thanks for this answer. It is absolutely correct.
Maybe you are looking for
-
Help, if you can my camera on my iPad 2 is bad ! Very grainy, every scents I updated the picture is bad.
-
What's Wrong with My SLP?
I have posted for login errors: 1. LOGIN-LGNWNT32.DLL-430: The following drive mapping operation could not be completed. [J:=\\ABRAM\BOSS\MAS90\] The error code was 8819. 2. Login-LGNWT32.dll-470: The specified drive mapping is an invalid path. This
-
A few people with activation problems is an understatment
After calling att around 12 times and still no activation. The pay as you go plan is a crock. Att says you have to come into the store to set up a pay as you go plan because you may have to place a deposit.Hmm, lets see. I buy the phone. I would have
-
Change default recover document location in Powershell ISE
Hello I think it is under appdata\Local\Microsoft_Corporation\ and I need to change this to the roaming part of the profile
-
1 java file can trigger one of 2 servlets?
I have a form and a servlet that processes it. but now i have to have the form do something else if the user picks a certain radio button. I thought of having an If statement that would check if the radio button was checked. If it was, I need another