Printing a Collection in N columns
I am trying to write a class that takes a Collection of Objects and prints them in a specified number of columns. However, it never works. All that ever prints is a blank page. Here's my code:
import java.awt.print.*;
import java.util.*;
import java.awt.*;
public class PrintList implements Printable{
private Vector list;
private int index=0,col;
public PrintList(Collection v,int c){
list=new Vector(v);
col=c;
public int print(Graphics g, PageFormat pf, int pi)throws PrinterException{
Graphics2D g2=(Graphics2D)g; // Calculate graphics dimensions
int height=g2.getFontMetrics().getHeight();
int width=(int)pf.getImageableWidth();
double lines=Math.floor(pf.getImageableHeight()/height);
double pages=Math.ceil(list.size()/lines/col);
if(pi>=pages){
index=0;
return Printable.NO_SUCH_PAGE;
g2.translate(pf.getImageableX(),pf.getImageableY());
for(int i=1;i<=lines && index<list.size();i++){
for(int j=0;j<col && index<list.size();j++){
String text=list.get(index).toString();
g2.drawString(text,j*width/col,i*height);
if(j==col-1) text+='\n'; // Format text to display what
else text+='\t'; // should be printed
System.out.print(text);
index++;
return Printable.PAGE_EXISTS;
public static void main(String[] args){ // args[0] = # of items in test list
try{ // args[1] = # of columns
int size=Integer.parseInt(args[0]);
int cols=Integer.parseInt(args[1]);
Vector list=new Vector();
for(int i=0;i<size;i++)
list.add(new Integer(i));
PrintList plist=new PrintList(list,cols);
PrinterJob printer=PrinterJob.getPrinterJob();
printer.setPrintable(plist);
printer.print();
}catch(Exception e){
e.printStackTrace();
}I'm using JDK 1.4.1_01 if that's important. Any help would be appreciated.
Ben
Your code is ok except for the for-loop in print() where you calculate the (x,y) co-ordinates. Just comment your for-loop and try with this:
g2.drawString("Testing..",50,50);
Now, you should be able to print.
So, work more on your for-loop.
iDriZ.
Similar Messages
-
When we try to print coupons or articles only the left half of the page prints in a 2 inch column in the middle of the page. This started when I downloaded the latest version of Firefox. When we print from Internet Express, everything prints fine.
Check your margin settings.
Type '''about:config''' in the URL bar and hit Enter.
''If you see the warning, you can confirm that you want to access that page.''
Filter = ''margin'' - then look at the left and right margin settings for any that look grossly incorrect - the setting is in inches. Some users with that problem have reported settings like 2.7235879 - IOW a very long numeric string after the decimal point.
Right-click the Value and select Reset or Modify. 0.5 or 0.25 are appropriate settings if you elect to Modify. -
Pass a Collection of multi-column records from JAVA to Plsql
Hi,
I need to pass a Collection of multi-column records(say Employee Id, Employee Name and Employee Address) from a JAVA application to an Oracle package/stored procedure
for data processing and updates.
I initially thought of using a pl/sql table as an input parameter, but then I came to know that a pl/sql table can have ONLY one column and an index (can be a String in
the case of an Associative Array). Please let me know if my understanding is wrong here.
I then thought of using a PL/SQL table with a RECORD type as an element. But, I came across a documentation that says that, Oracle JDBC does not support RAW, DATE, and PL/SQL RECORD as element types.
Could you please let me know how I can pass multi-column records from JAVA to an Oracle Stored procedure as an input parameter? Millions of rows would be sent by the JAVA program to the Oracle Stored procedure.
Any help will be highly appreciated.
Regards,
Sunil.There are several examples in the " Working with Oracle Collections" from the "JDBC Developer's Guide and Reference". You can either use a Map to create Java objects that are created with the Oracle objects data or the generic oracle.sql.STRUCT interface.
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm#1047581
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraoot.htm#1039477 -
Printing the totals of 1 column under another column
Hi all,
I have an internal table with 3 fields A, B, C .
I want to print the subtotal of the column 'C' under the column 'A'.
eg:
Material_Group Matnr Cost
MG1 M1 C1
MG1 M2 C2
(C1 + C2)
(This should come under the column "Material_Group" instead of the column "Cost" )
Hope that the requirement is clear. Please help me out in this ..
Thanking you in advance,
Shankara Narayanan T.VHi,
Please use the 'At New' command to get the new material group. take the sum in a variable and use the write statement as shown below.
Write:/ sum under 'Material_group'
Thanks,
Ajith V -
I am looking for a print data collection tool similar to PrintSolv or FleetPrint for PC environments. The target environment is 100% Apple computers (Servers, desktops & Laptops) and primarily HP & Epson printers. We could introduce a PC to the environment to perform the print data collection on network printers but neither PrintSolv or FleetPrint have a Mac agent to collect data from direct attached printers.
Thank you for your help.Look into PrintCapture. I managed it at a client a few years ago, so don't know how well it works with Intel/10.5, but it worked pretty well on Tiger/PPC - the client was able to collate print numbers and bill their clients from the information.
Matt -
Printing of collective invoice
Hi Gurus,
I have a list of sales orders grouped by individual customer account which need to be consolidated into one invoice per customer account.
I process them on VF04, sort into account number, highlight all the sales orders in the customer account and click on "collective billing doc" which is correct.
However, these invoices are not required for the customer, the billing run is necessary to enable a monthly "manual" invoice to be sent to the customer.
It seems to me that running off these consolidated invoices and then throwing them in the bin is a waste of resource.
Is it possible to do the billing run without generating the paperwork?
I would be grateful for your help with this.
Thanks & Regards
BawaHi,
In transaction code VV32, in the billing output type, in the Dispatch time column you can select the value 1- Send with periodically scheudled job.
By this way, it wont print the invoice but keep it in the spool. Whenever the user needs, it can be printed by using transaction code SP01.
Alternatively, check with your basis person, whether any dummy printer is configured in your system. This printer should be locked (you can verify this using transaction code SPAD). Use this dummy printer name in the VV32 transaction code. This also avoids printing of the invoices.
Regards, -
How to Print a report with 50 columns. Crystal Reports
Dear Experts,
I'm Using Crystal Reports 2008. I have a requirement that 50 columns should be placed in a Single Report with single line . But Page size should be A4 ( While Printing).
With Page Size A4 I'm able to place 5 columns.
Is there any possibility to acheave this no matter if number of opages increases
I Appreciate for the help in this regard.
But I need to display all the 50 fields (columns) in a single report.
I Achieved this by changing horizontal width to 70.
I can Place all the fields in one line.
But my concern is to print this report in A4 Paper I think its horizontal width will be 11. from crystal reports itself
I don't want to use cross tabs nor even use sql expression. Its just a simple display report for all the employees.
is there any simple way out to Achieve this by paging... or any other method.
Any help regarding this issue will be appreciated.
ThanksHi:
I'm not a expert in crystal report, but I would like help you, i don't understand if must to show 50 diferrents fields in your report or same field through 50 columns ? for exemple:
first case: You ned diferents fields
F1 F2 F3 ... F50
item1 F1 Item1 F2 Item1 F3 Item F50
item2 F1 Ite21 F2 Item2 F3 Item F50
In this case you must put the 50 fields in the report, just enough small to fit page
second case: You nedd the same field in 50 columns
Colum 1 Colum2 Column 50
item 0 item 11 item 490
item 1 item 12 item 491
item 2 item 13 item492
item 10 item 20 item 500
inm this case i haven't idea how to make it (sorry)
Edited by: Wgramirez on May 29, 2010 7:01 PM -
How do i take GR print out in a continuous pages? currently i am able to take line itm by line item only which is cumbersome as my GR docuement has 12 line items I do not want 12 documents to be printed instead it should come in 1 or 2 pages like a normal Po print out.
regards
samuel mendisHi,
While doing MIGO, choose 'Collective slip' at Printing tab.
This will solve your problem.
regards -
Print Report to PDF with columns vertical instead of horizontal
I enabled report printing for a report region but the PDF lists the columns horizontally even though the columns are listed vertically on the report page. Is there a way to list the columns vertically on the PDF so that it matches the layout on the report page. Thanks for your help.
Hi hhsu68
Wondering how you are arranging columns listed vertically on the report page?
You mean just selecting any vertical report template, or
you mean just column headers are vertical and the data as normal (horizontal)?
If its the second case could you please let me know how you did that?
Off course I would also like to know if you have found a solution to your problem as well.
Thank you
Ligon -
When using Appleworks database for printing labels can I have columns of different widths?
When using Appleworks database for printing labels can I have a column of different width?
Case in point, the supplied avery labels in Appleworks does not have 8195. When I build one using custom design I need a small column between column 2 and 3 to line up the info in columns 3 and 4. All the labels are 1.3/4 inch wide but I need to insert a column 1/4 wide to match up with the avery page....
Any ideas???
Thanks......
---warrenWell, the issue is that when you creat a custom width of 1.3/4 from the edge of the first label to the edge of label 2 all is good. The right and left margins were also set correct in AW. The Avery page, for some reason, has a small 1/4 inch column between the columns of label 2 and 3 therefore making the distance between the left edge of the label in column 2 and the right edge of the label in column 3 - a width of 2 inches and not 1.3/4.
I guess Avery wanted the page to look even.
I did this work around.....
I created a custom lay out of 2 columns (not 4) with the correct width of 1.3/4 from label edge to label edge and the correct left side margin. After printing the first page I just turned the sheet 180 degress and printed the 2nd page to use all the labels on the Avery sheet. Since the upper and lower margin were the same it worked great....
"Great minds think alike"... thanks for your suggetion -
Printing the Collective Stock/Requirements List
Hey All,
I'm trying to print out the collective stock/requirements list via the menu path "System -> List -> Save -> Local File" but it is shaded out and i cannot do this, just like SD variants are needed to be maintained in own data for the report VA05 so that layouts can be saved, do we also need some such varient maintained in own data to access this option ?
Best Regards.Dear Danish,
After executing the Stock/Requirements List in MD04,in the top menu List -
> variable print --->From
here you can download into a spread sheet or as a local file or as a word processing.
Or else you can print from here.
Now come back with your further queries.
Dear Vivek, MDLD is to print out the MRP list (which is a static one and stock/requirements list is a
dynamic one).
Regards
Mangalraj.S -
On SSRS Export or Print, Select the first 9 columns out of 15 columns
Hello Every1,
My Greetings for the day!!!
I am Hiren Parikh from India.
I am developing a SSRS report (Tablix) which has 15 columns. While developing the report, I have come a crossed a strange requirement.
When the reports gets loaded in SSRS Preview or in Sharepoint, it should display all the 15 columns.
However, if the user exports the same report or print the report in that case only the first 9 (columns 1 to 9)should come and the remaining 6 (columns 10 to 15) should not come in the print or export.
I request you all to suggest me.
Thanks in advance.
Regards,
Hiren Parikh.
Hiren ParikhHi Hiren Parikh,
Per my understanding that you want to hide the remaining 6 columns when print or export the report but display all the column when view in Sharepoint, right?
I have tested on my local environment and if your SQL Server version is 2008 R2 or higher, you can take reference as the method below:
This method is use the expression to show/hide the 6 columns in the report, when you print/ export the report it will hide, only when you preview in the designer or view the report in the server you can see all the columns
Details information below for your reference:
Check the entire column and right click the column to select the "Column Visibility"
Check the "Visibility" on the left pane and check the "Show or hide base on an Expression"
Expression:
=iif(Globals!RenderFormat.IsInteractive,False,True)
Repeat the step1 and step2 to hide the other columns.
If your version is SSRS 2008 and older, you can create a Parameter name 'Display or Print' and can give 2 values one Display and another Print.
Create two tablix: one have 15 columns (Tablix1)and another 9 columns (Tablix2)and when choose "Display" show the tablix1 and hide the tablix2 and when select the "Print" hide the tablix1 and show the tablix2.
If you have any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
ALV printed in batch with fixed columns
Hi,
I am trying to print an ALV List report in a batch job. Fixed column widths and a filter on the layout was a requirement, so I have a layout variant as part of the initial selection screen and my batch variant.
When I print online, it looks great. When I print through batch, the font is much bigger and the rows wrap. Is there a way to print using a layout variant for ALV list in batch?
Thanks!Hi,
When you execute an ALV List through a Job, the Output Settings are determined by the Printer settings that are set for the Output device that you have selected while creating the backgorund job. so i suggest you will have to look at those settings and make the changes occordingly or change the output device that you select.
regards,
Mahesh -
Bulk Collect for Uncertain columns
Hi Experts,
how to use bulk collect for uncertain number of columns of select statement.
Master table structure:
Create table tabmst
(id number,
cls_input varchar2(2000),
price number);
insert into tabmst(1,'select product, prod_price from product',500);
insert into tabmst(2,'select product, prod_price,purchase_dt from product',100);
insert into tabmst(3,'select * from product',1000);
Currently I want to store Select statement of cls_input column in a local variable like
dyn_qry:= cls_input; by using a cursor.
Now my question is how to use Bulk Collect by using "Execute Immediate" in Bulk collect variable as there is not certainity of the number of columns from "Select Statment". Please suggest.
Sample code:
I created TYPE variable for Bulk Collect also support blk_var;
Declare
dyn_qry varchar2(3000);
v_id number;
v_prod_price number;
v_product number;
cursor c1 is select * from tabmst;
begin
for i in c1 loop
v_id:=i.id;
dyn_qry:= i.cls_input;
Execute immediate dyn_qry into blk_var;
(Here I want to store the columns values from "blk_var" in local variables "v_prod_price" ; "v_product" ;. But it is uncertains of the columns of "Select statement")
End Loop;
End;
Now I want to store values of Each "Select statements columns" which is executing by dynamic SQL. but it is uncertain that how many columns will return from dynamic SQL.
Please suggest the approach on the same. Thanks in advance.Hi,
please do not post duplicated questions. Close (marking as answered and putting a note) your other thread regarding the same topic: {message:id=10890093}.
Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
Regards.
Al -
Using a Print Style Sheet to hide columns in a report
Hello there,
I am curious to know whether it is possible to hide certain columns in reports using a print style sheet.
I tried using the 'CSS Class' attribute when editing column formatting but it appears to be completely ignored and simply overwritten with the theme's default CSS Class for a report table cell (t15data in my case).
Any help would be greatly appreciated...
Cheers,
JordanHi Jordan,
Perhaps the simplest thing would be to change your page template (or, more probably, take a copy of the one you are using and edit that instead).
Add id="#COLUMN_HEADER_NAME#" into the TH and TD tags for the Column Heading Template and all of the Column Templates.
Then, in the Region Header of the region containing the report (or anywhere above the region), enter in:
<style type="text/css" media="print">
#ID_OF_COLUMN_TO_HIDE {display:none}
>/style>
I have not tested this to see if it impacts on any other page functionality, but it does do what you need - ie, the column appears on screen but not on a printout.
Regards
Andy
Maybe you are looking for
-
SAP (ECC 6.0) - Erro de rejeição (Engrenagem)
Boa tarde a todos, Gostaria de compartilhar um cenário de erro ocorrido no ambiente de produção do cliente (pós-GoLive) onde implementamos recentemente Nota Fiscal Eletrônica. Para um determinado cenário enviado para SEFAZ/SP foi retornado o código d
-
When is a topic considered to be "old" and no longer meant for new posting?
I decided to make this a topic, so hopefully future posters can also benefit from my ignorance. Therefore I sincerely hope that this topic will become a sticky note. Today I was "reprimanded" for posting in thread https://forum-en.msi.com/index.php?t
-
I have ipod 120 classic. I have been using genius on my ipod to create playlists on it.All of a sudden Genius does not show on my ipod or function. Should I reset ipod? Jim34
-
Problem in compiling and running programs in Java3D
Dear Friends, I'm newly installed Java 3D in my c:\ alreadey I'm havind jdk1.3 but java 3D created a new folder namely jdk1.2.2 in c:\. Now I am trying to compile my first program through javac but it couldn't find the libraries. In documentation thi
-
O No: not that bookstore example again!
I've been reading through the forum to find an answer for my problem but using the suggested solutions doesn't seem to work. I have deployed, redeployed, created, destroyed and re-created, all to no avail. I consistently get a message telling me that