sillsdev / ptx2pdf

XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
21 stars 7 forks source link

Import Settings from ZIP archive - with custom .py script #917

Open klassenjm opened 8 months ago

klassenjm commented 8 months ago

I would like to be able to supply a prepared configuration for study Bible 'notes only' printing. I can mostly do this by sharing a PDF with a saved configuration, and providing instructions to load a configuration from this PDF.

However, a part of this solution working is a small Python script. Although loading the config from the PDF sets the "Process Text With Custom Script at:" switch, it does not actually point to a valid location for the project the config is being set for -- nor does it copy the Python script into place (I'm aware that the PDF file is not storing the script).

I thought maybe loading the config from a saved archived would work. However, when I try this PTXPrint complains of an "Invalid PDF header"

Traceback (most recent call last):
  File "ptxprint\gtkview.py", line 3722, in onSelectPDForZIPfileToImport
  File "ptxprint\utils.py", line 257, in getPDFconfig
  File "ptxprint\pdfrw\pdfreader.py", line 587, in __init__
    raise PdfParseError('Invalid PDF header: %s' %
ptxprint.pdfrw.errors.PdfParseError: Invalid PDF header: 'PK\x03\x04\x14\x00\x00\x00\x08\x00\x10L[WFÈyã¶X\x00\x00óó\x00\x00\x18\x00\x00\x00GSB16c1/60JASGSB16c1.SFM¥½[\x92#G\x92-ø?"³\x07ï¿\x88ldtÂ\x81x!?R\x92ï¬&\x8b\x14föå\xad¹'

PTXprint Version 2.3.51

It would be great if the load from ZIP worked, and if it would unpack everything into the same (relative) locations as the source was when the archive was made. In particular, I would like to have the .py file in the shared/ folder (so that it gets transferred via Send/Receive).

This would make enabling a 'notes only' output quite simple for a new project.

markpenny commented 8 months ago

Hi @klassenjm , yes - I'm just confirming that you're doing the right thing, but we obviously have a regression here with the import from a saved archive (which I have also just been able to reproduce locally).

AFAIK, if the .py file is stored in the same folder along with the other settings (in the shared/PTXprint/ folder, it will get S/R as well (unless Paratext is doing something smart to restrict 'dangerous' files from being shared in that way; I know it has a list of exclusions, but don't know if .py is on that list; .bat certainly is!)

The second part of this issue is making sure that the relative paths get updated, so that we're not pointing to the wrong location for the (imported) configuration, as is seen in this example: image

mhosken commented 8 months ago

A case of incomplete feature. We imply we support zip import and then don't do it and treat all file types as pdf. Let's fix that.