Example Code of the Amyuni Geo-Registration Module

 

Public Sub Sample()
    ' Constants for Activation codes
    Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
    Const strActivationCode As String = "07EFCDAB0100010025AFF180DCBA441306C5739F7D452154D8C33B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
 
    ' Declare a new cdintfex document if it does not exist in the form.
    Dim pdfDoc As New CDIntfEx.Document
 
    ' The SetLicenseKey method should be called after creating an object of type 
    ' CDIntfEx.Document to activate the advanced methods that require the object 
    ' activation code to work properly
    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)
 
    Dim pDoc As CDIntfEx.IDIDocument = pdfDoc
 
    Dim gcs As CDIntfEx.ICoordinateSystem = pDoc.CreateCoordinateSystem()
    gcs.CSType = CDIntfEx.CoordinateSystems.PROJCS
    gcs.WKT = "GEOGCS[""GCS_North_American_1927"",DATUM[""D_North_American_1927"",SPHEROID[""Clarke_1866"",6378206.4,294.9786982]],PRIMEM[""Greenwich"",0.0],UNIT[""Degree"",0.0174532925199433]]"
 
    Dim bounds = New Integer() {0, 1, 0, 0, 1, 0, 1, 1}
    Dim gpts = New Double() {12.14545, -118.64174, 35.1259, -118.64174,
                                    35.1259, -85.21563, 12.14545, -85.21563}
    Dim lpts = New Integer() {0, 1, 0, 0, 1, 0, 1, 1}
 
    Dim measure As CDIntfEx.IMeasure = pDoc.CreateMeasure()
    measure.Bounds = bounds
    measure.GPTS = gpts
    measure.LPTS = lpts
    measure.GCS = gcs
 
    Dim bbox As CDIntfEx.IBBox = pDoc.CreateBBox()
    bbox.X1 = 0
    bbox.Y1 = 580
    bbox.X2 = 844
    bbox.Y2 = 0
 
    Dim vp As CDIntfEx.IViewport = pDoc.CreateViewport()
    vp.Measure = measure
    vp.Name = "Layers"
    vp.BBox = bbox
 
    ' Open the document
    pdfDoc.Open("c:\temp\non_geo_registered.pdf")
 
    ' Add ViewPort to PDF
    pdfDoc.AddViewport(1, vp)
 
    ' Save the document
    pdfDoc.Save("c:\temp\geo_registered.pdf")
End Sub
public void Sample()
{
    // Constants for Activation codes
    const string strLicenseTo = "Amyuni PDF Converter Evaluation";
    const string strActivationCode = "07EFCDAB0100010025AFF180DCBA441306C5739F7D452154D8C33B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
 
    // Declare a new cdintfex document if it does not exist in the form.
    CDIntfEx.Document pdfDoc = new CDIntfEx.Document();
 
    // The SetLicenseKey method should be called after creating an object of type 
    // CDIntfEx.Document to activate the advanced methods that require the object 
    // activation code to work properly
    pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);
 
    CDIntfEx.IDIDocument pDoc = (CDIntfEx.IDIDocument)pdfDoc;
 
    CDIntfEx.ICoordinateSystem gcs = pDoc.CreateCoordinateSystem();
    gcs.CSType = CDIntfEx.CoordinateSystems.PROJCS;
    gcs.WKT = "GEOGCS[\"GCS_North_American_1927\",DATUM[\"D_North_American_1927\","
               + "SPHEROID[\"Clarke_1866\",6378206.4,294.9786982]],PRIMEM"
               + "[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]";
 
    int[] bounds = new int[8] { 0, 1, 0, 0, 1, 0, 1, 1 };
    double[] gpts = new double[8] { 12.14545, -118.64174, 35.12590, -118.64174,
        35.12590, -85.21563, 12.14545, -85.21563 };            
    int[] lpts = new int[8] { 0, 1, 0, 0, 1, 0, 1, 1 };
 
    CDIntfEx.IMeasure measure = pDoc.CreateMeasure();
    measure.Bounds = bounds;
    measure.GPTS = gpts;
    measure.LPTS = lpts;
    measure.GCS = gcs;
 
    CDIntfEx.IBBox bbox = pDoc.CreateBBox();
    bbox.X1 = 0; bbox.Y1 = 580;
    bbox.X2 = 844; bbox.Y2 = 0;
 
    CDIntfEx.IViewport vp = pDoc.CreateViewport();
    vp.Measure = measure;
    vp.Name = "Layers";
    vp.BBox = bbox;
 
    // Open the document
    pdfDoc.Open(@"c:\temp\non_geo_registered.pdf");
 
    // Add ViewPort to PDF
    pdfDoc.AddViewport(1, vp);
 
    // Save the document
    pdfDoc.Save(@"c:\temp\geo_registered.pdf");
}