Skip to content

Instantly share code, notes, and snippets.

/**
* Shows how to restrict access using the HTTP "Basic" schema.
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication
* @see https://tools.ietf.org/html/rfc7617
*
* A user-id containing a colon (":") character is invalid, as the
* first colon in a user-pass string separates user and password.
*/
const BASIC_USER = "user";
const BASIC_PASS = "password";
require "hexapdf"
in1 = HexaPDF::Document.open("aaa.pdf")
in2 = HexaPDF::Document.open("bbb.pdf")
out = HexaPDF::Document.new
[in1.pages.to_a, in2.pages.to_a.reverse].transpose.flatten.each do |page|
out.pages << out.import(page)
end