#!/usr/local/bin/ruby
#
#
# ./linkpdfpage.rb
#
# require file ../cpdfman110.pdf
# or edit ../cpdfman110.pdf

require "ClibPDF"

pdf = ClibPDF::PDF.open(0)
pdf.enableCompression(ClibPDF::YES)
pdf.init
pdf.pageInit(1, ClibPDF::PORTRAIT, "0 0 144 20", "0 0 144 20")

pdf.rawRect(0.0, 0.0, 144.0, 20.0)
pdf.setrgbcolorFill(1.0, 1.0, 0.0)
pdf.fill

pdf.setgrayFill(0.0)
pdf.beginText(0)
pdf.setFont("Times-Roman", "MacRomanEncoding", 14.0)
pdf.rawTextAligned(72.0, 10.0, 0.0, ClibPDF::TEXTPOS_MM, "GoToR p.48")
pdf.endText

#act_dict = "/Type /Action /S /GoToR /D [47 /FitH 780] /F (../cpdfman110.pdf)"
act_dict = "/Type /Action /S /GoToR /D [47 /FitH 780] /F (../cpdfman200.pdf)"
pdf.rawSetLinkAction(0.0, 0.0, 144.0, 20.0, act_dict, NIL)

pdf.finalizeAll
pdf.savePDFmemoryStreamToFile("linkpdfpage.pdf")

#pdf.launchPreview
pdf.close()
