ArcPy ExportToPDF does not export image (TIF)

870
9
09-14-2011 08:20 AM
TatianaTen
New Contributor III
Hi all,

I'm having troubles with exporting the map document with tif image to PDF using the python script. The dataframe with map gets exported, but the image is dropped during the process.
It works fine with small resolution parameter, but in my case I need to produce 660dpi and without any compression. It also works if I run the Export Map from the ArcMap, but not if I run the script from Arc or GPTask.
The system I'm running on is Win 2003, 4Gb RAM, 2 CPUs

<code>
arcpy.mapping.ExportToPDF(mapDoc, str(output_path), resolution=660,
                                  colorspace='CMYK', image_compression='NONE',
                                  layers_attributes='NONE',
                                  georef_info='false')
</code>

Please, help as I need this urgently....

Thanks,
Tatiana
Tags (2)
0 Kudos
9 Replies
JakeSkinner
Esri Esteemed Contributor
How is the TIFF image added to your map document?  Is it added using the 'Add Data' button, or is it added using 'Insert > Picture'?

Have you tried converting the TIFF to a different format (i.e. JPEG) and see if it that works?
0 Kudos
MathewCoyle
Frequent Contributor
Have you tried exporting the PDF with default settings?
i.e.
arcpy.mapping.ExportToPDF(mxd, str(output_path))
0 Kudos
TatianaTen
New Contributor III
How is the TIFF image added to your map document?  Is it added using the 'Add Data' button, or is it added using 'Insert > Picture'?

Have you tried converting the TIFF to a different format (i.e. JPEG) and see if it that works?


The tif image is added using 'Insert > Picture'.

I'm using TIFF format, cos it's one of the requirement of my project.
0 Kudos
TatianaTen
New Contributor III
Have you tried exporting the PDF with default settings?
i.e.
arcpy.mapping.ExportToPDF(mxd, str(output_path))


yes, i have. Works fine with defaults, cos they have lower values, i.e. resolution of 300 and image_compression is ADAPTIVE.
0 Kudos
MathewCoyle
Frequent Contributor
So this is just an image, not a geotiff basemap or anything? How big is it? If it is exporting with default values, memory or something must be an issue. I would try restarting your computer so memory is fresh, then add each parameter you want to customize one at a time to see where it hits the wall.

You can also try setting smaller metafile/raster buffer size in advanced arcmap setting utility, to see if that helps.
0 Kudos
TatianaTen
New Contributor III
So this is just an image, not a geotiff basemap or anything? How big is it? If it is exporting with default values, memory or something must be an issue. I would try restarting your computer so memory is fresh, then add each parameter you want to customize one at a time to see where it hits the wall.


No, it's not a geotiff basemap, it's an image with legend and the cover for the map. We're using a number of those images with different sizes ranging from 1.5 to 3 Mb.
I was thinking about the memory issue, but the Export of the map works from ArcMap, and it exports a big file of 1Gb (but it works and I'm able to open it).  Unless there are two different export engines used in ArcMap and arcpy. I don't know.


You can also try setting smaller metafile/raster buffer size in advanced arcmap setting utility, to see if that helps.

Not sure where to find it, but will definitely try it. I'm gonna try everything that might help! 😉
0 Kudos
MathewCoyle
Frequent Contributor
The Advanced Settings utility is located in your install\Utilities directory, depending on what OS you are using.

E.g. on Windows 7 machine, ArcGIS 10.0 default install, it would be in C:\Program Files (x86)\ArcGIS\Desktop10.0\Utilities

As to ArcMap and arcpy module operating differently, I have had issues in the past with exporting a PDF out of ArcMap working fine, and exporting a PDF using arcpy using the same parameters failing. I don't know if it is a memory management difference between the two, or ghosts in my machine, it just doesn't seem to be consistent.
0 Kudos
suharthachowdhury
New Contributor
Hi,
Did you ever get it solved? I am having the same problem with my script in ArcGIS 9.3.1. My script to export the mxd to PNG exports everything else on the map doc except a tiff logo. As you mentioned on the first post, ArcMap does export the logo fine when the export is done through ArcMap.
My script is as follows (some relevant code):

Set pExporter = New ExportPNG
 
  With pExporter
    .PixelBounds = pPixelEnv
    .Resolution = lngOutputResolution
    .ExportFileName = sFullPathName
End With

' device coordinates origin is upper left, ypositive is down
  With tExpRect
    .Left = pExporter.PixelBounds.LowerLeft.x
    .bottom = pExporter.PixelBounds.UpperRight.y
    .Right = pExporter.PixelBounds.UpperRight.x
    .Top = pExporter.PixelBounds.LowerLeft.y
  End With

' export the map
  hdc = pExporter.StartExporting
    Set pAV = pPageLayout
    pAV.Output hdc, lngOutputResolution, tExpRect, Nothing, Nothing
    DoEvents
  pExporter.FinishExporting

I am not sure if I am missing any required parameters. Please help since I am really lost in this.
0 Kudos
TatianaTen
New Contributor III
Hi all,

Thanks for all your replies....

My problem was solved, by changing the environment and increasing the memory. Originally, I was running on Win 2003, 4Gb RAM, 2 CPUs. Now changed for Win 2008, 6Gb RAM, 2 CPUs and 2 drives (1 for the OS and another for the Data), and I have noticed that if the hard disc with OS space is below 3Gb the image doesn't get exported.
I've managed to install the Adobe Reader on my second drive (not OS drive), so I try to keep my c drive as free as possible.

I've also tried mzcoyle's suggestion to use the Advanced Settings, it didn't solve the issue, but it might help in the performance. Thanks mzcoyle for this suggestion.

suhartha, your script is in VBA, am I right? Have you tried to export with smaller parameters, i.e. Lower resolution?
0 Kudos