-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support attachfile Package #935
Comments
Hey @bradcarman, I've personally never worked with attached files on PDF before, could you provide a MWE and which PDF viewer you're using that supports them? |
@bradcarman I got some time to check this with Adobe Acrobat DC Tecctonic already includes the When compiling with either Package attachfile Warning: attachfile works _only_ with pdfLaTeX and LuaLaTeX
(attachfile) and _only_ in PDF-generating mode. For this run,
(attachfile) placeholders will be substituted for all
(attachfile) attachfile commands. It seems that XeTeX/Tectonic are missing the engine macros for From
Seems this lack of support was a deliberate decision from the package author. Looking for alternatives, there's the Finally, there's the MWE: \documentclass{article}
\usepackage{attachfile2}
\begin{document}
\attachfile{Test.png}
\end{document} Using it produces a file with an attachment, but when opening it with Acrobat DC the attachment name is an uncanny Do you know of other PDF readers that display attachments we could try? |
Firefox works just fine for that purpose (tested with the attachfile package documentation ). In my experimentation in windows attachfile2 produces a file with the correct name etc, ist just that it contains only "null". Which is the same behavior as when I reference a non-existing file (which fails silently btw, not great). I suspect that that is simply due to me using the v2 cli, where I'm not sure where tectonic is building the output? I also experienced issues with Did you enable EDIT: Yeah no, with v1 the document also only contains "null" |
Thanks, yes I can reproduce the issue with Firefox. Using When Tectonic is in a situation where none of the attaching files packages work, I believe that Also, whenever using XeTeX or a XeTeX-based engine, something of the attachment prevents it being displayed correctly under some PDF viewers like Adobe Acrobat DC. We might need to tackle that issue separately. @vlasakm You're good with the internals, any insight on this appreciated 💜 Output: warning: Tectonic does not support `config' special. Ignored.
warning: File "./Test.png" not found.
warning: Interpreting special command fstream (pdf:) failed.
warning: >> at page="1" position="(133.768, 667.198)" (in PDF)
warning: >> xxx "pdf:fstream @atfi_obj_1(./Test.png)<</Type/EmbeddedFile/Para..."
warning: >> Reading special command stopped around >><</Type/EmbeddedFile/Params<</Size 251184/ModDate(D:20221005...<<
warning: Cannot close undefined object @atfi_obj_1.
warning: Object @atfi_obj_1 used, but not defined. Replaced by null. |
A previous change left the `fullname` variable unconditionally set to `NULL`, which meant that all attempts to find streams would fail. The `fullname` variable is however no longer needed, since Tectonic doesn't have the two step Kpathsea file workflow (find full name + open), but it suffices to just open the file with `ttstub_input_open`. See tectonic-typesetting#935.
I agree that For these kinds of low level packages that deal with the output format (PDF, PostScript, HTML, DVI) one needs to look for My opinions, point by point:
Since this github issue is about
There are multiple things from the warnings:
This is #904. I didn't investagate how much this influences
This is the most crucial line. Though I must admit, that I missed it too. The next few lines is just the backtrace and the end is just the result of the file not being embedded (since it was not found). The fact that the file is not found is a mistake in the code, which unconditionally failed any attempt to find files to embed. This should also be fixed with #953. |
@vlasakm Thanks a lot! |
I forgot to mention that although the file gets embedded just fine, I get:
To be honest I have no previous experience with buffered reads in Rust, and the issue might be something in the layers of abstraction, so I didn't investigate further. |
A previous change left the `fullname` variable unconditionally set to `NULL`, which meant that all attempts to find streams would fail. The `fullname` variable is however no longer needed, since Tectonic doesn't have the two step Kpathsea file workflow (find full name + open), but it suffices to just open the file with `ttstub_input_open`. See tectonic-typesetting#935.
@9SMTM6 I had almost forgotten about |
@mnrvwl Sure. It appears to mostly work with v0.12.0 on windows % index.tex
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{python}
print("inline")
\end{minted}
\inputminted{python}{./test.py}
\end{document} # test.py
print("external") with v1 CLI: [doc]
name = 'v2cli'
bundle = 'https://data1.fullyjustified.net/tlextras-2022.0r0.tar'
[[output]]
name = 'default'
type = 'pdf'
shell_escape = true
shell_escape_cwd = "." As I said, it appears to mostly be working if one is setting Also the directory of With Perhaps xelatex just doesnt report execution errors? The reason I think that might be the case is the error: failed to execute the shell-escape command "for ^%i in (pygmentize.exe pygmentize.bat pygmentize.cmd) do set > default.aex <nul: /p x=^%~$PATH:i>> default.aex": execution of the request failed this looks like its just running a commend for every os (not an expert in whatever language that is tho) and looking what sticks. |
As far as I understand it from tracing it through release notes, merges etc, that commit is part of |
Currently, we only have `ttstub_input_read` function, which corresponds to Rust's `read_exact`. This seems to work for most of xetex, but it's not semantically a replacement for buffered reading with `fread`, which is used in a dvipdfmx. One of such places is reading a file to be included in a PDF file as attachment. This is done through dvipdfmx special like this: \special{pdf:fstream @sourcefile (example.txt)} These reads are done in 1024 byte chunks, and if we read these chunks with read_exact, we are going to fail unless the file size is not exactly divisible by 1024. Tectonic would report this as: warning: 1024-byte read failed caused by: failed to fill whole buffer To fix this issue in a non-intrusive way, we introduce a new variant of reads - `ttstub_input_read_partial`, which follows Rust's `read` semantics, and not `read_exact`'s, and we use it for the dvipdfmx fstream reading. Likely any place that calls `ttstub_input_read` in a loop is also a candidate for using `ttstub_input_read_partial`, and perhaps it would work better for others. But there definitely are places in xetex that depend on the `read_exact` semantics. For example, when I naively just tried to make all reads into `ttstub_input_read_partial`, xetex failed pretty quickly on "undumping the format file", which has a few initial 4 byte reads, but then it tries to undump big string pool which was many kilobytes in size. Rust `read` however would only return 8196 minus couple of the the 4 bytes, which would fail a check on the TeX side which expects full read. AFAICT xetex uses `fread`, so this probably just comes down to buffering differences between `fread` and Rust's `Reader` / `BufReader`. Relates to tectonic-typesetting#935 Fixes tectonic-typesetting#1260
If possible, it would be great if the "attachfile" package could be supported by Tectonic.
The text was updated successfully, but these errors were encountered: