Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38790 > unrolled thread
| Started by | antonior0409@gmail.com |
|---|---|
| First post | 2019-03-05 03:39 -0800 |
| Last post | 2019-03-08 14:04 -0800 |
| Articles | 13 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Javax Print : truncated document antonior0409@gmail.com - 2019-03-05 03:39 -0800
Re: Javax Print : truncated document Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2019-03-06 17:22 -0600
Re: Javax Print : truncated document antonior0409@gmail.com - 2019-03-07 03:19 -0800
Re: Javax Print : truncated document Eric Douglas <e.d.programmer@gmail.com> - 2019-03-07 05:14 -0800
Re: Javax Print : truncated document antonior0409@gmail.com - 2019-03-07 05:41 -0800
Re: Javax Print : truncated document Eric Douglas <e.d.programmer@gmail.com> - 2019-03-07 07:16 -0800
Re: Javax Print : truncated document antonior0409@gmail.com - 2019-03-07 09:44 -0800
Re: Javax Print : truncated document Eric Douglas <e.d.programmer@gmail.com> - 2019-03-07 10:06 -0800
Re: Javax Print : truncated document antonior0409@gmail.com - 2019-03-08 10:33 -0800
Re: Javax Print : truncated document Eric Douglas <e.d.programmer@gmail.com> - 2019-03-08 11:34 -0800
Re: Javax Print : truncated document antonior0409@gmail.com - 2019-03-08 12:42 -0800
Re: Javax Print : truncated document Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-03-08 16:13 -0500
Re: Javax Print : truncated document Eric Douglas <e.d.programmer@gmail.com> - 2019-03-08 14:04 -0800
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-05 03:39 -0800 |
| Subject | Javax Print : truncated document |
| Message-ID | <cc5addd3-217e-43e7-843e-114ef28f4993@googlegroups.com> |
Hi,
I'm printing some NA LEGAl document using javax print but (only with java) I get truncated documents due to margin not properly aligned
So I'm trying to modify it but every attempt is ignored
below the used code:
private DocAttributeSet getDocAttributeSet(...) {
OrientationRequested orientationRequested = PageOrientationEnum.LANDSCAPE.name().equals(request.getPageOrientation()) ? OrientationRequested.LANDSCAPE : OrientationRequested.PORTRAIT;
DocAttributeSet docAttributeSet = new HashDocAttributeSet();
docAttributeSet.add(orientationRequested);
int width = Math.round(MediaSize.ISO.A4.getX(MediaSize.MM));
int height = Math.round(MediaSize.ISO.A4.getY(MediaSize.MM));
docAttributeSet.add(new MediaPrintableArea(0, 0, width/72f, height/72f, MediaPrintableArea.MM));
return docAttributeSet;
}
Whats I'm wrong?
Thanks in advance
[toc] | [next] | [standalone]
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Date | 2019-03-06 17:22 -0600 |
| Message-ID | <q5pknm$1t6$1@dont-email.me> |
| In reply to | #38790 |
On 3/5/2019 05:39, antonior0409@gmail.com wrote:
> Hi,
> I'm printing some NA LEGAl document using javax print but (only with java) I get truncated documents due to margin not properly aligned
>
> So I'm trying to modify it but every attempt is ignored
>
> below the used code:
>
>
> private DocAttributeSet getDocAttributeSet(...) {
> OrientationRequested orientationRequested = PageOrientationEnum.LANDSCAPE.name().equals(request.getPageOrientation()) ? OrientationRequested.LANDSCAPE : OrientationRequested.PORTRAIT;
>
> DocAttributeSet docAttributeSet = new HashDocAttributeSet();
> docAttributeSet.add(orientationRequested);
>
>
>
> int width = Math.round(MediaSize.ISO.A4.getX(MediaSize.MM));
> int height = Math.round(MediaSize.ISO.A4.getY(MediaSize.MM));
> docAttributeSet.add(new MediaPrintableArea(0, 0, width/72f, height/72f, MediaPrintableArea.MM));
>
> return docAttributeSet;
> }
>
> Whats I'm wrong?
>
> Thanks in advance
You have to protect the printer margins yourself.
--
Knute Johnson
[toc] | [prev] | [next] | [standalone]
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-07 03:19 -0800 |
| Message-ID | <33a86a7a-f9d6-43ed-ba29-57c049239b25@googlegroups.com> |
| In reply to | #38790 |
Il giorno martedì 5 marzo 2019 12:40:00 UTC+1, antoni...@gmail.com ha scritto:
> Hi,
> I'm printing some NA LEGAl document using javax print but (only with java) I get truncated documents due to margin not properly aligned
>
> So I'm trying to modify it but every attempt is ignored
>
> below the used code:
>
>
> private DocAttributeSet getDocAttributeSet(...) {
> OrientationRequested orientationRequested = PageOrientationEnum.LANDSCAPE.name().equals(request.getPageOrientation()) ? OrientationRequested.LANDSCAPE : OrientationRequested.PORTRAIT;
>
> DocAttributeSet docAttributeSet = new HashDocAttributeSet();
> docAttributeSet.add(orientationRequested);
>
>
>
> int width = Math.round(MediaSize.ISO.A4.getX(MediaSize.MM));
> int height = Math.round(MediaSize.ISO.A4.getY(MediaSize.MM));
> docAttributeSet.add(new MediaPrintableArea(0, 0, width/72f, height/72f, MediaPrintableArea.MM));
>
> return docAttributeSet;
> }
>
> Whats I'm wrong?
>
> Thanks in advance
thanks for reply
How can I do this?
I'm looking for some solution but are still ignored
Is there an example?
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2019-03-07 05:14 -0800 |
| Message-ID | <faad75ca-84ef-4faa-88c8-be455eb278a3@googlegroups.com> |
| In reply to | #38803 |
On Thursday, March 7, 2019 at 6:19:36 AM UTC-5, antoni...@gmail.com wrote: > How can I do this? > I'm looking for some solution but are still ignored > > Is there an example? Your sample code is not complete enough to see your problem. You need to set the printable area to tell it where to print on the page. You can force the margins to anything you want. If you print a custom object, you can implement Printable and/or Pageable and override the print method where you get an instance of the printer's graphics which should have an imageable value set to it's default margins. I'm not clear what you're trying to print, what exactly is cut off, or how you're printing it. Your sample here doesn't print anything.
[toc] | [prev] | [next] | [standalone]
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-07 05:41 -0800 |
| Message-ID | <f147a84a-e9c6-430a-b885-24867d2d4c60@googlegroups.com> |
| In reply to | #38804 |
Il giorno giovedì 7 marzo 2019 14:14:16 UTC+1, Eric Douglas ha scritto: > On Thursday, March 7, 2019 at 6:19:36 AM UTC-5, antoni...@gmail.com wrote: > > How can I do this? > > I'm looking for some solution but are still ignored > > > > Is there an example? > > Your sample code is not complete enough to see your problem. You need to set the printable area to tell it where to print on the page. You can force the margins to anything you want. > If you print a custom object, you can implement Printable and/or Pageable and override the print method where you get an instance of the printer's graphics which should have an imageable value set to it's default margins. > I'm not clear what you're trying to print, what exactly is cut off, or how you're printing it. Your sample here doesn't print anything. I'm printing a PDF as byte array, probably my code is wrong, have you sample code?
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2019-03-07 07:16 -0800 |
| Message-ID | <00af27f5-e9a9-48f6-ab78-c71aa9f9c627@googlegroups.com> |
| In reply to | #38805 |
On Thursday, March 7, 2019 at 8:42:06 AM UTC-5, antoni...@gmail.com wrote: > > I'm printing a PDF as byte array, probably my code is wrong, have you sample code? Have you tried Google? What are you trying to do different? Here's my first search result: https://stackoverflow.com/questions/22607701/print-pdf-as-byte-array-in-java/50141811#50141811
[toc] | [prev] | [next] | [standalone]
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-07 09:44 -0800 |
| Message-ID | <028ad0ea-a74f-45b9-b4ed-5c71473fdcff@googlegroups.com> |
| In reply to | #38806 |
Il giorno giovedì 7 marzo 2019 16:16:19 UTC+1, Eric Douglas ha scritto: > On Thursday, March 7, 2019 at 8:42:06 AM UTC-5, antoni...@gmail.com wrote: > > > > I'm printing a PDF as byte array, probably my code is wrong, have you sample code? > > Have you tried Google? > What are you trying to do different? > Here's my first search result: > https://stackoverflow.com/questions/22607701/print-pdf-as-byte-array-in-java/50141811#50141811 I'm just using this kind of operations, using cups4j we are able to fit the page but javax print it seems doesn't work
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2019-03-07 10:06 -0800 |
| Message-ID | <36a18dfb-452d-4989-8d3d-795d1c164c52@googlegroups.com> |
| In reply to | #38807 |
On Thursday, March 7, 2019 at 12:44:16 PM UTC-5, antoni...@gmail.com wrote: > > I'm just using this kind of operations, using cups4j we are able to fit the page but javax print it seems doesn't work I just pointed you to exact code needed to send a PDF in byte array form to a printer, so if you're having a problem you're going to have to be more specific with some sample code preferably runnable.
[toc] | [prev] | [next] | [standalone]
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-08 10:33 -0800 |
| Message-ID | <5802c210-44b1-4801-a18f-1c514bb98905@googlegroups.com> |
| In reply to | #38806 |
Sure I'm already able to print pdf but not fitting the paper Is there a way to manage margins or simply send the fit command? Inspecting code it seems that javax print send an underlying lpr command
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2019-03-08 11:34 -0800 |
| Message-ID | <0bef0185-249c-4618-9707-1b7cf2966602@googlegroups.com> |
| In reply to | #38809 |
On Friday, March 8, 2019 at 1:33:34 PM UTC-5, antoni...@gmail.com wrote: > Sure I'm already able to print pdf but not fitting the paper > > Is there a way to manage margins or simply send the fit command? > > Inspecting code it seems that javax print send an underlying lpr command There are a couple ways to do this. First, what size paper is it printing on? Can you open the PDF in Acrobat Reader? Right click on it in Reader and select Properties. What is it's page size?
[toc] | [prev] | [next] | [standalone]
| From | antonior0409@gmail.com |
|---|---|
| Date | 2019-03-08 12:42 -0800 |
| Message-ID | <c1b121f0-f293-4083-89ac-4d5d5a028e49@googlegroups.com> |
| In reply to | #38810 |
Hi, the document size is 8,44 x 13,44 mm to print as NA LEGAL
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2019-03-08 16:13 -0500 |
| Message-ID | <q5uluf$rar$1@dont-email.me> |
| In reply to | #38811 |
On 3/8/2019 3:42 PM, antonior0409@gmail.com wrote:
> Hi,
> the document size is 8,44 x 13,44 mm to print as NA LEGAL
Use a teeny-tiny font ... :)
Seriously, I can't decipher the given dimensions. Here
are a few of my attempts:
- Taking the commas as decimal separators and the "mm" as
millimeters, the page would be about the size of your
smallest fingernail. This probably isn't what you mean.
- Taking "mm" as a typo for centimeters doesn't improve
matters much: It inflates each dimension by ten, but the
page is only about the size of an index card -- plausible,
but still not suggestive of "NA LEGAL".
- If "NA LEGAL" denotes the page size commonly called "legal"
in the USA (and maybe Mexico and Canada; I dunno), that
would be 8.5 by 14 inches, 215.9 by 355.6 mm. None of
those numbers resemble the dimensions you give.
- Perhaps the given dimensions are not metric at all, but
inches? If so, the size is just a little less than USA's
"legal," but I'm at a loss to account for the missing 0.06
and 0.56 inches (1.52 and 14.22 mm).
It seems to me you should take a deep breath, take a moment
or two to calm yourself, and re-state the details of your problem.
No one will be able to help you if your problem description is
hasty and inaccurate.
--
esosman@comcast-dot-net.invalid
Six hundred eighty-four days to go.
[toc] | [prev] | [next] | [standalone]
| From | Eric Douglas <e.d.programmer@gmail.com> |
|---|---|
| Date | 2019-03-08 14:04 -0800 |
| Message-ID | <e566054c-41f4-4529-be80-c5715bd10f03@googlegroups.com> |
| In reply to | #38811 |
On Friday, March 8, 2019 at 3:43:09 PM UTC-5, antoni...@gmail.com wrote: > Hi, > the document size is 8,44 x 13,44 mm to print as NA LEGAL If you meant to say the measurement of the pages in the PDF in inches that should come out fine if you set the job attributes to add a page size of 8.5x14. In that sample I linked the last command has a null parameter. You'd need to create a HashPrintRequestAttributes object for that.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web