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

Translate PDF directly on the Google Translate server #639

Open
richardsonoge opened this issue Jul 21, 2024 · 2 comments
Open

Translate PDF directly on the Google Translate server #639

richardsonoge opened this issue Jul 21, 2024 · 2 comments

Comments

@richardsonoge
Copy link

richardsonoge commented Jul 21, 2024

Hi there!

I've been stuck on this project for several months. I'm trying to translate my visitors' PDFs directly into the Google Translate server and I'd like you to help me do it with your library please. Here's the link: Google Translate https://translate.google.com/?hl=en&sl=en&tl=fr&op=docs

Here is the beginning of my code:

<?php

require 'vendor/autoload.php';

// Path to your PDF file and download destination
$pdfPath = 'documents/con.pdf';
$downloadPath = 'save/translated.pdf';

use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Page;

$browserFactory = new BrowserFactory();

$browser = $browserFactory->createBrowser();
try {
    $page = $browser->createPage();
    $page->navigate('https://translate.google.com/?hl=en&sl=en&tl=fr&op=docs')->waitForNavigation('networkIdle', 10000);

    $elem = $page->dom()->querySelector('.ZdLswd')->click();

    // screenshot - Say "Cheese"! 😄
    $page->screenshot()->saveToFile('save/bar.png');

    // pdf
    $page->pdf(['printBackground' => true])->saveToFile('save/bar.pdf');

} finally {
    $browser->close();
}

I'm extremely stuck and I don't know what to do... PLEASE! Any help will be appreciated.

@enricodias
Copy link
Member

And what is the problem you are having, specifically?

@richardsonoge
Copy link
Author

And what is the problem you are having, specifically?

I'll explain it more succinctly. My main goal is to use your library to submit my PDF directly to the Google Translate server https://translate.google.com/?hl=en&sl=en&tl=fr&op=docs for translation. But I can't do that with your library. Can you help me do this or give me a block of code that I can use to do it please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants