You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Jose robles (JIRA)" <ji...@apache.org> on 2011/07/01 19:02:29 UTC

[jira] [Created] (PDFBOX-1057) PDXObjectImage create diferences between pdf on mac and windows

PDXObjectImage create diferences between pdf on mac and windows
---------------------------------------------------------------

                 Key: PDFBOX-1057
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1057
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.5.0
         Environment: Mac OSx 10.6.8, java version "1.6.0_26"

            Reporter: Jose robles


Hi! I hope you can help me with this, I have a pdf form, I use pdfbox to fill the fields, but also to add a barcode to the form, the barcode is generated with jbars, this generate a jpg, then I add this jpg to the pdf form,  on Mac works everything fine, but when I generate/open the same form on Windows the  barcode is distorted, I dont know whats going on, not sure If I did something wrong or is the pdfbox.

[code]
                File fi = new File(codigoBarras.getPathToImg());   //the generated Codebar
		if(!fi.exists() || !fi.canRead()){
			Log.error("GenerarPoliza", "La imagen del codigo de barras no se genero correctamente.");  //the codebar didnt generate correctly
			codigo = false;
		}
	        PDXObjectImage ximage = null;
		ximage = new PDJpeg(this.pdf, new FileInputStream( fi ) );   //this.pdf is the pdf document.
		ximage.setWidth(toPixel(60 * pixelXmm_x));  //set the width of the image
		ximage.setHeight(toPixel(13 * pixelXmm_x)); //set the height of the image
		PDPageContentStream contentStream = new PDPageContentStream(this.pdf, pagina, true , true);
		contentStream.drawImage(ximage, toPixel(20.0 * pixelXmm_x), toPixel(10.0 * pixelXmm_y));  //draw the codebars to the given coordinates. 		
		contentStream.close();
[/code]

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (PDFBOX-1057) PDXObjectImage create diferences between pdf on mac and windows

Posted by "Andreas Lehmkühler (Closed JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Lehmkühler closed PDFBOX-1057.
--------------------------------------

    Resolution: Not A Problem
      Assignee: Andreas Lehmkühler

I agree with Luke, it's not a PDFBox issue.
                
> PDXObjectImage create diferences between pdf on mac and windows
> ---------------------------------------------------------------
>
>                 Key: PDFBOX-1057
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1057
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.5.0
>         Environment: Mac OSx 10.6.8, java version "1.6.0_26"
>            Reporter: Jose robles
>            Assignee: Andreas Lehmkühler
>
> Hi! I hope you can help me with this, I have a pdf form, I use pdfbox to fill the fields, but also to add a barcode to the form, the barcode is generated with jbars, this generate a jpg, then I add this jpg to the pdf form,  on Mac works everything fine, but when I generate/open the same form on Windows the  barcode is distorted, I dont know whats going on, not sure If I did something wrong or is the pdfbox.
> [code]
>                 File fi = new File(codigoBarras.getPathToImg());   //the generated Codebar
> 		if(!fi.exists() || !fi.canRead()){
> 			Log.error("GenerarPoliza", "La imagen del codigo de barras no se genero correctamente.");  //the codebar didnt generate correctly
> 			codigo = false;
> 		}
> 	        PDXObjectImage ximage = null;
> 		ximage = new PDJpeg(this.pdf, new FileInputStream( fi ) );   //this.pdf is the pdf document.
> 		ximage.setWidth(toPixel(60 * pixelXmm_x));  //set the width of the image
> 		ximage.setHeight(toPixel(13 * pixelXmm_x)); //set the height of the image
> 		PDPageContentStream contentStream = new PDPageContentStream(this.pdf, pagina, true , true);
> 		contentStream.drawImage(ximage, toPixel(20.0 * pixelXmm_x), toPixel(10.0 * pixelXmm_y));  //draw the codebars to the given coordinates. 		
> 		contentStream.close();
> [/code]

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (PDFBOX-1057) PDXObjectImage create diferences between pdf on mac and windows

Posted by "Luke Bellandi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13059248#comment-13059248 ] 

Luke Bellandi commented on PDFBOX-1057:
---------------------------------------

I ran into this same problem.  The PDF will render correctly in Preview.app on Mac, but will look all striated on Windows in Adobe Reader.app, right?

If you download Adobe Reader.app for Mac, though, you'll see the same problems. This is not a problem in PDFBox AFAICT, it's an idiosyncrasy of Preview.app.

What you need to do to resize images is to apply a matrix transform, not call setWidth, setHeight.  So in your case, do the following:

1) Remove the setWidth()/setHeight() calls
2) Apply a transform matrix to the PDPageContentStream before drawing the image to perform the scaling:
contentStream.concatenate2CTM(xScaleFactor, 0, 0, yScaleFactor, 0, 0);
3) Call draw image.  NOTE: the coordinates that you'll be drawing your image at will also be subject to the scaling transformation that was just applied.  If you don't want that, be sure to multiply your render coordinates by (1.0 / xScaleFactor) and (1.0 yScaleFactor) respectively.

Hope that helps -- good luck!

- Luke

> PDXObjectImage create diferences between pdf on mac and windows
> ---------------------------------------------------------------
>
>                 Key: PDFBOX-1057
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1057
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.5.0
>         Environment: Mac OSx 10.6.8, java version "1.6.0_26"
>            Reporter: Jose robles
>
> Hi! I hope you can help me with this, I have a pdf form, I use pdfbox to fill the fields, but also to add a barcode to the form, the barcode is generated with jbars, this generate a jpg, then I add this jpg to the pdf form,  on Mac works everything fine, but when I generate/open the same form on Windows the  barcode is distorted, I dont know whats going on, not sure If I did something wrong or is the pdfbox.
> [code]
>                 File fi = new File(codigoBarras.getPathToImg());   //the generated Codebar
> 		if(!fi.exists() || !fi.canRead()){
> 			Log.error("GenerarPoliza", "La imagen del codigo de barras no se genero correctamente.");  //the codebar didnt generate correctly
> 			codigo = false;
> 		}
> 	        PDXObjectImage ximage = null;
> 		ximage = new PDJpeg(this.pdf, new FileInputStream( fi ) );   //this.pdf is the pdf document.
> 		ximage.setWidth(toPixel(60 * pixelXmm_x));  //set the width of the image
> 		ximage.setHeight(toPixel(13 * pixelXmm_x)); //set the height of the image
> 		PDPageContentStream contentStream = new PDPageContentStream(this.pdf, pagina, true , true);
> 		contentStream.drawImage(ximage, toPixel(20.0 * pixelXmm_x), toPixel(10.0 * pixelXmm_y));  //draw the codebars to the given coordinates. 		
> 		contentStream.close();
> [/code]

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira