[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556200#comment-17556200
 ] 

Andreas Lehmkühler commented on PDFBOX-5462:


The behaviour changed in 3.x. 2.x implements different strategies to cache 
things which makes the code complicated, hard to maintain and sort of 
nontransparent. Consequently some of the internal caching (scratch files aren't 
used for reading anymore) was removed so that the user has to care about it.

if you are dealing with streams you might want to spool them to a file first 
especially if the corresponding pdf is a bigger one. 2.x does the same under 
the hood but 3.x no more. 

I'm going to add some more details about that change to the 3.x migration guide

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f, 0, 0); // black
>   float x = (float)((diagonalLength - stringWidth) / 2); // 
> "horizontal" position in rotated world
>   f

Jenkins build is back to stable : PDFBox » PDFBox-trunk » Apache PDFBox examples #1350

2022-06-19 Thread Apache Jenkins Server
See 



-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



Jenkins build is back to stable : PDFBox » PDFBox-trunk #1350

2022-06-19 Thread Apache Jenkins Server
See 



-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556130#comment-17556130
 ] 

Marian Ion commented on PDFBOX-5462:


[~lehmi]  I understand you, but I can't: in the real application I have a PDF 
streamed over the net! And, as I said, it used to work with 2.x series 
libraries, why it shouldn't work now ?

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f, 0, 0); // black
>   float x = (float)((diagonalLength - stringWidth) / 2); // 
> "horizontal" position in rotated world
>   float y = (float)(-FONT_HEIGHT / 4); // 4 is a trial-and-error 
> thing, this lowers the text a bit
>   cs.beginText();
>   cs.newLineAtOffset(x, y);
>   cs.showText(watermarkText);
>   cs.endText();
>   } finally {
>   ...
>   }
>   return numberOfPages;
> }
> {code}



--
This message was sent by Atlassian

Jenkins build became unstable: PDFBox » PDFBox-trunk #1349

2022-06-19 Thread Apache Jenkins Server
See 



-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



Jenkins build became unstable: PDFBox » PDFBox-trunk » Apache PDFBox examples #1349

2022-06-19 Thread Apache Jenkins Server
See 



-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-4892) Improve code quality (4)

2022-06-19 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556115#comment-17556115
 ] 

ASF subversion and git services commented on PDFBOX-4892:
-

Commit 1902068 from Tilman Hausherr in branch 'pdfbox/branches/2.0'
[ https://svn.apache.org/r1902068 ]

PDFBOX-4892: simplify, as suggested by Valery Bokov

> Improve code quality (4)
> 
>
> Key: PDFBOX-4892
> URL: https://issues.apache.org/jira/browse/PDFBOX-4892
> Project: PDFBox
>  Issue Type: Improvement
>Affects Versions: 2.0.20
>Reporter: Tilman Hausherr
>Priority: Minor
>
> This is a longterm issue for the task to improve code quality, by using the 
> [SonarQube report|https://sonarcloud.io/project/issues?id=pdfbox-reactor], 
> hints in different IDEs, the FindBugs tool and other code quality tools.
> This is a follow-up of PDFBOX-4071, which was getting too long.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-4892) Improve code quality (4)

2022-06-19 Thread ASF subversion and git services (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556113#comment-17556113
 ] 

ASF subversion and git services commented on PDFBOX-4892:
-

Commit 1902067 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1902067 ]

PDFBOX-4892: simplify, as suggested by Valery Bokov

> Improve code quality (4)
> 
>
> Key: PDFBOX-4892
> URL: https://issues.apache.org/jira/browse/PDFBOX-4892
> Project: PDFBox
>  Issue Type: Improvement
>Affects Versions: 2.0.20
>Reporter: Tilman Hausherr
>Priority: Minor
>
> This is a longterm issue for the task to improve code quality, by using the 
> [SonarQube report|https://sonarcloud.io/project/issues?id=pdfbox-reactor], 
> hints in different IDEs, the FindBugs tool and other code quality tools.
> This is a follow-up of PDFBOX-4071, which was getting too long.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556092#comment-17556092
 ] 

Andreas Lehmkühler edited comment on PDFBOX-5462 at 6/19/22 5:47 PM:
-

The language settings shouldn't have any impact. I'm using different JDKs and 
I've used 1.8.0_202 in this case, but I guess that shouldn't have any impact 
too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is copy that file into 
memory which allocates 1.2GB of it. *+Pass the file to loadPDF instead of 
creating an InputStream first+*


was (Author: lehmi):
The language settings shouldn't have any impact. I'm using different JDKs and 
I've used 1.8.0_202 in this case, but I guess that shouldn't have any impact 
too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is copy that file into 
memory which allocates 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>

[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556092#comment-17556092
 ] 

Andreas Lehmkühler edited comment on PDFBOX-5462 at 6/19/22 5:44 PM:
-

The language settings shouldn't have any impact. I'm using different JDKs and 
I've used 1.8.0_202 in this case, but I guess that shouldn't have any impact 
too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is copy that file into 
memory which allocates 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first


was (Author: lehmi):
The language settings shouldn't have any impact. I'm using different JDKs and 
I've used 1.8.0_202 in this case, but I guess that shouldn't have any impact 
too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is to copy that file 
into memory allocation 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>  

[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556092#comment-17556092
 ] 

Andreas Lehmkühler edited comment on PDFBOX-5462 at 6/19/22 5:43 PM:
-

The language settings shouldn't have any impact. I'm using different JDKs and 
I've used 1.8.0_202 in this case, but I guess that shouldn't have any impact 
too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is to copy that file 
into memory allocation 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first


was (Author: lehmi):
The language settings should have any impact. I'm using different JDKs, I've 
used 1.8.0_202 in this case, but I guess that shouldn't have any impact too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is to copy that file 
into memory allocation 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some 

[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556092#comment-17556092
 ] 

Andreas Lehmkühler commented on PDFBOX-5462:


The language settings should have any impact. I'm using different JDKs, I've 
used 1.8.0_202 in this case, but I guess that shouldn't have any impact too.

W.r.t. the 4K pages file. I won't test that. It is an 1.2GB file. If you are 
still using an InputStream the first thing PDFBox does is to copy that file 
into memory allocation 1.2GB of it. Pass the file to loadPDF instead of 
creating an InputStream first

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f, 0, 0); // black
>   float x = (float)((diagonalLength - stringWidth) / 2); // 
> "horizontal" position in rotated world
>   float y = (float)(-FONT_HEIGHT / 4); // 4 is a trial-and-error 
> thing, this lowers the text a bit
>   cs.beginText();
>   cs.newLin

[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556091#comment-17556091
 ] 

Marian Ion edited comment on PDFBOX-5462 at 6/19/22 5:28 PM:
-

[~lehmi]  the code I use is the same as yours from 
https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/AddWatermarkText.java?view=markup
 the only difference is that you instantiate the font for every page while I do 
it once, would that be the cause? I shall give it a try tomorrow...


was (Author: JIRAUSER291146):
[~lehmi]  the code I use is the same as yours from 
[https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/AddWatermarkText.java]
 the only difference is that you instantiate the font for every page while I do 
it once, would that be the cause? I shall give it a try tomorrow...

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f

[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556091#comment-17556091
 ] 

Marian Ion commented on PDFBOX-5462:


[~lehmi]  the code I use is the same as yours from 
[https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/AddWatermarkText.java]
 the only difference is that you instantiate the font for every page while I do 
it once, would that be the cause? I shall give it a try tomorrow...

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f, 0, 0); // black
>   float x = (float)((diagonalLength - stringWidth) / 2); // 
> "horizontal" position in rotated world
>   float y = (float)(-FONT_HEIGHT / 4); // 4 is a trial-and-error 
> thing, this lowers the text a bit
>   cs.beginText();
>   cs.newLineAtOffset(x, y);
>   cs.showText(watermarkText);
>   cs.endText();
>   } finall

[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556089#comment-17556089
 ] 

Marian Ion edited comment on PDFBOX-5462 at 6/19/22 5:11 PM:
-

[~lehmi] my environment is Ubuntu (now {*}22.04{*}) with java {*}build 
17.0.3+7-Ubuntu-0ubuntu0.22.04.1{*}. I've tested the program on 2 i7 computers, 
a Dell laptop with 8G of RAM and an Intel *NUC8i7BEH* with 32G of RAM, both 
exhibit the same malfunction.

I attached the jar I use to this issue, try with it please ; try also to create 
a 4 k pages sample and use it on it, or download 
[https://server.famion.eu/4k_pages.pdf]

Would you like to send you my environment variables? the ones that might be of 
interest to you are
 
{quote}LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8

TEMPDIR=/tmp/user/1002
TMPDIR=/tmp/user/1002
TEMP=/tmp/user/1002
TMP=/tmp/user/1002
{quote}
 

 


was (Author: JIRAUSER291146):
[~lehmi] my environment is Ubuntu (now {*}22.04{*}) with java {*}build 
17.0.3+7-Ubuntu-0ubuntu0.22.04.1{*}. I've tested the program on 2 i7 computers, 
a Dell laptop with 8G of RAM and an Intel *NUC8i7BEH* with 32G of RAM, both 
exhibit the same malfunction.

I attached the jar I use to this issue, try with it please ; try also to create 
a 4 k pages sample and use it on it, or download 
[https://server.famion.eu/4k_pages.pdf]

Would you like to send you my environment variables? the ones that might be of 
interest to you are
 
{quote}LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
{quote}
 

 

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
> 

[jira] [Comment Edited] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556089#comment-17556089
 ] 

Marian Ion edited comment on PDFBOX-5462 at 6/19/22 5:08 PM:
-

[~lehmi] my environment is Ubuntu (now {*}22.04{*}) with java {*}build 
17.0.3+7-Ubuntu-0ubuntu0.22.04.1{*}. I've tested the program on 2 i7 computers, 
a Dell laptop with 8G of RAM and an Intel *NUC8i7BEH* with 32G of RAM, both 
exhibit the same malfunction.

I attached the jar I use to this issue, try with it please ; try also to create 
a 4 k pages sample and use it on it, or download 
[https://server.famion.eu/4k_pages.pdf]

Would you like to send you my environment variables? the ones that might be of 
interest to you are
 
{quote}LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
{quote}
 

 


was (Author: JIRAUSER291146):
[~lehmi] my environment is Ubuntu (now {*}22.04{*}) with java {*}build 
17.0.3+7-Ubuntu-0ubuntu0.22.04.1{*}. I've tested the program on 2 i7 computers, 
a Dell laptop and an Intel {*}NUC8i7BEH{*}, both exhibit the same malfunction.

I attached the jar I use to this issue, try with it please ; try also to create 
a 4 k pages sample and use it on it, or download 
[https://server.famion.eu/4k_pages.pdf]

Would you like to send you my environment variables? the ones that might be of 
interest to you are
 {quote}
LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
{quote}

 

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   doub

[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556089#comment-17556089
 ] 

Marian Ion commented on PDFBOX-5462:


[~lehmi] my environment is Ubuntu (now {*}22.04{*}) with java {*}build 
17.0.3+7-Ubuntu-0ubuntu0.22.04.1{*}. I've tested the program on 2 i7 computers, 
a Dell laptop and an Intel {*}NUC8i7BEH{*}, both exhibit the same malfunction.

I attached the jar I use to this issue, try with it please ; try also to create 
a 4 k pages sample and use it on it, or download 
[https://server.famion.eu/4k_pages.pdf]

Would you like to send you my environment variables? the ones that might be of 
interest to you are
 {quote}
LC_ADDRESS=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
{quote}

 

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0

[jira] [Updated] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Marian Ion (Jira)


 [ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marian Ion updated PDFBOX-5462:
---
Attachment: my-pdf-test.jar

> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz, my-pdf-test.jar
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   //cs.setRenderingMode(RenderingMode.STROKE); // for "hollow" 
> effect
>   PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
>   gs.setNonStrokingAlphaConstant(0.2f);
>   gs.setStrokingAlphaConstant(0.2f);
>   gs.setBlendMode(BlendMode.MULTIPLY);
>   cs.setGraphicsStateParameters(gs);
>   // some API weirdness here. When int, range is 0..255.
>   // when float, this would be 0..1f
>   cs.setNonStrokingColor(0f, 0, 0);
>   cs.setStrokingColor(0f, 0, 0); // black
>   float x = (float)((diagonalLength - stringWidth) / 2); // 
> "horizontal" position in rotated world
>   float y = (float)(-FONT_HEIGHT / 4); // 4 is a trial-and-error 
> thing, this lowers the text a bit
>   cs.beginText();
>   cs.newLineAtOffset(x, y);
>   cs.showText(watermarkText);
>   cs.endText();
>   } finally {
>   ...
>   }
>   return numberOfPages;
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5263) Suggestion: Signing actual document changes - Enhancing incremental saving

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556067#comment-17556067
 ] 

Andreas Lehmkühler commented on PDFBOX-5263:


What is the status of this ticket? I guess PDFBOX-5286 solves the performance 
issues. Is there anything else to be done? Do we have to do that in 3.0.0 or 
can it be done later?

> Suggestion: Signing actual document changes - Enhancing incremental saving
> --
>
> Key: PDFBOX-5263
> URL: https://issues.apache.org/jira/browse/PDFBOX-5263
> Project: PDFBox
>  Issue Type: Improvement
>  Components: Parsing, PDModel, Writing
>Affects Versions: 3.0.0 PDFBox
>Reporter: Christian Appl
>Priority: Major
> Fix For: 3.0.0 PDFBox
>
> Attachments: Enhanced_incremental_saving_.patch, 
> Enhanced_incremental_saving_PDFBox3.patch, NoSignatureFound.zip, 
> Observer_based_incremental_saving(09-13-2021).patch, 
> Observer_based_incremental_saving_(09-09-2021-09-09).patch, 
> Observer_based_incremental_saving_(12-00-2021-09-08).patch, 
> Observer_based_incremental_saving_(15-19-2021-09-08).patch, 
> Observer_based_incremental_saving_(17-00-2021-09-07).patch, 
> Observer_based_incremental_saving_(fixed_).patch, 
> Observer_based_incremental_saving_-_still_eroneous.patch, 
> Observer_based_incremental_saving_.patch, 
> PDFBOX-5263-YTW2VWJQTDAE67PGJT6GS7QSKW3GNUQR_afterPatch.pdf, 
> PDFBOX-5263-YTW2VWJQTDAE67PGJT6GS7QSKW3GNUQR_beforePatch.pdf, 
> PDFBOX-5263_Introduce_COSReferenceInfo.patch, 
> PDFBOX-5263_Introduce_COSReferenceInfo_(LinkedHashMap).patch, 
> PDFBOX-5263_Introduce_state_based_increment_handling_.patch, 
> PDFBOX-5263_Introduce_state_based_increment_handling__(POC2).patch, 
> PDFBOX-5263_Introduce_state_based_increment_handling__(simplified).patch, 
> Prototype_COSChangeObserver_(code_base).patch, 
> Prototype__Document_and_reference_holder_aware_COSContext_.patch, 
> Updating_context_management_.patch, image-2021-08-23-14-55-24-077.png, 
> image-2021-08-26-09-52-33-567.png, image-2021-08-26-09-54-24-897.png, 
> image-2021-08-26-10-00-07-383.png, image-2021-08-26-10-02-08-003.png, 
> image-2021-08-26-10-03-47-940.png, image-2021-08-26-10-06-42-925.png, 
> image-2021-08-26-10-09-12-698.png, image-2021-08-26-10-12-19-265.png, 
> image-2021-09-06-17-06-59-667.png, image-2021-09-07-09-35-31-408.png, 
> image-2021-09-07-13-33-00-161.png, image-2021-09-07-15-40-59-080.png, 
> image-2021-09-08-10-23-44-036.png, image-2021-09-08-11-18-34-211.png, 
> image-2021-09-13-14-40-33-049.png, image-2021-09-13-14-41-13-206.png, 
> image-2021-09-30-09-33-04-449.png, image-2021-09-30-09-34-19-175.png, 
> image-2021-10-07-13-06-40-576.png, image-2021-10-07-13-38-34-817.png, 
> image-2021-10-07-16-42-48-685.png, image-2021-10-07-16-46-30-004.png, 
> image-2021-10-07-17-46-41-793.png, image-2021-10-07-18-13-05-737.png, 
> out.pdf, out2.pdf, profiling-2021-10-07 16-27-06.png
>
>
> *TL;DR:*
> Currently it is rather tedious to create incremental changes in between 
> signatures via PDFBox. I attempted to simplify that and wrote a patch.
> This is rather a POC, than an actual suggestion for direct inclusion. (For 
> reasons explained later.)
> *Signatures and incremental PDF documents:*
> A typical reason for wanting to sign a document multiple times (creating an 
> incremental PDF) is , that in between signatures the document changed and the 
> additional signature shall sign the new state of the document.
> If one wanted to implement such incremental changes using PDFBox, he would 
> find, that most of the time made changes are completly ignored, when calling 
> "saveIncremental".
> As documented for the "saveIncremental" methods and especially the matching 
> constructors in "COSWriter", this would require, to identify the "path" of 
> all made changes and one would need to set the "needToBeUpdated" flag of all 
> elements of that path.
> *But:*
> As documented one would have to have exact understanding of what he did and 
> how the PDF standard does implement this, he would have to identify said 
> structures and the more complex the changes were, the more tedious this would 
> become.
> *Also:*
> Because of the implementation of incremental saving in COSWriter, the whole 
> path must be informed that it required an update.
> Resulting in unnecessary large increments, as not all ancestors might 
> actually have changed.
> e.g. If one added an image to a preexisting page of the document - the 
> contentstream, the resources of the page and the page dictionary would have 
> changed. But the "pages" array and all it's ancestors would not have changed 
> a bit, but still would have to be informed and included.
> *Assumptions that lead to this patch:*
> - COSWriter should not stop iterating a COSTree 

[jira] [Commented] (PDFBOX-5462) OutOfMemoryError when watermaking in 3.0.0-RC1

2022-06-19 Thread Jira


[ 
https://issues.apache.org/jira/browse/PDFBOX-5462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17556064#comment-17556064
 ] 

Andreas Lehmkühler commented on PDFBOX-5462:


[~john75] Thanks for the sample code and file

I'm afraid everything works fine for me, no exception. I've tried the following:

* I've created a sample file with 512 pages using the provide script. BTW, the 
provided pdf sample1.pdf is quite inefficient. 3 of the 4 pages contain one 
image, but all pages are referencing all images within their resources.
* using {{org.apache.pdfbox.examples.util.AddWatermarkText}} took 2 seconds to 
watermark the pdf
* using your code took 12 seconds to watermark the pdf

I've optimized some of your code:
* use a File instead of an InputStream as input. The parser needs random access 
to the pdf so that the data from the input stream has to be copied somewhere 
temporarily. The changes in 3.0.0 made it more efficient to use a file as input
* wrap the OutputStream into an BufferedStream or simply use a File as output 
and PDFBox will do that for you

In the end your code is as fast as the example. It takes 1,5 seconds to 
watermark the file.

I didn't use any additional JVM settings such as -Xmx and even the memory 
settings for the loadPDF-method aren't needed at all. I've run all test within 
my eclipse environment on an elderly pc (i7-3770, 16GB) using linux.

The question is, what is different in your environment? What hardware are you 
using?


> OutOfMemoryError when watermaking in 3.0.0-RC1
> --
>
> Key: PDFBOX-5462
> URL: https://issues.apache.org/jira/browse/PDFBOX-5462
> Project: PDFBox
>  Issue Type: Bug
>Affects Versions: 3.0.0 PDFBox
>Reporter: Marian Ion
>Priority: Major
> Attachments: TestPdfBox.tgz
>
>
> I am using the Maven *3.0.0-RC1* version and I encounter the following error 
> when watermarking a 5120 pages file:
> {quote} java.lang.OutOfMemoryError: Java heap space: failed reallocation of 
> scalar replaced objects
> {quote}
>  
> However, the *2.0.26* version code works without problem!
> The code is basically this :
> {code:java}
> private static final PDFont PDF_FONT = PDType1Font.HELVETICA;
> memoryUsageSetting = MemoryUsageSetting.setupMixed(2 * ONE_GIGA, 40 * 
> ONE_GIGA);
> //try (PDDocument pdfDocument = PDDocument.load(is, memoryUsageSetting)) {  
> // 2.0.26
> try (PDDocument pdfDocument = Loader.loadPDF(inputStream, 
> memoryUsageSetting)) { // 3.0.0-RC1
>   int nbPages = addWatermark(watermarkText, pdfDocument);
>   pdfDocument.save(os);
> }
> ...
> private int addWatermark(String watermarkText, PDDocument document) throws 
> IOException {
>   int numberOfPages = document.getNumberOfPages();
>   System.out.printf("Start adding watermark on a %d pages PDF 
> document%n", numberOfPages);
>   long start = System.nanoTime();
>   int pageIndex = 0;
>   for(PDPage page : document.getPages()) {
>   ++pageIndex;
>   try (PDPageContentStream cs = new PDPageContentStream(document, 
> page, PDPageContentStream.AppendMode.APPEND, true, true)) {
>   float width = page.getMediaBox().getWidth();
>   float height = page.getMediaBox().getHeight();
>   int rotation = page.getRotation();
>   switch(rotation) {
>   case 90:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(90), height, 0));
>   break;
>   case 180:
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(180), width, height));
>   break;
>   case 270:
>   width = page.getMediaBox().getHeight();
>   height = page.getMediaBox().getWidth();
>   
> cs.transform(Matrix.getRotateInstance(Math.toRadians(270), 0, width));
>   break;
>   default:
>   break;
>   }
>   double stringWidth = 
> (double)PDF_FONT.getStringWidth(watermarkText) / 1000 * FONT_HEIGHT;
>   double diagonalLength = Math.sqrt((double)width * width + 
> (double)height * height);
>   double angle = Math.atan2(height, width);
>   cs.transform(Matrix.getRotateInstance(angle, 0, 0));
>   cs.setFont(PDF_FONT, (float)FONT_HEIGHT);
>   /

[jira] [Resolved] (PDFBOX-5389) To set compressed on buffered image while creating a PDF

2022-06-19 Thread Tilman Hausherr (Jira)


 [ 
https://issues.apache.org/jira/browse/PDFBOX-5389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr resolved PDFBOX-5389.
-
Fix Version/s: 2.0.27
   3.0.0 PDFBox
 Assignee: Tilman Hausherr
   Resolution: Fixed

I forgot about this one but I think all is done here. We can't handle tiled / 
stripped images directly.

> To set compressed on buffered image while creating a PDF
> 
>
> Key: PDFBOX-5389
> URL: https://issues.apache.org/jira/browse/PDFBOX-5389
> Project: PDFBox
>  Issue Type: Bug
>  Components: Documentation
>Affects Versions: 2.0.19
>Reporter: Komal
>Assignee: Tilman Hausherr
>Priority: Major
> Fix For: 2.0.27, 3.0.0 PDFBox
>
> Attachments: 1bit_singlepage_G3_out.tiff
>
>
> Dear Concerned,
>  
> Dear Concerned,
>  
> We need to convert images into PDF. We have many format of image type like 
> tiff with any compression (G3, G4, LZW or Jpeg compression), JPEG, BMP, PNG. 
> Images can be single strip or multistrip/multitiles.
>  
> We have converted these images into buffered image and add it to pdf page but 
> for all type of image only compression set is /flatdecode. I need to set 
> different compression for different image format.
>  
> Kindly suggest how to set the compression while inserting image in creation 
> mode of PDF
>  
> Code:
> {
> PDDocument document = new PDDocument();
> //generated buffered image BufferedImage bim;
>     PDPage page = new PDPage(new PDRectangle((int) 
> bim.getWidth(), (int)bim.getHeight()));
>        document.addPage(page);
>    //Creating PDImageXObject object 
>    PDImageXObject imgObj = null;
>  try {
>         imgObj = 
> LosslessFactory.createFromImage(document, bim);
>     } catch (IOException e) {
>     // TODO Auto-generated catch 
> block
>     e.printStackTrace();
>     }
>     //PDPageContentStream contentStream = new 
> PDPageContentStream(document, page, AppendMode.OVERWRITE,true,true);
>  PDPageContentStream contentStream = new 
> PDPageContentStream(document, page);
>        contentStream.drawImage(imgObj, 0, 0);
>        contentStream.close();
>        //fileForInput.close();
>  
>        document.save(outputFile + ".pdf");
>        document.close();
> }
>  
> PDFBox vesion : 2.0.19
>  
> Regards,
> Komal Walia



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org