Sample code for 30+ languages & platforms
SQL Server Requires Chilkat v11.7.0+

PDF Footnotes in Markdown: Inline, at the End, or Dropped

See more PDF Text Extraction Examples

Demonstrates the "footnotes" option of the "markdown" operation. Small-print notes at the foot of a page are kept where they are ("inline", the default), gathered at the end of the document ("end"), or left out ("none").

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    --  This example requires the Chilkat API to have been previously unlocked.
    --  See Global Unlock Sample for sample code.

    --  The two-page PDF used in this example is available at footnotes.pdf

    DECLARE @pdf int
    EXEC @hr = sp_OACreate 'Chilkat.Pdf', @pdf OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    EXEC sp_OAMethod @pdf, 'LoadFile', @success OUT, 'qa_data/pdf/footnotes.pdf'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @pdf, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @pdf
        RETURN
      END

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    DECLARE @jsonOut int
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jsonOut OUT

    --  Page 1 has two superscript references in the text and the two notes in small print at its foot;
    --  page 2 has a third.
    EXEC sp_OAMethod @pdf, 'ExtractText', @success OUT, 'markdown', @json, @jsonOut
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @pdf, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @pdf
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @jsonOut
        RETURN
      END

    PRINT '---- footnotes: inline (default) ----'
    EXEC sp_OAMethod @jsonOut, 'StringOf', @sTmp0 OUT, 'markdown'
    PRINT @sTmp0

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'footnotes', 'end'
    EXEC sp_OAMethod @pdf, 'ExtractText', @success OUT, 'markdown', @json, @jsonOut
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @pdf, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @pdf
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @jsonOut
        RETURN
      END

    PRINT '---- footnotes: end ----'
    EXEC sp_OAMethod @jsonOut, 'StringOf', @sTmp0 OUT, 'markdown'
    PRINT @sTmp0

    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'footnotes', 'none'
    EXEC sp_OAMethod @pdf, 'ExtractText', @success OUT, 'markdown', @json, @jsonOut
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @pdf, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @pdf
        EXEC @hr = sp_OADestroy @json
        EXEC @hr = sp_OADestroy @jsonOut
        RETURN
      END

    PRINT '---- footnotes: none ----'
    EXEC sp_OAMethod @jsonOut, 'StringOf', @sTmp0 OUT, 'markdown'
    PRINT @sTmp0

    --  Sample output:

    --  ---- footnotes: inline (default) ----
    --  <!-- page 1 -->
    --  
    --  # The Lens on Loan
    --  
    --  The society located a fourth-order lens of the correct period at a museum1 in the next county, and an agreement to loan it for ten years was signed in November.2 The lens will be lit with a low-wattage electric lamp rather than oil, and it will be displayed as a historic light rather than registered as an aid to navigation.
    --  
    --  1 The county maritime museum, which holds three lenses from decommissioned lights. 2 The loan is renewable and carries no fee; the society insures the lens.
    --  
    --  <!-- page 2 -->
    --  
    --  # Public Access
    --  
    --  The grounds opened to visitors on weekends from July. Nearly three thousand people climbed the tower over the summer,3 with no incidents.
    --  
    --  3 Counted at the entrance by the volunteers on duty.
    --  
    --  ---- footnotes: end ----
    --  <!-- page 1 -->
    --  
    --  # The Lens on Loan
    --  
    --  The society located a fourth-order lens of the correct period at a museum1 in the next county, and an agreement to loan it for ten years was signed in November.2 The lens will be lit with a low-wattage electric lamp rather than oil, and it will be displayed as a historic light rather than registered as an aid to navigation.
    --  
    --  <!-- page 2 -->
    --  
    --  # Public Access
    --  
    --  The grounds opened to visitors on weekends from July. Nearly three thousand people climbed the tower over the summer,3 with no incidents.
    --  
    --  1 The county maritime museum, which holds three lenses from decommissioned lights. 2 The loan is renewable and carries no fee; the society insures the lens.
    --  
    --  3 Counted at the entrance by the volunteers on duty.
    --  
    --  ---- footnotes: none ----
    --  <!-- page 1 -->
    --  
    --  # The Lens on Loan
    --  
    --  The society located a fourth-order lens of the correct period at a museum1 in the next county, and an agreement to loan it for ten years was signed in November.2 The lens will be lit with a low-wattage electric lamp rather than oil, and it will be displayed as a historic light rather than registered as an aid to navigation.
    --  
    --  <!-- page 2 -->
    --  
    --  # Public Access
    --  
    --  The grounds opened to visitors on weekends from July. Nearly three thousand people climbed the tower over the summer,3 with no incidents.

    EXEC @hr = sp_OADestroy @pdf
    EXEC @hr = sp_OADestroy @json
    EXEC @hr = sp_OADestroy @jsonOut


END
GO