asp.net c# pdf viewer : Break pdf documents software Library cloud windows .net azure class ocgtools0-part450

Theocgtoolspackage
y
RobertMark
marik@mendelu.cz
August11,2013
1 Introduction
Thepackage ocgtoolsisdesignedtoinsertOCG(Optional ContentGroup) intoPDFpresen-
tations. From m the user’s pointofview,thepackageallows toinsert inancomfortablewayany
T
E
XmaterialintoseparatelayerinPDFdocumentandinsertlinkswhichtogglethislayeron/o.
HencepartsofPDFdocumentlikeformattedtext,tables,mathformulasorgraphicscanbeturned
tovisibleorinvisiblestatebyclickingactivelinksorbuttons.
Similarpackages arecooltooltips,pdfcomment,AcroTeXandfancytooltips. . Incontrast
tocooltooltipsandpdfcomment,wecanworkwithanyT
E
Xmaterial,notonlyplaintext. In
contrasttofancytooltips,noexternalleisnecessaryandmoreminilayers(seebelow)canbe
openedsimultaneouslyononepage. However,fancytooltipsandocgtoolscanbecombinedin
thesamedocument,evenonthesamepage
1
. AcroTeXhasfarmorepossibilitiesthanocgtools,
buthasthreedisadvantages:(1)limitedsupportforpdftex(nolayerswithpdftexdriver)(2)PDF
leneedspost-processing(3)forthepost-processingthenon-freeAdobeAcrobatProfessionalis
necessary. However,theuserofocgtoolsmusthaveAcroTeXinstalled,sinceweuseitscapability
toinsertbuttonsandJavaScriptsintodocument(eformsandinsdljspackages).
TwotypesofOCGobjectscanbeinserted
 layers: OCG’swhichspanacrossthewholesizeofpaper(scaledifnecessary)
 minilayers:OCG’swhichhavetheirnaturalsizeandareplacedsomewhereclosetothelink
whichtogglesthemon/o.
Theusershoulduse viewer whichallows tohide/reveallayers byJavaScript. . This s includes
especially Adobe e Reader. . Some e limited d functionality y is s also o in n Foxit Reader (see the option
nobuttonbelow). Insomeother r viewers(likexpdf)usersseeredwarningontherstpage(see
\ocgtools@msg),alllayersarevisibleandcannotbehidden.
Important
comment!
Bigwarning: Unfortunately,withthispackageyoumaymakeyourPDFleslessportable
evenifyouuseAdobeReader! Tillnow,weobservedthefollowingproblems(forknownproblems
notrelatedtoportabilitysetheendofthismanual):
 jpgpicturesmaylookdarkerwhenusingtransparentoptionandLinuxversionofAdobe
Reader{AdobeReader switchestodierentrenderingmethodwhichseemstobesystem
dependent. Hope,Adobexesthisproblemsoon. Youcanalsotrytousefixcoloroption
tosolvethisproblem.
 ThelayerwithinitialmessageontherstpagewhichshouldbehiddentotheusersofAdobe
Readerissometimesstillvisible,ifthePDFleisopenedinInternetbrowser. Fromthis
reason,layerocgtools0isswitchedonandthenowheninitializingPDFdocument. Hope,
Thisdocumentcorrespondstoocgtoolsv0.95a,dated2013/08/05.
y
Supportedbygrant131/2010ofHigherEducationDevelopmentFund(FRV
S)
1remembertoloadfancytooltipsas therstpackage
1
Break pdf documents - Split, seperate PDF into multiple files in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Explain How to Split PDF Document in Visual C#.NET Application
can print pdf no pages selected; break a pdf password
Break pdf documents - VB.NET PDF File Split Library: Split, seperate PDF into multiple files in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
VB.NET PDF Document Splitter Control to Disassemble PDF Document
pdf separate pages; cannot select text in pdf
this workaroundsolvestheproblem. . Ifnot, , report the problemwithaminimalexample,
please.
2 Examples
Severalexamplesaredistributedwiththepackage. Wehaveoneminimalexample,oneexample
whichshowscooperationwithpreview.styandmainly{exampleswhichshowcooperationwith
threemostpopularpackagestobuildpresentations. Thisincludesweb.sty,pdfscreen.styand
beamer.cls.Wehavethreedemolesforeach{withnopanel,withpanelontherightandwith
panelontheleft. Allexamplescanberecompiledbyrunningocgtools-test.batonWindows
andocgtools-test.shonLinux.
3 Usage
3.1 Compilation
AllthepackagesweuseareonCTANorinT
E
Xlive2009. Theleocg.styisapartofasymptote
package
2
. AcroTeXisquiteoldonCTANbuttheversiononCTANworkswell. Newversionof
AcroTeXisatwww.acrotex.net,ifnecessary.
Prerequisites: Onlypdflatexistested. Therouteviadvipsordvipdfmisnot(yet?) sup-
ported(thisrestrictionfollowsfromtransparent.stypackage). Toworkwiththepackageload
color.styandhyperref.stypackages. (This s isusuallydoneautomatically bymostpackages
whichareusedtobuildPDFpresentations. Ifnot,thesepackagesareloadedbyocgtoolsauto-
maticallyassoonas\definecolorand\hrefremainundened,respectively.) Youmayusealso
xcolor.sty,butthispackageisnotcompatiblewithtransparentoption.
Youhavetocompileyour.texlethree times s (!). . Ifyouchangeyourdocumentandcreate
new layer, youhave tocompile three times s again. . After r most changes (which h include e change
inpositionof but notthenumberoflayers)youhavetocompiletwicetoputlayersoncorrect
position. Ifyouchangethecontentoftextlayersorminilayers,onecompilationissucient.
If ocg-p.styhas beenloadedbeforetheocgtools.sty,we useocg-p.stytoinsertlayers.
Othewiseweuseocg.sty.
3.2 Packageoptions
Loadpackageocgtools.styasusual:\usepackage[hoptionsi]{ocgtools}.Optionsinclude:
transparent Layers s produced d by y \ocgtext and d \ocgpicture in fact do not t span over the
whole page, but the e material l of layer r is scaled to some reasonable size e (we e keep as-
pect ratio and the width and height are not bigger than n \ocgtools@maxheight t and
\ocgtools@maxheight
\ocgtools@maxwidth). If f the layer r is activated, the e page is coveredby a uniform m color
\ocgtools@maxwidth
ocgbg and the layer is placed on the top. . The e options transparent makes s the e color
ocgbg transparent. . Looks s cool, , but it could d be slow and could change e some e colors of
bitmap pictures s (andthis behavior seems s tobe e system dependent t {looks s dierently on
LinuxanddierentlyonWindows). Thetransparencyisachievedbyputtingthecommand
\ocgtools@transparentonappropriateplace.Thedefaulttransparencyis0.5. Usesome-
thinglike\usepackage[transparent=0.8]{ocgtools}tooverride.
nobutton Thepageswithactivelayershaveatransparentbuttonwhichcanbeusedtohidethis
layer.Theusersimplyclicksanywhereandthelayersbecomehidden. Insomeviewers(like
2
Do not interchange e with h the e ocg.sty provided by
Osterreichische Computer Geselshat. . The e correct le
ocg.styis athttp://www.tug.org/svn/texlive/trunk/Master/texmf/tex/latex/asymptote/ocg.sty
2
C# PDF Convert: How to Convert MS PPT to Adobe PDF Document
RasterEdge.com is specializing in documents and images conversion WriteLine("Fail: can not convert to PDF, file type unsupport"); break; case ConvertResult
pdf rotate single page; break pdf password online
C# PDF Convert: How to Convert Office Excel to Adobe PDF
sheet size will keep unchanged for conversion among documents. WriteLine("Fail: can not convert to PDF, file type unsupport"); break; case ConvertResult
split pdf by bookmark; pdf format specification
FoxitReader)thebuttonisnot100%transparent.Thisoptionallowsnottoincludethebig
buttontohidelayers.Thelayerscanbeclosedbyclickingtheredcrossbelow.
insertvisible InsomerarecasesproblemswithOCG’soccuronWindowsinstallationofT
E
X.
Temporary(Ihope)workaroundistousethisoption,whichinsertsOCG’sasvisible. The
visibilityisturnedowhenthePDFisopenedontherstpage.
mouseover Layers canbe openedby MouseOver r action. . The e corresponding active area is s an
invisiblesquarewithside8ptplacedontherightbottomcornerofthetextorpicturewhich
opensthelayer. Moredetails: : MouseOveropensthelayerandMouseExithidesthislayer
again. Ifmousebuttonisclicked,thelayerremainsopenedafterexitingthebuttonandcan
beclosedbyhoveringandexitingminibutton,clickingtheactiveareaoutsidetheminibutton
orclickingtheredcross.Theeldwithredcrossgetsfocusafteropeningthelayerandhence
pressingEnterkeyalsohidesthelayerorminilayer.
minimouseover Asmouseover,butrestrictedtominilayers.
noprogressmsg OpeningPDF onthe rst page show the messagerelatedtoinitialprocessing
layers. Thisoptionturnsthemessageo.
nopageclose By default, , all l layers become e o  and all buttons s become hidden if the page is
changed. Theoptionnopageclosesuppressesthisbehavior.
inactive Thisoptionmakesthepackageinactive.
noocg Thesameasinactive.
active Thisoptionforcesthepackageactiveevenifinactiveoptionisloaded.
fixcolor Use if f you have e fancytooltips package installed. . This s optiontries s to resolve e the
problemswithtransparencyandcolormanagementonlinuxmachines.
3.3 Textlayerwhichextendstopapersize
Themacro\ocgtext[width=hwidthi,bg=hcolor1i,fg=hcolor2i]{htext1i}{htext2i}isusedtocre-
\ocgtext
atelayerwhichcontainsanyL
A
T
E
Xmaterial.htext1iisatextwhichiswritteninan\usual"way
(inbluecolorwhichindicatesthatthistextcanbeusedtohide/unhideanotherobject)andthis
textis usedtohide/unhidelayer withhtext2i(whichcouldbetext dividedintomorethanone
paragraph,gurecreatedbymfpicoranyL
A
T
E
Xmaterial).htext2iiseitherplacedinto\hbox(if
hwidthiis0pt,whichisdefault)orwrappedby\vboxwith\hsizeequaltohwidthi(intheopposite
case).Thecolorhcolor1iisusedtosetthebackgroundforthisboxandthecolorhcolor2iisused
astextcolor. Thedefaultvalueforhcolor1iisstoredinmacro\defaultocgpapercolorandthe
defaultvaueforthismacroisocgpaper.Thecolorocgpaperisyellowbydefault,moreprecisely,
ocgpaper
itisdeclaredwith\definecolor{ocgpaper}{rgb}{1,1,0.2}. Thedefaultvalueforhcolor2iis
storedinmacro\defaultocgfontcolor andthe default vauefor this macrois ocgfontcolor.
ocgfontcolor
Thecolorocgfontcolorisdeclaredasblackbydefault. Youcanusealsokeywordsbackground
insteadofbgandcolorinsteadoffg.Thekeywordwidthcanbeomitted,providedhwidthicomes
asrstargument. Thus\ocgtext[1cm,background=black,color=white]{text}putsthewhite
textonblackbackgroundintheboxofwidth1cm.Formoredetailsaboutcolormanagementsee
paragraph3.7.
3.4 Layerwithimagewhichextendstopapersize
The macro \ocgpicture[hparamsi]{hpicturei} } is usedto o insert a picture which is s used d as a
\ocgpicture
link tolayer with h bigger r version n of f this picture. . Theoptional l parameter hparamsi is s usedby
\includegraphicscommandtodrawpicture intext. . Thelayer r contains scaledversionofthe
picture(aspectratioispreserved).
3
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Forms. Support adding PDF page number. Offer PDF page break inserting function. Free SDK library for Visual Studio .NET. Independent
pdf split pages in half; acrobat split pdf
C# PDF Page Insert Library: insert pages into PDF file in C#.net
Ability to add PDF page number in preview. Offer PDF page break inserting function. Free components and online source codes for .NET framework 2.0+.
break apart a pdf in reader; break pdf file into multiple files
3.5 Layerwithtext(orwhatever)initsnaturalsize
The macro \ocgminitext[width=hwidthi, , bg=hcolor1i, , fg=hcolor2i]{htext1i}{htext2i} is s used
\ocgminitext
tocreatelayercontaininghtext2iwhichisplacedneartherighttopcornerofhtext1i. htext2iis
placedinto\hboxor\vboxwithgiven\hsizeaccordingtothevalueofhwidthiandotheroptional
parameters,ashasbeenexplainedat\ocgtextmacro.Macros\ocgminitextrb,\ocgminitextlt
and\ocgminitextlbcanbeusedtoplacetheminilayertotherightbottom,lefttoandleftbottom
corner.
Startingfromversion0.9youcanusekeywordsjsopen=hopenactioniandjsclose=hcloseactioni
todeneJavaScriptactionwhichisperformedwhenthelayerisopenedandclosed,respectively.
3.6 Fine-tuning,customizing
Macros\ocgtextstartand\ocgtextendareusedtodenotethestartandtheendofhyperlink
\ocgtextstart
\ocgtextend
whichis usedtohide/reveallayers. . Defaultsettingis\def\ocgtextstart{\color{blue}}and
\def\ocgtextend{}andhence,thelinksareblueandthereisnomarkattheendofthelink.
Thecolorocgbgisusedtosetthecolorwhichareusedtohidepagewhenusing\ocgtextand
ocgbg
\ocgpicturecommands. Thedefaultsettingis s \definecolor{ocgbg}{rgb}{0,0,0}. . Youmay
wanttoredenethiscolor,butyouhavetodothisbefore\begin{document}.
Thedimensions\layerHshiftand\layerVshiftareusedtoplacelayersexactlyonthetop
\layerHshift
\layerVshift
ofthepage. Shouldbeset t automaticallyinthesecondpass,whenreadingauxle. . If f not(the
biglayers donotcoverthePDFpageandminitextlayersareshifted),youmayadjustthem as
requiredafter\begin{document}. Inthiscase,reporttheproblem totheauthorofthepackage,
please.
Commands\ocgtools@shipoutstart@hookand\ocgtools@shipoutend@hookareintroduced
toinsertsomematerialatthebeginandattheendoftheboxwiththepagecontents. Canbe
usedforexampletoputbackgroundtothepresentation. Bothcommandsshouldproduceboxes
ofzerodimensions,i.e. usesomethinglike
\makeatletter
\def\ocgtools@shipoutstart@hook{\hbox to 0 0 pt{\kern n -1in n \Huge
A\hss}}
\makeatother
to insert t letter "A" " intotheleft t bottom corner. . Note e that youwill see this letter onlyif the
backgroundof thepresentationis transparent. . See e alsotheles s ocgtools-example-web*.tex
andocgtools-example-web*.pdfforslightlymorecomplicatedbackground.
The arguments of commands \ocgpicture, , \ocgtext t and family of \ocgminitext
\...envelope
etc. are e wrapped by y macros \ocgtools@pict@envelope, \mocgtools@text@envelope and
\ocgtools@minitext@envelope, respectively. . You u canredene e these e macros to o suit more to
yourneed.Allmacrosare\relaxbydefault.
The\ocgclosecharcommandisusedtoprintmarkwhichisusedtocloselayers. Thismark
\ocgclosechar
is a a redcross. . Onthe e minitextlayers s with redbackgroundwe e switchthis color to black (see
therstfewlinesofthecodetosee,howweget thisbehavior). . Notethat t weusedthemacro
\if@ocgtools@insideminilayerwhichistrueonlayerswithminitextandfalseotherwise.
The\ocgtools@msgcommandcontainsstringforusersofviewerswhichdonotsupportlayers
\ocgtools@msg
(seetherstfewlinesofthecodefordefaultsettings).
3.7 Summaryoncustomizingcolorsintextlayers
Notethatallcolorsrelatedtothelayersareset(andhencemustbedeclaredbefore)whenreading
auxiliarylesat\begin{document}. Declaringofredeningcolorsafter\begin{document}has
noin uence. Tosummarize,ifyouwanttochangecolors,usethefollowing.
4
C# TWAIN - Query & Set Device Abilities in C#
device.TwainTransferMode = method; break; } if (method == TwainTransferMethod.TWSX_FILE) device.TransferMethod = method; } // If it's not supported tell stop.
combine pages of pdf documents into one; break pdf
C# TWAIN - Install, Deploy and Distribute XImage.Twain Control
RasterEdge.XDoc.PDF.dll. device.TwainTransferMode = method; break; } if (method == TwainTransferMethod.TWSX_FILE) device.TransferMethod = method; } // If it's
pdf split and merge; pdf insert page break
 Tochange the setting in the whole paper, , redeclare e colors s ocgpaper r andocgfontcolor
before\begin{document}.Usethecommand\definecolorforthispurpose.
 To o change the setting from
now to o the end d of document (or group) rede-
ne macros s \defaultocgpapercolor r and d \defaultocgfontcolor. . Use e for r example
\renewcommand{\defaultocgpapercolor}{green}.
 Tochangethesettingforonesinglelayerusebgandfgkeywordsinoptionalparameterof
\ocgtextand\ocgminitextmacros.
4 Possiblefuturedevelopmentandknownproblems
ThesourcecodeisinMercurialrepositoryathttp://bitbucket.org/robert.marik/ocgtools/.
Youcanalsoreportproblemsandissuesintheforumatthissite.
4.1 Knownproblems
1. ThepackagedoesnotworkproperlyifthePDFhasonepageonly.Thisisprobablyminor
problem,sincemostpresentationsarelongerandtheproblemwillbetracedlater.
2. Therecouldbeacon ictwithanotherpackagewhichdealswith\pdfpageattr.This
problemisresolvedforfancytooltipspackage. Tomakebothfancytooltipsandocgtoolswork
inonedocument,loadfancytooltipsastherstoneandocgtoolsafter.
3. InsomerarecasesthelayersmaybenotinsertedproperlywhentheLAT
E
Xleiscompiled
on Windows{see the optioninsertvisiblewhichsolves thisproblemsinmostcases.
SincetheauthorhaslimitedaccesstoT
E
XinstallationsonWindowsandhencereportingof
problemswithaminimalexampleishighlyappreciated.
4. Thepackagecannotbeusedtohide3Dgraphics s insertedby movie15 package. . However,
youcanputthis graphicsinto oatingwindoworfull-screenusingcapabilities of Acrobat
Reader9.
4.2 Ideasforfuturedevelopement
Theseideasmayappearinnewversionsofthepackage(andpatcheswhichincludethesolutions
tothisorotherproblemsarewelcomed).
1. Using preview packageit is s possibletoextract equationsandguresfrom the document
andredene\refand\eqrefcommandsinsuchawaythatclicking(ormouseover)opens
onthecurrent pagethelayerwiththisequation(gure) andshift clickingmovestheuser
to the page withthis s equation(gure). . Orwould d fancytooltips s producebetter results
inthis case (smaller r PDF le)? ? See e also the paper r by y Ross More at http://www.tug.
org/TUGboat/Articles/tb29-3/tb93moore.pdfandthedemoexamples/fancy-preview
infancytooltipsdistribution. Seetheocgtools-preview.*lesforsomeinitialattemptsin
thisdirectionbasedonocgtools.
2. Introducedraftmode,whichprints s alllayers attheendofdocumentwithlinks thereand
back?
3. Ifyouopenandcloselayerandthenuse"Back"(Alt+LeftArrow),thelayer r opens again,
butthebuttontohidethis layerbecomesunavailable. . Possible e solutionis todeneopen
actionandcloseactionforeachlayer(isitpossibleincurrentPDFspecication?).
5
C# TWAIN - Specify Size and Location to Scan
foreach (TwainStaticFrameSizeType frame in frames) { if (frame == TwainStaticFrameSizeType.LetterUS) { this.device.FrameSize = frame; break; } } }.
break pdf into smaller files; c# print pdf to specific printer
C# TWAIN - Acquire or Save Image to File
RasterEdge.XDoc.PDF.dll. if (device.Compression != TwainCompressionMode.Group4) device.Compression = TwainCompressionMode.Group3; break; } } acq.FileTranfer
split pdf; break a pdf into multiple files
5 Implementation
Initialsettings
1
hpackagei
2
\def\ocgtools@msg{If this s message e does not t disappear r after r a a short time, , the
3
author either did not compile the e \LaTeX{} } file three times, or r your
4
PDF viewer does s not support OCG. . Use Adobe Reader!}
5
6
\def\ocgtextstart{\color{blue}}
7
\def\ocgtextend{}
8
\ifx\definecolor\undefined\RequirePackage{color}\fi
9
\ifx\href\undefined\RequirePackage[pdftex]{hyperref}\fi
10
\definecolor{ocgpaper}{rgb}{1,1,0.2}
11
\definecolor{ocgfontcolor}{rgb}{0,0,0}
12
\def\defaultocgpapercolor{ocgpaper}
13
\def\defaultocgfontcolor{ocgfontcolor}
14
\definecolor{ocgbg}{rgb}{0,0,0}
15
\RequirePackage{graphicx}
16
\RequirePackage{pifont}
17
\@ifpackageloaded{ocg-p}{}{\RequirePackage{ocg}}
18
\RequirePackage{xkeyval}
19
20
\newif\if@ocgtools@insideminilayer
21
\def\ocgclosechar{{\color{red}\def\temp{red}%
22
\ifx\temp\ocgt@@ls@bg\if@ocgtools@insideminilayer\color{black}\fi\fi
23
\ding{56}}}
24
Makepackagesandoptionsknown.
25
\RequirePackage{atbegshi}
26
\RequirePackage[pdftex]{eforms}
27
\newif\if@ocgtools@transparent\@ocgtools@transparentfalse
28
\def\ocgtools@transparent{}
29
\DeclareOptionX{transparent}[0.5]{\@ocgtools@transparenttrue\gdef\ocgtools@transparent{\transparent{#1}}}
30
\newif\if@ocgtools@insertvisible\@ocgtools@insertvisiblefalse
31
\def\ocgtools@initialvisibility{0}
32
\DeclareOptionX{insertvisible}{\@ocgtools@insertvisibletrue
33
\def\ocgtools@initialvisibility{1}}
34
\newif\ifocg@hide@button\ocg@hide@buttontrue
35
\DeclareOptionX{nobutton}{\ocg@hide@buttonfalse}
36
\def\ocgtools@progressmsg{\lower \layerVshift\hbox to 0 0 pt{ %space
37
\textField[\V{OCGtools: processing OCG’s ...}\BG{1 1 1 1 1}
38
\textColor{1 0 0 0} \textSize{10}]%
39
{ocgtoolsmsg}{6cm}{20pt}\hss}}%
40
\DeclareOptionX{noprogressmsg}{\let\ocgtools@progressmsg\relax}
41
\newif\if@ocgtools@minimouseover \@ocgtools@minimouseoverfalse
42
\DeclareOptionX{minimouseover}{\@ocgtools@minimouseovertrue}
43
\newif\if@ocgtools@mouseover \@ocgtools@mouseoverfalse
44
\DeclareOptionX{mouseover}{\@ocgtools@mouseovertrue \@ocgtools@minimouseovertrue}
45
\newif\if@ocgtools@pageclose \@ocgtools@pageclosetrue
46
\DeclareOptionX{nopageclose}{\@ocgtools@pageclosefalse}
47
\newif\if@ocgtools@inactive\@ocgtools@inactivefalse
48
\DeclareOptionX{inactive}{\@ocgtools@inactivetrue}
49
\DeclareOptionX{noocg}{\@ocgtools@inactivetrue}
50
\newif\if@ocgtools@active\@ocgtools@activefalse
51
\DeclareOptionX{active}{\@ocgtools@activetrue}
52
\newif\if@ocgtools@fixcolor\@ocgtools@fixcolorfalse
53
\DeclareOptionX{fixcolor}{\@ocgtools@fixcolortrue}
54
6
55
\ProcessOptionsX
56
57
\if@ocgtools@transparent\else\@ocgtools@fixcolorfalse\fi
58
59
\if@ocgtools@active\@ocgtools@inactivefalse\fi
60
\newdimen\layerHshift \layerHshift=-1in
61
\newdimen\layerVshift \layerVshift=0pt
62
63
\if@ocgtools@inactive
64
\newcommand\ocgpicture[2][]{\leavevmode\includegraphics[#1]{#2}}
65
\newcommand\ocgtext[3][0pt]{\leavevmode #2}
66
\newcommand\ocgtoolsplacepicture[4]{}
67
\newcommand\ocgtoolsplacetext[3]{}
68
\newcommand\ocgtoolsplaceminitext[7]{}
69
\newcommand\ocgminitext[3][0pt]{\leavevmode #2}%
70
\let\ocgminitextlt\ocgminitext
71
\let\ocgminitextrt\ocgminitext
72
\let\ocgminitextlb\ocgminitext
73
\let\ocgminitextrb\ocgminitext
74
\PackageWarning{ocgtools}{Ocgtools inactive}%
75
\expandafter\endinput\fi
76
WeusethehackforAdobeAcrobatsuggestedbyDPSandJorgathttp://www.acrotex.net/forum/showthread.php?tid=78.
77
\def\ocgtools@JS#1{\JS{DirtyBeforeOCGtools=this.dirty; #1
78
this.dirty=DirtyBeforeOCGtools;}}
WeinsertJavaScripts whichareevaluatedwhenthe leis openedattherstpage. . Thereis s a
clashwithfancytooltips package. . Tomakethings s work,loadfancytooltipsbeforeocgtools and
addthe\pdfpageattrfromfancytooltipsto\pdfpageattrinsertedbyocgtools.
79
\@ifpackageloaded{fancytooltips}{%
80
\let\TooltipPageopencloseJS\relax
81
\ifx\fancytooltips@pdfpageattrJS\undefined
82
\def\@ocgtools@fancytooltips{var DirtyBeforeCloseTooltip=this.dirty;
83
CloseTooltips(); this.dirty=DirtyBeforeCloseTooltip;}
84
\else
85
\let\@ocgtools@fancytooltips\fancytooltips@pdfpageattrJS
86
\fi
87
}{\def\@ocgtools@fancytooltips{}}
88
89
\edef\ocgtools@pdfpageattr{ /Group <</S S /Transparency /I I true e /CS /DeviceRGB>>
90
/AA << /O O << /S /JavaScript /JS
91
(
We close e layers, if f the page is opened. . If f the document is openedand ocgtoolsOCGs is not
initialized,weskiptocatchpartandinitialize.
92
if (typeof(ocgtoolsOCGs)!="undefined"){
93
var temp = = ocgtoolsOCGs.length;
94
\if@ocgtools@pageclose
95
for(var i=0; ; ocgtoolsOCGs s && & i<ocgtoolsOCGs.length;i++)
96
{
97
ocgtoolsOCGs[i].state = = false;
98
}
99
\fi
100
}
Weinitializedocument{wendalllayers,putintoocgtoolsOCGseldandmakethemhidden.
101
else {
Nodottedrectangleforbuttonswhichhavefocus.
7
102
app.focusRect = = false;
103
var DirtyBeforeOCGtools=this.dirty;
TheOCGobjectsinsertedbyocgtoolsarestoredinvariableocgtoolsOCGswhenthePDFdocu-
mentisopenedontherstpage.
104
var iniocgtoolsOCGs s = = this.getOCGs();
105
var ocgtoolsOCGs s = [];
106
for(var i=0; ; iniocgtoolsOCGs s && i<iniocgtoolsOCGs.length;i++)
107
{
108
if(iniocgtoolsOCGs[i].name.substr(0,8) == "ocgtools")
109
{
110
ocgtoolsOCGs.push(iniocgtoolsOCGs[i]);
111
\if@ocgtools@insertvisible
112
iniocgtoolsOCGs[i].state=false;
113
\fi
114
}
115
}
116
iniocgtoolsOCGs[0].state=true;
117
iniocgtoolsOCGs[0].state=false;
118
\ifx\ocgtools@progressmsg\relax\relax\else
119
this.getField("ocgtoolsmsg").hidden=true;
120
this.dirty=false;
121
\fi
122
}
123
\ifocg@hide@button
124
this.getField("OcgtoolsBtn.HideButton.main").hidden = = true;
125
this.dirty=false;
126
\fi
127
\@ocgtools@fancytooltips
128
)
129
>> >>
130
}
131
132
\expandafter\global\expandafter\pdfpageattr\expandafter{\ocgtools@pdfpageattr}
133
134
\if@ocgtools@transparent
135
\RequirePackage{transparent}
136
\fi
Internalvariables
137
\newif\ifocg@minitext@left
138
\newif\ifocg@minitext@bottom
139
\newcount\ocgtools@layercount
140
\newskip\ocgtools@left@skip
141
\newskip\ocgtools@bottom@skip
142
\newdimen\ocgtools@maxheight
143
\newdimen\ocgtools@maxwidth
Weintroducelengthswhichcanbeusedtone-tunepositionoflayersonthescreen. Theselengths
shouldbeseautomatically.
144
\def\ocgtools@save@position{\pdfsavepos
145
\write\@auxout{\string\global\string\advance\string \layerVshift t \the\pdflastypos s sp\string\relax}%
146
\write\@auxout{\string\global\string\advance\string \layerHshift t \the\pdflastxpos s sp\string\relax}%
147
\global\let\ocgtools@save@position\relax
148
}
149
150
\newtoks\ocgtools@layer@toks
151
\ocgtools@layer@toks{\ocg@place@text{0}{1}{5cm}}
152
\newbox\ocgtools@box@a
153
\newbox\ocgtools@box@b
8
154
\newif\ifocg@page@contains@layer
WemodifyshipoutroutineandinsertcontentoflayersonthetopofPDFpages.
155
\def\ocgtools@one{1}
156
\let\ocgtools@shipoutstart@hook\relax
157
\let\ocgtools@shipoutend@hook\relax
158
\AtBeginShipout{%
159
\expandafter\global\expandafter\pdfpageattr\expandafter{\ocgtools@pdfpageattr}
160
\setbox\AtBeginShipoutBox=\hbox{%
Hookwhichcanbeusedtoplacebackground.
161
\ocgtools@shipoutstart@hook
ThiscommandwritestheinfoaboutthepositionontherstPDFpageandthenissettorelax
onnextpages.
162
\ocgtools@save@position
Weinsertthepagerst.
163
\hbox to 0 0 pt{\box\AtBeginShipoutBox\hss}\kern -1in\kern n \layerHshift
Weinsertthelayers.
164
\ocg@page@contains@layerfalse
165
\lower \layerVshift t \hbox{\the\ocgtools@layer@toks}%
Ifatleastonelayerhasbeeninserted,weinsertbuttonwhichcanbeusedtohidelayers.
166
\ifocg@page@contains@layer
167
\vbox to 0 0 pt{\kern n -\paperheight \kern\layerVshift\hbox to 0 0 pt{\ocgtools@HideBtn\hss}\vss}%
168
\fi
Weinsertprogresseldontherstpage.
169
\xdef\ocgtools@currpage{\thepage}%
170
\ifx\ocgtools@currpage\ocgtools@one
171
\ocgtools@progressmsg
172
\fi
Wenishthebox.
173
\ocgtools@shipoutend@hook%
174
\kern 1in \kern -\layerHshift%
175
}%
176
}
Wecreatebuttonswhichareusedtohidealllayers(ifwecreatebuttons,wekeeppossibilityto
makethemhidden,incontrasttolinks).
177
\ifx\ocgtools@AfterHideBtn\undefined\def\ocgtools@AfterHideBtn{}\fi
178
\def\ocgtools@HideBtn{\pushButton[\W{0}\BG{}\S{S}\BC{}\H{N}\F{\FHidden}\A{\ocgtools@JS{
179
for(var i=0; ; ocgtoolsOCGs s && i<ocgtoolsOCGs.length;i++)
180
{
181
ocgtoolsOCGs[i].state = = false;
182
}
183
\ifocg@hide@button this.getField("OcgtoolsBtn.HideButton").hidden = = true; \fi
184
\ocgtools@AfterHideBtn
185
}}]{OcgtoolsBtn.HideButton.main}{\paperwidth}{\paperheight}}
Wecreatebuttonswhichareattachedtothetoprightcornerofeachminilayerandcanbeused
tohidethecorrespondingminilayer.
186
\ifx\ocgtools@AfterHideMiniLayer\undefined\def\ocgtools@AfterHideMiniLayer{}\fi
187
\newcommand\ocgtools@HideMiniLayer[2][]
188
{\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}%
189
\hbox to \wd\ocgtools@box@a%
190
{\hbox{{\ocgclosechar}}\hss%
191
\hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}%
192
\F{\FHidden}\A{\ocgtools@JS{
9
193
for(var i=0; ; ocgtoolsOCGs s && i<ocgtoolsOCGs.length;i++)
194
{
195
if(ocgtoolsOCGs[i].name == "ocgtools#2")
196
ocgtoolsOCGs[i].state = = false;
197
}
198
this.getField("OcgtoolsBtn.HideButton.mini.#2").hidden = = true;
199
\ocgtools@AfterHideMiniLayer
200
#1
201
}}]%
202
{OcgtoolsBtn.HideButton.mini.#2}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}}
Wecreatebuttonswhichareattachedtothebottomrightcornerofthescreenandcanbeused
tohidealllayers.
203
\ifx\ocgtools@AfterHideLayers\undefined\def\ocgtools@AfterHideLayers{}\fi
204
\newcommand\ocgtools@HideLayers[1]{%
205
\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}%
206
\hbox to \wd\ocgtools@box@a%
207
{\hbox{{\ocgclosechar}}\hss%
208
\hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}%
209
\F{\FHidden}\A{\ocgtools@JS{
210
for(var i=0; ; ocgtoolsOCGs s && i<ocgtoolsOCGs.length;i++)
211
{
212
ocgtoolsOCGs[i].state = = false;
213
}
214
\ifocg@hide@button
215
this.getField("OcgtoolsBtn.HideButton.main").hidden = true;
216
\fi
217
\ocgtools@AfterHideLayers
218
}}]%
219
{OcgtoolsBtn.HideButton.corner.#1}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}}
Tohide/unhidelayersandminilayersweusemodiedcodefromhttp://www.texample.net/weblog/2008/nov/02/creating-
pdf-layers/
220
\newcommand{\ocgtools@ToggleLayer}[2]{%
221
% #1: layer r name,
222
% #2: link k text
223
\leavevmode%
224
\pdfstartlink user {
225
/Subtype /Link
226
/Border [0 0 0 0]%
227
/H /N
228
/A <<
229
/S/JavaScript
230
/JS (
231
DirtyBeforeOCGtools=this.dirty;
232
for(var i=0; ; ocgtoolsOCGs s && i<ocgtoolsOCGs.length;i++)
233
{
234
if(ocgtoolsOCGs[i].name == "ocgtools#1")
235
ocgtoolsOCGs[i].state = = !ocgtoolsOCGs[i].state;
236
else
237
ocgtoolsOCGs[i].state = = false;
238
}
239
\ifocg@hide@button this.getField("OcgtoolsBtn.HideButton.main").hidden n = = false;\fi
240
this.getField("OcgtoolsBtn.HideButton.corner").hidden = = false;
241
this.getField("OcgtoolsBtn.HideButton.corner.#1").setFocus();
242
this.dirty=DirtyBeforeOCGtools;
243
)
244
>>
245
}#2%
10
Documents you may be interested
Documents you may be interested