isteinbrecher / latex2ai

LaTeX Plugin for Adobe Illustrator
MIT License
168 stars 5 forks source link

LaTeX2AI does not work with non ASCII characters in the document name / path #100

Open meteorlin opened 2 years ago

meteorlin commented 2 years ago

Hello, while using this plug-in, it throw an error. The plug-in panel stacks together: image

The error log:

--------------------------------------------------------------------------------
LaTeX2AI Error! If this happens, please open an issue under
github.com/isteinbrecher/latex2ai/issues
--------------------------------------------------------------------------------
LaTeX2AI version:
0.0.9
LaTeX2AI git sha:
67f83772bff502cd60a6f285e2713396d0998908

Illustrator Version:
2200
--------------------------------------------------------------------------------
Error thrown at:
--------------------------------------------------------------------------------
c:\adobe illustrator cc 2018 sdk\samplecode\latex2ai\l2a\src\l2a_ai_functions\l2a_ai_functions.cpp::59
L2A::AI::CreatePlacedItem
--------------------------------------------------------------------------------

Ilustrator Error. Error code: ÿÿÿÕ

After that, the Ai give me an error panel with "L2APlugin: :ToolMouseDown Error caught."

isteinbrecher commented 2 years ago

It seems that Illustrator can not find the created PDF file. Usually, if the Plugin gets to this point, the PDF should be created properly. Can you check what the contents of the temp directory "C:\Users\USERNAME\AppData\Local\Temp\LaTeX2AI" are, when the error message appears?

meteorlin commented 2 years ago

Thank you for your quick reply! It seems that the pdf file is generated successfully: image

isteinbrecher commented 2 years ago

Ok, this rules out any LaTeX errors. The LaTeX2AI_item_1.pdf file should be copied to the links folder in your working directory (under some cryptic filename). Can you check if this file is created correctly?

meteorlin commented 2 years ago

Yes, the LaTeX2AI_item_1.pdf file is created correctly and I can open it successfully.

isteinbrecher commented 2 years ago

Jsut to be sure, did you check the LaTeX2AI_item_1.pdf file, or the one in the links folder? The name should be something like AI_FILENAME_LaTeX2AI_4771e3d2b5bd68a2.pdf.

meteorlin commented 2 years ago

Well, there is not any folder named links in the Temp\LaTeX2AI folder. Can you give me an example snapshot which shows what folders or files should be generated in the Temp\LaTeX2AI folder?

isteinbrecher commented 2 years ago

I think I was not very precise with my previous comment. The creation of a LaTeX2AI item can be split up in the following steps:

  1. Create the PDF file in the temp directory. This your case this is the LaTeX2AI_item_1.pdf file.
  2. Copy the created file to the sub folder links in the document directory, i.e., the directory where your Illustrator file is saved. The item is stored under a name containing the document name and the PDF file hash (e.g., AI_FILENAME_LaTeX2AI_4771e3d2b5bd68a2.pdf).
  3. The PDF from the links folder is placed as a label in Illustrator.

It seems that the error you reported happens in step 2.

The figure below shows an example directory structure with two Illustrator documents figure_1.ai (containing 3 LaTeX2AI labels) and figure_2.ai (containing 2 LaTeX2AI labels). The labels are stored in the links folder to help illustrator locate them when opening the documents. Once opened the Plugin should handle all housekeeping tasks. Screenshot from 2022-03-24 13-24-52

meteorlin commented 2 years ago

Oh, I see. The links folder is generated in the same dir of the .ai file, but it is empty (without any .pdf file is generated). image

isteinbrecher commented 2 years ago

This means, that the problem is most likely somewhere in the decoding or encoding of the PDF file. I uploaded a commit (fa16f1e5), which creates a log file debug.log in the main directory (the one where the illustrator document is). You can upload this log file here, that might give more detailed information on what is going wrong (for privacy reasons be ware, that this log file contain some metadata about the created PDF, e.g. your user name).

LaTeX2AI_fa16f1e5_release_IllustratorCC2018.zip.zip

meteorlin commented 2 years ago

I'm sorry to reply you so late and I solve it by changing the dir path of the .ai file because the previous path contained Chinese. Here is the snapshot of the debug.log file after changing the dir path. image Can you fix it caused by non-English characters in the path? Thank you so much!

isteinbrecher commented 2 years ago

Yes, it seems that non ASCI characters in the document path lead to this bug. I will have a look at this in the next couple of days.

isteinbrecher commented 2 years ago

@meteorlin the issue is more complicated than I anticipated. With #101 a warning is introduced that alerts the user if non ASCII characters are used in the file name. I will keep this issue open, for a future fix.

The new warning will be in the next release.