Global Mapper v25.0

GM_ExportPdf problam

eldad.cohen
eldad.cohen Global Mapper User
edited January 2012 in SDK
Hello all,
I have problem with using GM_ExportPDF function.
I have the trail version of QuickPDF (I installed it yesterday), I'm uisng the GM_SetQuickPdfUnlockCode method.
but when i'm trying to use the GM_ExportPdf method i'm getting the error code that i didn't registerd the QuickPdf. Also i check the return value from GM_SetQuickPdfUnlockCode method and it is Ok.

What is wrong??

Comments

  • global_mapper
    global_mapper Administrator
    edited November 2011
    Which SDK version are you using and which QuickPDFLibrary version did you buy? A month or so ago the QuickPDFLibrary moved to v8 and the latest SDK release uses QuickPDFLibrary v7, so a v8 key won't work when you try and export. However, we have a new SDK build at http://www.globalmapper.com/GlobalMapperSDK_v138_beta.zip that uses QuickPDFLibrary v8 that will work with the v8 unlock codes.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited November 2011
    First thank you for the repling.
    I'm still have the same problem.
    I'm using the latest version of QPL 8.12 it's the trail version for 30 days, I downloaded the beta SDK version that you post here.

    That's What i wrot in my code (C#):

    use in the start of the method:
    LastGMError=GlobalMapperDLL.GM_setQuickPDFUnlockCode("the code of the trail version");
    // this method returns GM_Error_None
    // after this use the method ExportPDF
    LastGMError=GlobalMapperDLL.GM_ExportPDF("path out file", the layer list,number of layers,NULL,NULL);

    and it returns GM_Error_NotRegistered.

    I hope we will find the answer.

    Thanks,
    Eldad.
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited November 2011
    Hi again,
    I found it that i get the same error when i use the GM_ExportRaster method...
    What could be the problem...

    Thanks again,
    Eldad.
  • global_mapper
    global_mapper Administrator
    edited November 2011
    Eldad,

    Do you have a licensed copy of the SDK or a trial key? You need to have a gmdll_regkey.txt license file from us placed in your folder with the GlobalMapperInterface.dll file from the SDK that you are using to provide the license information. You can't export from the SDK without a license key, hence the 'not registered' error message.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited November 2011
    Can you pleas show me an example for using GM_ExportRaster.

    Thanks
    Eldad.
  • global_mapper
    global_mapper Administrator
    edited November 2011
    Eldad,

    Here is a sample from the GMDLL_TesterDlg.cpp file included with the SDK C++ sample application:

    void
    CGMDLL_TesterDlg::OnSaveAsGeotiff()
    {
    // Get the filename to save to
    CFileDialog theSaveDialog
    (
    FALSE,
    ".tif",
    NULL,
    OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT,
    "GeoTIFF (*.tif, *.tiff)|*.tif;*.tiff|All Files|*.*||"
    );
    if ( IDOK != theSaveDialog.DoModal() )
    {
    return;
    }

    // Save the file
    GM_Error_t32 theErr = GM_ExportRaster
    (
    theSaveDialog.GetPathName(), // Name of new file to create
    GM_Export_GeoTIFF, // Format to export
    NULL, // Layer to export or NULL for all
    NULL, // World bounds to export or NULL for all
    2048, // Width in pixels of new image
    2048, // Height in pixels of new image
    GM_ExportFlags_GenWorldFile | GM_ExportFlags_GenPRJFile |
    GM_ExportFlags_GenTABFile | GM_ExportFlags_Palette
    );
    if ( GM_Error_NotRegistered == theErr )
    {
    mMapWindow.ShowNotRegisteredMessage
    (
    _T("You cannot export GeoTIFF files without having a registration file.")
    );
    }
    else if ( GM_Error_None != theErr )
    {
    CString theErrStr;
    theErrStr.Format( "Error export GeoTIFF: %d", theErr );
    ::AfxMessageBox( theErrStr );
    }
    else
    {
    ::AfxMessageBox( "Succesfully exported GeoTIFF file" );
    }
    } // end of function CGMDLL_TesterDlg::OnSaveAsGeotiff


    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited November 2011
    Hi Mike,
    Can I get a trail vesion of the sdk. I want to check first if all the functionality that I need works?

    ELdad.
  • global_mapper
    global_mapper Administrator
    edited November 2011
    Eldad,

    Please email gmsupport@bluemarblegeo.com and we can provide you with a trial of the SDK.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited December 2011
    First i want to thank you for the help.
    Now i have another problame.
    I'm trying to export a tiff file to pdf file.
    The DATUM of the tiff file is WGS-84 the file info (in the code) is ok, the programe take as well the information from the file.
    But when i use the the GM_ExportPdf method the output DATUM that i get is NAD83.

    I'm adding here my code:

    public void ExportToPDFDialog()
    {
    IntPtr FS = GlobalMapperDLL.GM_GetFilterString();
    string s = Marshal.PtrToStringAnsi(FS);

    OpenFileDialog OFD = new OpenFileDialog();

    OFD.Filter = s;

    OFD.ShowDialog(this);
    Cursor oldCursor = this.Cursor;
    Cursor = Cursors.WaitCursor;
    ExportToPDF(OFD.FileName);
    Cursor = oldCursor;
    }

    public void ExportToPDF(string FileName)
    {
    const String license = "******";
    LastGMError = GlobalMapperDLL.GM_SetQuickPDFUnlockCode(license);
    if (LastGMError == GlobalMapperDLL.GM_Error_t32.GM_Error_None)
    {
    GM_Projection_t theGeoProj = new GM_Projection_t();
    theGeoProj.mProjSys = PROJSYS.GM_PRJ_GEO;
    theGeoProj.mDatum = DATUM.GM_DATUM_WGS_84;
    theGeoProj.mUnit = UNIT.GM_PRJ_UNIT_ARC_DEGREES;
    theGeoProj.mNumAttrs = 0;
    LastGMError = GlobalMapperDLL.GM_SetProjection(ref theGeoProj);

    IntPtr LayerHandle = IntPtr.Zero;
    LastGMError = GlobalMapperDLL.GM_LoadLayer(FileName, out LayerHandle, 0);
    GlobalMapperDLLWrapper.GM_LayerInfo_t Info = new GlobalMapperDLLWrapper.GM_LayerInfo_t();
    IntPtr InfoPtr = GlobalMapperDLL.GM_GetLayerInfo(LayerHandle);
    Info = (GlobalMapperDLLWrapper.GM_LayerInfo_t)Marshal.PtrToStructure(InfoPtr, typeof(GlobalMapperDLLWrapper.GM_LayerInfo_t));

    GM_Rectangle_t WorldBounds = new GM_Rectangle_t();
    WorldBounds.mMaxX = Info.mGlobalRect.mMaxX;
    WorldBounds.mMinX = Info.mGlobalRect.mMinX;
    WorldBounds.mMaxY = Info.mGlobalRect.mMaxY;
    WorldBounds.mMinY = Info.mGlobalRect.mMinY;

    IntPtr theLayerList;
    UInt32 theNumLayers = 0;
    LastGMError = GlobalMapperDLL.GM_LoadLayerList(FileName, out theLayerList, out theNumLayers, 0);
    SaveFileDialog SFD = new SaveFileDialog();
    string s = "PDF files (*.geoPDF,*.PDF)|*.pdf";
    SFD.Filter = s;
    SFD.ShowDialog(this);
    Cursor oldCursor = this.Cursor;
    Cursor = Cursors.WaitCursor;

    GM_ExportOptsPDF_t ExportOpts = new GM_ExportOptsPDF_t();

    // Flags for Exporting
    ExportOpts.mFlags = GM_PDFExportFlags_t32.GM_PDF_FillPage | GM_PDFExportFlags_t32.GM_PDF_Landscape;
    ExportOpts.mBorderWidth = 0;
    LastGMError = GlobalMapperDLL.GM_ExportPDF(SFD.FileName, theLayerList, theNumLayers, ref WorldBounds, ref ExportOpts);
    Cursor = oldCursor;
    }
    }

    I hope you'll understand the problem and help me to fix it.

    Thank's,

    Eldad
  • global_mapper
    global_mapper Administrator
    edited December 2011
    Eldad,

    The problem is that the OGC best practices for geospatial PDF for some reason doesn't have a code listed for the WGS84 datum, so Global Mapper writes those out using the NAD83 code, which is basically equivalent for nearly all purposes. The spatial placement should basically be identical. There are some codes that Global Mapper will recognize as WGS84, but they are not universally recognized.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited December 2011
    Ok,
    So how can it be that when i'm using the GM UI it knows how to do the conversion( I'm speeking about the same file)...
    The UI converts the pdf to tiff with datum WGS84.
  • global_mapper
    global_mapper Administrator
    edited December 2011
    Eldad,

    Can you provide the PDF that you are generating from the GM application that is coming back into GM as WGS84?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited December 2011
    this is the pdf: http://www.agc.army.mil/GeoPDFgallery/DoD/L701461501_geo.pdf
    I converted it firs to geotiff and after it to geoPDF, as I said my code covert it back to NAD83 and the GM UI convert it to the WGS84 as it should be.

    thanks
  • global_mapper
    global_mapper Administrator
    edited December 2011
    I took a look and found the datum code in the PDF file was ING-A, which actually corresponds to the Indian 1960 datum which wasn't built in to Global Mapper, so it just defaulted to WGS84. I added Indian 1960 as a built-in datum and now it comes in properly positioned. I have placed a new SDK build with this change at http://www.globalmapper.com/GlobalMapperSDK_v138_beta.zip .

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
    First Thank you for the help.
    Second i still have the problem with the convertion from tiff in DATUM WGS84 to GeoPdf in the same DATUM.
    The GM UI knows how to covert tiff file in datum wgs84 to pdf file in datum wgs84?
    I still don't gat the point why the UI can covert it and the SDK can't...

    You can find in this site some tiff files in datum wgs84 that i converted them with the UI App to Pdf in Datum wgs84:
    http://www.terracolor.net/sample_imagery.html

    Regards,
    Eldad.
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
    Here you can find other tiff files:
    http://www.mapmart.com/Samples.aspx
  • global_mapper
    global_mapper Administrator
    edited January 2012
    Have you tried the updated SDK build from http://www.globalmapper.com/GlobalMapperSDK_latest_beta.zip? It would contain the datum change that had to be made in the UI to recognize the datum being used in the PDF files that you are using.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
    I tried it too, and the problem appeared again.
    This is the tiff file that i'd checked http://mapmart.com/DownloadArea/MapMart_Samples/LombardStreetTIFF.zip. This tiff is wgs84 and i coverted it with the UI to Pdf file and it was correct but with the SDK i got the NAD83 datum...
  • global_mapper
    global_mapper Administrator
    edited January 2012
    I just downloaded that .zip file and exported to a PDF in the UI and the PDF that was created had NAD83 (datum code NAR) as the datum, which is what I would expect from both the UI and the SDK due to the lack of a datum code for WGS84 documented in the OGC best practices document. Can you provide the PDF that you generated from the UI that shows up as WGS84?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
    This is the file, it is at wgs84 datum.
    Im using GM 12. I just click on EXPORT PDF File... => in the dialog box press Ok give name for the file and press save.
    At the end i get Pdf file at wgs84 datum in utm 10 as it should be like the tiff file.
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
  • global_mapper
    global_mapper Administrator
    edited January 2012
    There was a time when the datum code WGD was written out for WGS84 as that is supported by some applications, and Global Mapper will recognize it as WGS-84, but other applications don't support it (like Acrobat's position plug-in), so we switched back to use the universally recognized code of NAS for NAD83 when WGS84 is encountered as they as basically equivalent. In v13 and the latest SDK you won't get WGD, but in the particular build of v12 that you have you get WGD for WGS84. The PDF file generated doesn't display position info in Acrobat though, whereas one with NAS for NAD83 does. The lat/lon values are the same, so it really doesn't matter positionally which is used. I don't know why the OGC best practices document didn't list a datum code for WGS84, but without one there isn't a way to add WGS84 and get something that works everywhere.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • eldad.cohen
    eldad.cohen Global Mapper User
    edited January 2012
    First thank you very much.
    Second can you pleas send me a link for a SDK that can Convert to WGS84.(like SDK v12).

    Regards,
    Eldad.
  • global_mapper
    global_mapper Administrator
    edited January 2012
    Eldad,

    We don't have a SDK version that writes out WGD for the WGS-84 datum as it is not supported by any other applications so it is bad to create them that way. It will only be recognized as WGS-84 in Global Mapper itself. Do you have some other application that you want to use these PDFs in that requires WGD in the datum field? NAD83 and WGS-84 are equivalent to within about 1 mm so there really is no difference.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com