Solved

PDF to BMP to Base64


Badge +9

I have a series of PDF documents that contain a map that came from the ArcGIS Map Series tools (over 2000 in all). I am reading each of the PDF's in and converting to BMP and saving the images to a local drive so I can use the images in a HTML report.

 

Rather than store the images locally, I was wondering if there was a way to convert the images to base64 and save the base64 as an attribute and then just use that attribute in the HTML document?

 

Is this possible? Any suggestions would be very much appreciated.

icon

Best answer by ebygomm 1 July 2022, 16:21

View original

6 replies

Userlevel 6
Badge +32

Hej Dean, not sure what you want to solve exactly. You already know you can add an image as base64 in an HTML report, right?

Badge +9

Hej Dean, not sure what you want to solve exactly. You already know you can add an image as base64 in an HTML report, right?

Thanks @nielsgerrits​ I want to be able to use the base64 image in the HTML report rather than link to a file. So, I want to try and figure out how to extract the image from the PDF and convert it to base64 without having to save the image locally.

Userlevel 6
Badge +32

Thanks @nielsgerrits​ I want to be able to use the base64 image in the HTML report rather than link to a file. So, I want to try and figure out how to extract the image from the PDF and convert it to base64 without having to save the image locally.

I don't know if that is possible. When I do this kind of job I use the TempPathnameCreator to create the files and point the HTMLGenerator to those temp files to convert it to Base64. But with 2000 bmp's and 2000 html's I can imagine the volume might be an issue. I would maybe use a workspacerunner to be sure the process runs one by one and clearing the tempfiles in between.

Badge +9

Thanks @nielsgerrits​ I want to be able to use the base64 image in the HTML report rather than link to a file. So, I want to try and figure out how to extract the image from the PDF and convert it to base64 without having to save the image locally.

Thanks @nielsgerrits​ ​

Userlevel 1
Badge +21

The RasterExtractor will give you the raster as a blob

Badge +9

The RasterExtractor will give you the raster as a blob

Thanks @ebygomm​ that is a great option. I then added the binary encoder to convert to base64 which is stored as an attribute to be used in the HTML report.

image

Reply