forked from XmacsLabs/mogan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[29_6] add pdf format and conversion mechanism betwen tm and pdf
## Why you open this Pull Request? Previously, there were many drawbacks to opening PDFs through truncation, such as not being able to save properly, and detaching attachments may overwrite other files. These problems can be perfectly solved by adding pdf format and its conversion mechanism ## What work have you done in the current Pull Request? add pdf format and conversion mechanism betwen tm and pdf
1 parent
2d529ca
commit 28a3463
Showing
16 changed files
with
526 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<TeXmacs|2.1.2> | ||
|
||
<style|myslides> | ||
|
||
<\body> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim | ||
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea | ||
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate | ||
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat | ||
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id | ||
est laborum. | ||
|
||
\; | ||
|
||
<image|logo.pdf|0.3par|||> | ||
</body> | ||
|
||
<\initial> | ||
<\collection> | ||
<associate|page-medium|paper> | ||
</collection> | ||
</initial> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<TeXmacs|2.1.2> | ||
|
||
<style|<tuple|generic|british>> | ||
|
||
<\initial> | ||
<\collection> | ||
<associate|global-author|> | ||
<associate|global-subject|> | ||
<associate|global-title|29_1_1.tm> | ||
<associate|page-medium|paper> | ||
</collection> | ||
</initial> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<TeXmacs|2.1.2> | ||
|
||
<style|tsts/myslides> | ||
|
||
<\body> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod | ||
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim | ||
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea | ||
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate | ||
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat | ||
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id | ||
est laborum. | ||
|
||
\; | ||
|
||
<image|p/logo.pdf|0.3par|||> | ||
</body> | ||
|
||
<\initial> | ||
<\collection> | ||
<associate|global-author|> | ||
<associate|global-subject|> | ||
<associate|global-title|main.tm> | ||
<associate|page-medium|paper> | ||
</collection> | ||
</initial> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; | ||
;; MODULE : init-pdf.scm | ||
;; DESCRIPTION : setup pdf converters | ||
;; COPYRIGHT : (C) 2023 tangdouer | ||
;; | ||
;; This software falls under the GNU general public license version 3 or later. | ||
;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE | ||
;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. | ||
;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
(texmacs-module (pdf-format)) | ||
|
||
|
||
(define (texmacs->pdf x . opts) | ||
(let* ((tem-dir (url-temp-dir)) | ||
(tem-pdf (string->url (string-append (url->string tem-dir) "/tem.pdf"))) | ||
(tem-tm (string->url (string-append (url->string tem-dir) "/tem.tm"))) | ||
(tem-tm-out (open-output-file (url->string tem-tm))) | ||
(url-list (pdf-get-linked-file-paths x buffer-get))) | ||
(display* tem-dir "\n") | ||
(display (serialize-texmacs (pdf-replace-linked-path x buffer-get)) tem-tm-out) | ||
(close-output-port tem-tm-out) | ||
|
||
(let* ((cur (current-buffer)) | ||
(buf (buffer-new))) | ||
(buffer-set-master buf cur) | ||
(switch-to-buffer buf) | ||
(load-buffer tem-tm) | ||
(set-drd cur) | ||
(dynamic-make-slides) | ||
(print-to-file tem-pdf) | ||
(switch-to-buffer cur) | ||
(buffer-close buf)) | ||
;;attachment-list need be generated | ||
(if (pdf-make-attachments tem-pdf url-list tem-pdf) | ||
(display* "pdf-make-attachments return true\n") | ||
(display* "pdf-make-attachments return false\n")) | ||
(string-load tem-pdf))) | ||
|
||
(define (pdf->texmacs x . opts) | ||
(let* ((tem-dir (url-temp-dir)) | ||
(tem-pdf (string->url (string-append (url->string tem-dir) "/tem.pdf"))) | ||
(tem-tm (string->url (string-append (url->string tem-dir) "/tem.tm"))) | ||
(tem-pdf-out (open-output-file (url->string tem-pdf)))) | ||
(display* tem-dir "\n") | ||
(display x tem-pdf-out) | ||
(close-output-port tem-pdf-out) | ||
(if (extract-attachments tem-pdf) | ||
(noop) | ||
(display* "extract-attachments return false\n")) | ||
(set! tem-tm (url-relative tem-tm (pdf-get-attached-main-tm tem-pdf))) | ||
|
||
(if (url-exists? tem-tm) | ||
(display* tem-tm " exist\n") | ||
(display* tem-tm " not exist\n")) | ||
(pdf-replace-linked-path (tree-import tem-tm (url-format tem-tm)) tem-pdf))) | ||
|
||
(converter texmacs-tree pdf-document | ||
(:function texmacs->pdf)) | ||
|
||
(converter pdf-document texmacs-tree | ||
(:function pdf->texmacs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters