Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
LaTeX: to create xbb files (for use with dvipdfmx) only using pdfLaTeX
% bxxbb.sty
% package declaration
\ProvidesPackage{bxxbb}[2014/06/15 v0.1]
% preparationd
% environment check
\ifx\pdfoutput\@undefined\else \ifnum\pdfoutput>\z@
%% options
%--------------------------------------- public interface
% (now defined as no-op)
%%<*> \xbbquit
% Quit the TeX process now.
% (now defined as no-op)
% If not running on pdfTeX, stop loading the package.
\ifx t\bxxb@work\else
%--------------------------------------- main
% (e-TeX is assumed afterwards)
%% variables
%% \bxxb@pp : the string '%%'
\begingroup \escapechar\m@ne
%% redefinition
\PackageWarning\bxxb@pkgname{Quit now}%
%% \bxxb@maybe@quit
\ifx f\bxxb@autostop
%% \bxxb@write@xbb{<page>}{<image_file>}
% obtain bbox value
\edef\bxxb@x{\ifx\bxxb@x\@empty\else page \bxxb@x\fi}%
\pdfximagebbox\pdflastximage 1 \space
\pdfximagebbox\pdflastximage 2 \space
\pdfximagebbox\pdflastximage 3 \space
\pdfximagebbox\pdflastximage 4}%
% create xbb file
\bxxb@pp Title: #2^^J%
\bxxb@pp BoundingBox: \bxxb@bbox^^J%
\bxxb@pp HiResBoundingBox: \bxxb@bbox^^J%
\typeout{>> bbox of image '#2' = [\bxxb@bbox]}%
%--------------------------------------- done
%% EOF
% Write instructions for creating xbb files before \documentclass
% command. When this source file is compiled with pdfLaTeX, only
% this "pre-preamble" part will be executed.
% When the source file is compiled with a non-pdfLaTeX engine,
% the "pre-preamble" part will be ignored and the normal source
% lines thereafter will be processed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment