NeoPdf Varias imágenes - Forum

Forum Navigation
You need to log in to create posts and topics.

NeoPdf Varias imágenes

Hola @luishp,

Después de mucho tiempo sin participar veo que VisualNeo sigue avanzando por el buen camino.  Me alegro.

En este mensaje quería preguntarte si es posible enviar varias imágenes a un pdf.

El código que uso solo me imprime una.

neoPdfInit "prueba" "A4" "portrait"

neoPdfImage "prueba" "Image1" "PNG" 10 10 20 40
neoPdfImage "prueba" "Image2" "PNG" 60 60 20 40

neoPdfRender "prueba" "IFrame1"

Saludos,

Roger


 

@rrey

In this message I wanted to ask you if it is possible to send several images to a pdf.

Yes, there is an example of this in the called neoPDF-Tutorial (Sample Apps >>> Tutorials) ... take a look at the button labelled Images using base64 in the page labelled Images (the other button needs an image in the same folder).

The code I use only prints me one.

Can you tell us ...

a) that you are talking about "viewing" when you say "print" ?

b) which one it prints ? ... Image1 or Image2

c) what the real widths/heights of the two images are ?

d) does it print the missing image if you comment out the one that prints ?

 

@gaev

Te adjunto el programa en un zip. El problema es que solo se visualiza una imagen en el pdf.

Gracias

Uploaded files:
  • You need to login to have access to uploads.

@rrey

Thank you for the .zip file

When I ran it on my Chrome Browser, none of the files were displayed in the iFrame ... when I did Inspect >>> Console, I saw these messages ...

Access to XMLHttpRequest at 'file:///C:/Users/Gaev%20Keeka/Downloads/tutorial_pdf/cb.png' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
/C:/Users/Gaev%20Keeka/Downloads/tutorial_pdf/cb.png:1

Failed to load resource: net::ERR_FAILED

Access to XMLHttpRequest at 'file:///C:/Users/Gaev%20Keeka/Downloads/tutorial_pdf/an.png' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
/C:/Users/Gaev%20Keeka/Downloads/tutorial_pdf/an.png:1

Failed to load resource: net::ERR_FAILED

This is because of CORS restrictions; when you run your App from a file:///c: type of location, CORS does not allow it; try and run it from an https:// type of location.

Alternately, you can create a base64 format of your images, like in the the first button in the Tutorial App.

@gaev Lo ejecutó usando phpserver en localhost evitando los problemas de CORS, pero solo sale en el PDF una imagen.

Gracias

@rrey

You ran it using phpserver on localhost avoiding CORS problems, but only one image comes out in the PDF

No, I only tried it from the local file; I will try that later tonight.

 

 

 

@rrey

Using phpServer, I tried several combinations and found that ...

a) when there is only one neoPdfImage command specified, it works just fine ... so there is nothing wrong with the images

b) when there are two such commands, the second one does not render, and Inspect >>> Console shows this message ...

Uncaught TypeError: Cannot read property 'addImage' of undefined

... so the error is somewhere in the plugin (or the javascript library that the plugin is deploying).

Perhaps @luishp is better able to decipher the problem.

Note that (as in the Tutorial App) when a base64 image is specified (albeit the same one at different x , y co-ordinates), they render as expected.

@rrey @gaev yes, it seems there is a bug in the plugin due to the "asynchronous nightmare" :-)
I will try to fix it a soon as possible, meanwhile you can use neoPdfImageBase64 as I think it works properly.

This also works:

neoPdfInit "prueba" "A4" "portrait"
neoPdfImage "prueba" "Image1" "PNG" 10 10 20 40
Wait 500
  neoPdfImage "prueba" "Image2" "PNG" 20 20 20 40
  neoPdfRender "prueba" "IFrame1"
EndWait

Thank you both of you.

Regards

@rrey @gaev please replace the plugin with the attached one. I will include the fixed version in the next VisualNEO Web release.
Thank you again :)

Uploaded files:
  • You need to login to have access to uploads.

@luishp @gaev Muchas gracias a los dos por todo.