Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Initialize
- public override void Initialize()
- {
- // define our routine for preparing to show a page.
- // This writes out some tags which we capture in the
- // callback to obtain the page size and orientation.
- this.Execute(string.Format(@"
- /GSNETViewer_PDFpage {{
- ({0}) print dup == flush
- pdfgetpage /Page exch store
- Page /MediaBox pget
- {{ ({1}) print == flush }}
- if
- Page /CropBox pget
- {{ ({2}) print == flush }}
- if
- Page /Rotate pget not {{ 0 }} if
- ({3}) print == flush
- }} def", PDF_PAGE_TAG, PDF_MEDIA_TAG, PDF_CROP_TAG, PDF_ROTATE_TAG));
- // put these in userdict so we can write to them later
- this.Execute(@"
- /Page null def
- /Page# 0 def
- /PDFSave null def
- /DSCPageCount 0 def
- ");
- // open PDF support dictionaries
- this.Execute(@"
- GS_PDF_ProcSet begin
- pdfdict begin");
- }
- #endregion
- #region Open
- public override void Open(string filePath)
- {
- // open PDF file
- this.Execute(string.Format("({0}) (r) file pdfopen begin", filePath.Replace("\\", "/")));
- this.Execute("/FirstPage where { pop FirstPage } { 1 } ifelse");
- this.Execute("/LastPage where { pop LastPage } { pdfpagecount } ifelse");
- // flush stdout and then send PDF page marker to stdout where we capture the page numbers via callback
- this.Execute(string.Format("flush ({0}) print exch =only ( ) print =only (\n) print flush", PDF_PAGES_TAG));
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement