Skip to content
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

Export conversation as PDF #77

Open
mbprotheweb opened this issue Mar 16, 2023 · 12 comments
Open

Export conversation as PDF #77

mbprotheweb opened this issue Mar 16, 2023 · 12 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mbprotheweb
Copy link

Would be great if you add the option to export a conversation as PDF
And it would be a lot more user friendly for a lot of situations
Thank you

@pionxzh pionxzh added the enhancement New feature or request label Mar 16, 2023
@pionxzh
Copy link
Owner

pionxzh commented Mar 16, 2023

We are running out of space to add a button!!
(just kidding 😄)

image

@mbprotheweb
Copy link
Author

Just suggesting
You can maybe leave the basics and then have something like a hover submenu for 'More' options

@mbprotheweb
Copy link
Author

Something like the original export menu

image

@pionxzh
Copy link
Owner

pionxzh commented Mar 16, 2023

Yes we might need a sub-menu for them

@Kreijstal
Copy link

You can just open it in html and save as pdf, no need to implement and maintain mindless features nobody needs.

@ginixsan
Copy link
Contributor

ginixsan commented Apr 21, 2023

@mbprotheweb you could do something like this:

import { promises as fs } from 'fs';
import puppeteer from 'puppeteer';

async function htmlToPdf(inputFile: string, outputFile: string) {
  try {
    const htmlContent = await fs.readFile(inputFile, 'utf-8');

    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.setContent(htmlContent);
    const pdfBuffer = await page.pdf({ format: 'A4' });

    await fs.writeFile(outputFile, pdfBuffer);
    console.log(`PDF saved to ${outputFile}`);

    await browser.close();
  } catch (error) {
    console.error('Error:', error);
  }
}

// Usage
const inputFile = 'input.html';
const outputFile = 'output.pdf';
htmlToPdf(inputFile, outputFile);

Modify it to style it as you wish

@mbprotheweb
Copy link
Author

Both of the above are great suggestions
It would just be more convenient to be able to export it directly as a pdf

@pionxzh
Copy link
Owner

pionxzh commented Apr 21, 2023

Thanks for all the suggestions. I will spare some time for this recently.

@pionxzh pionxzh added the good first issue Good for newcomers label Apr 21, 2023
@Kreijstal
Copy link

Both of the above are great suggestions It would just be more convenient to be able to export it directly as a pdf

ok but please don't inject a giga dependency that creates PDFs as an userscript, it would be incredibly bloated, OR, make it so, that it gets imported at runtime, that way it only is loaded when you actually want to create a PDF and not everytime you refresh

@pionxzh
Copy link
Owner

pionxzh commented Apr 22, 2023

I know this script is already huge. I will try to make it dynamic load some scripts. The userscript environment is really special, so normal code splitting will not work as intended.

@Nayko93
Copy link

Nayko93 commented Aug 29, 2023

Any news ?
Also, will the resulting PDF will keep the text formatting if you copy past from the PDF back into ChatGPT ? like all the line break and stuff like that ?

@pionxzh
Copy link
Owner

pionxzh commented Aug 29, 2023

I will spare some time for it this weekend. Not sure what you mean by text formatting, but the limitation of copying from PDF won't be able to be fixed by the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants