ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

Export to PDF freezes

Open alanosman opened this issue 2 years ago • 19 comments

Non-ChatGPT bug

  • [X] This issue does not occur on chat.openai.com and only occurs on this app.

Version

1.1.0

Bug description

I'm not sure if this is a feature of the desktop client or not, but when I go to export a discussion, the export freezes and never completes. I looked at chatGPT on the web, and they do not have export icons.

OS

Windows 11 pro

Environment

No response

alanosman avatar Nov 22 '23 15:11 alanosman

Yes,this is a feature of the desktop client,the export icons work via the export.js,I think it is caused by the change of gpt front-end style,try Edit Preference -> Control center ->Scripts -> export.js, remove lines 114, 143, 170 code related to 'spacer'. image

SilenceIronMan avatar Nov 23 '23 01:11 SilenceIronMan

@SilenceIronMan Your fix enabled the ExportPDF without freezing, much appreciated. With short chats the PDF correctly configures, but with long chats the text overruns max size limits and appears distorted. Cannot OCR using Adobe Acrobat Pro. Do you know of a fix to correctly format long chats? ExportPDF fix5

TransPete avatar Nov 24 '23 17:11 TransPete

Hi, @SilenceIronMan - thanks for the tip. It fixed it for me.

One thing though, it seemed like it doesn't format the text color well. image

alanosman avatar Nov 24 '23 23:11 alanosman

Hi, @SilenceIronMan - thanks for the tip. It fixed it for me.

One thing though, it seemed like it doesn't format the text color well. image

@alanosman Just add this code this.thread.style.backgroundColor = 'rgba(52,53,65,.9)'; at line 143.

SilenceIronMan avatar Nov 27 '23 03:11 SilenceIronMan

@SilenceIronMan Your fix enabled the ExportPDF without freezing, much appreciated. With short chats the PDF correctly configures, but with long chats the text overruns max size limits and appears distorted. Cannot OCR using Adobe Acrobat Pro. Do you know of a fix to correctly format long chats? ExportPDF fix5

@TransPete Maybe you can try this way, I'm not sure if this will necessarily work。 Open your PDF file, File -> Print, on the page that pops up, change the printer to "Adobe PDF" (do not do real printing), and select all pages. In the "Page Processing" section, select "Reduce to printable area" for "Page scaling method". Finally click "OK".

SilenceIronMan avatar Nov 27 '23 03:11 SilenceIronMan

@SilenceIronMan The fix did not work as it just kept processing and eventually had to be aborted due to no progress. It did however reveal that the entire download was attempting to fill a single page as illustrated below. Wonder if an instruction can be added to the ExportPDF that will have the PDF paginate correctly. image

TransPete avatar Nov 28 '23 23:11 TransPete

@SilenceIronMan The fix did not work as it just kept processing and eventually had to be aborted due to no progress. It did however reveal that the entire download was attempting to fill a single page as illustrated below. Wonder if an instruction can be added to the ExportPDF that will have the PDF paginate correctly. image

@TransPete Try this way,edit Preference -> Control center ->Scripts -> export.js. Relpace the function handlePdf with my code: (But there will be small flaws in font segmentation.)

async function handlePdf(imgData, canvas, pixelRatio) {
  const { jsPDF } = window.jspdf;
  var contentWidth = canvas.width
  var contentHeight = canvas.height
  var pageHeight = contentWidth / 592.28 * 841.89
  var leftHeight = contentHeight
  var position = 0
  var imgWidth = 595.28
  var imgHeight = 592.28 / contentWidth * contentHeight
  var pdf = new jsPDF('', 'pt', 'a4')
  if (leftHeight < pageHeight) {
      pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight, '', 'FAST');
  } else {
      while (leftHeight > 0) {
          pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight, '', 'FAST');
          leftHeight -= pageHeight
          position -= 841.89
          if (leftHeight > 0) {
              pdf.addPage()
          }
      }
  }
  const data = pdf.__private__.getArrayBuffer(pdf.__private__.buildDocument());
  const name = `ChatGPT_${formatDateTime()}.pdf`;
  await invoke('download_file', { name: name, blob: Array.from(new Uint8Array(data)) });
}

SilenceIronMan avatar Nov 29 '23 07:11 SilenceIronMan

Hi @SilenceIronMan - I re-synced with the remote script and added this script. This seems to have fixed the issue.

alanosman avatar Nov 29 '23 14:11 alanosman

@SilenceIronMan I replaced the code but when reloaded, no longer found the "ExportPDF" button displayed in the bottom of the left sidebar. Re-synced the export.js script thinking I might have mis-pasted your code, but on restart, still cannot find the ExportPDF button. Don't know ".js" language, don't know what happened to the Export buttons! Suggestions?

TransPete avatar Nov 29 '23 15:11 TransPete

@SilenceIronMan I replaced the code but when reloaded, no longer found the "ExportPDF" button displayed in the bottom of the left sidebar. Re-synced the export.js script thinking I might have mis-pasted your code, but on restart, still cannot find the ExportPDF button. Don't know ".js" language, don't know what happened to the Export buttons! Suggestions?

@TransPete It may be that the css style has changed. I will give you a copy of my file tomorrow.

SilenceIronMan avatar Nov 29 '23 16:11 SilenceIronMan

@SilenceIronMan That will be much appreciated. Don't know when the buttons disappeared. Only thought is they might have been hidden due to problems with execution. Many thanks for your kind assistance.

TransPete avatar Nov 29 '23 16:11 TransPete

@SilenceIronMan - @TransPete is right. Now all my export buttons are gone after a restart. Whoops.

alanosman avatar Nov 29 '23 16:11 alanosman

@SilenceIronMan Thank you for the confirmation that I'm not alone @alanosman . Was beginning to think that not only ChatGPT is subject to hallucinations!

TransPete avatar Nov 29 '23 16:11 TransPete

@TransPete @alanosman Replace your content. export.txt

SilenceIronMan avatar Nov 30 '23 02:11 SilenceIronMan

Bless you, i just discovered that my favorite feature of export (the only way I have found to do this especially to .md) HAD Disappeared, then i saw everyone complaining about the accidental use and thought that it had been Erased as a feature (Please do not do that). I just updated with the export.txt in the previous post and all is well again. Thanks for that.

mjweav avatar Nov 30 '23 02:11 mjweav

@SilenceIronMan thank you. Looks like both export works and the icons are back.

Question on the username, why "Silence" with IronMan? :-)

alanosman avatar Nov 30 '23 04:11 alanosman

@SilenceIronMan Replaced the entire export.js file with the new code and most happy to see the icons re-appear. However, when I selected a chat and pressed the PDF button, the PDF that downloaded was dark and unreadable. Hope springs eternal. PDF export fail 3

TransPete avatar Nov 30 '23 15:11 TransPete

@SilenceIronMan Tried ExportPDF again and no joy. Have to Quit ChatGPT and restart to get out of the loop. PDF export fail 4

TransPete avatar Nov 30 '23 19:11 TransPete

I tried the suggested solutions here but could not get a PDF to have anything other than the dark background. I decided to ask ChatGPT for a solution - and it provided one! I've shared the specific chat here but the solution is simple:

Change Background Color in fixLocation Method: Modify the background color set in line 168 of the fixLocation method to a lighter color or the color you desire for your PDF background. For instance, setting it to a white background can be done by changing rgba(52,53,65,.9) to rgba(255,255,255,1).

https://chat.openai.com/share/181204c5-8063-48d5-97db-84006619d9b2

Also attached is the PDF export of that chat - with a white background. ChatGPT_2023_12_25-111446.pdf

Luke717 avatar Dec 25 '23 11:12 Luke717