3
$\begingroup$

I made a string expressed in StandardForm format.

str = "Plot[Sin[\!\(\*SuperscriptBox[\(x\), \
\(2\)]\)]+\!\(\*SqrtBox[FractionBox[\(x\), \(2\)]]\),{x,0,3}]";

enter image description here

And I want to save this as a PDF file.

NotebookPrint[ str, StringJoin[NotebookDirectory[],   "tset1.pdf"]]

If you open the PDF file, it doesn't look like StandardForm.

enter image description here

Can I use NotebookPrint to save PDF files in StandardForm format?

If I use Export, I can save PDF files in the desired form.

Export[ StringJoin[NotebookDirectory[], "tset2.pdf"], str]

However, there is one big problem with this. If the string is very long and is one page long, the page cannot be divided.

I want to make a PDF file so that I can keep the StandardForm format and separate pages for long sentences.

$\endgroup$
2
  • $\begingroup$ How about str = "Plot[Sin[\!\(\*SuperscriptBox[\(x\), \ \(2\)]\)]+\!\(\*SqrtBox[FractionBox[\(x\), \(3\)]]\),{x,0,3}]"; NotebookPrint[str // MakeExpression // Apply@HoldForm, "tset1.pdf"]? $\endgroup$
    – xzczd
    Nov 18, 2023 at 7:06
  • $\begingroup$ Thank you, it works very well. Your answer made it possible for me to proceed to the next level. Thank you again! $\endgroup$
    – Milk
    Nov 18, 2023 at 7:34

1 Answer 1

4
$\begingroup$

Turn the comment to an answer:

NotebookPrint[str // MakeExpression // Apply@HoldForm, "tset1.pdf"]
"tset1.pdf" // SystemOpen
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.