Git Product home page Git Product logo

Comments (14)

rasel-sk avatar rasel-sk commented on June 28, 2024 1

The bug in PDF.js where different images were displayed as the same occurred between versions 2.7.570 and 2.13.216. This issue was specifically noted to have started in version 2.13.216​ (GitHub)​​ (GitHub)​.

In various discussions, users reported that certain PDFs displayed correctly in versions up to 2.7.570 but encountered rendering issues in versions starting from 2.13.216 onwards. These issues included images being misrepresented, such as different images being shown as the same​ (GitHub)​​ (GitHub)​.

For further details on this and related issues, you can review the discussions on GitHub issues #12537 and #14641​ (GitHub)​​ (GitHub)​.

from autogram.

celuchmarek avatar celuchmarek commented on June 28, 2024

Vďaka za podnet. Otestoval som aj u seba a naozaj to robí toto. Je to strašne divné. Pridal som label bug.

Tu podľa mňa bude nejaký problém s pdfJS, ktoré používame na vizualizáciu PDF v HTML webview. @jsuchal nepoznáš také? Ty si kedysi práve na tejto časti robil.

Každopádne, chceme už dlhšie upgradnúť práve pdfJs na nejakú novšiu verziu, takže možno to súvisí s #73

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

Vyskusal som to v pdf.js tu https://mozilla.github.io/pdf.js/web/viewer.html a tam to vyzera takto
image

@rasel-sk vies prezredit ako si taketo pdf vyrobil?

from autogram.

rasel-sk avatar rasel-sk commented on June 28, 2024

@jsuchal Vytvoril som ho cez mPDF, ale myslím, že to nie je podstatné. Skúšal som rôzne verzie Autogramu (v1.99.0, v2.0.1, v2.1.69) a zakaždým rovnaký výsledok. Chrome, Edge, Firefox, Adobe Acrobat Reader ho zobrazujú správne... 4:1.

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

Je to zlozitejsie, zjavne su to bugy ani nie tak v pdfjs ako v engine browseru. JavaFX WebView pouziva asi nejaku starsiu verziu. Ked lokalne skusam v javafx webview otvorit pdfjs (legacy mod) ale aj najnovsiu verziu 4.x, tak to robi to iste.
image

from autogram.

rasel-sk avatar rasel-sk commented on June 28, 2024

Strieľam od brucha a na slepo, ak je to problém sa cache (neviem otestovať):

package digital.slovensko.autogram.core.visualization;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

import digital.slovensko.autogram.core.SigningJob;
import digital.slovensko.autogram.ui.Visualizer;
import eu.europa.esig.dss.model.DSSDocument;

public class PDFVisualization extends Visualization {
private final DSSDocument document;

public PDFVisualization(DSSDocument document, SigningJob job) {
    super(job);
    this.document = document;
}

private String getBase64EncodedDocument() {
    try {
        URL url = new URL(document.getName()); // Assuming document.getName() returns the URL of the document
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
        connection.setRequestProperty("Pragma", "no-cache");
        connection.setRequestProperty("Expires", "0");

        try (InputStream inputStream = connection.getInputStream();
             ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            return new String(Base64.getEncoder().encode(outputStream.toByteArray()), StandardCharsets.UTF_8);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

@Override
public void initialize(Visualizer visualizer) {
    visualizer.setPrefWidth(getVisualizationWidth());
    visualizer.showPDFVisualization(getBase64EncodedDocument());
}

}

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

@rasel-sk ja to skusam uplne mimo autogramu len cisty webview, cize toto najskor asi nie.

from autogram.

rasel-sk avatar rasel-sk commented on June 28, 2024

@jsuchal WebView z default prehliadača namiesto JavaFX?

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

@rasel-sk to sa v javafx robi velmi zle a navyse by sme si trosku strelili do kolena. Takto mame aspon pod kontrolou aky webview tam je.

from autogram.

rasel-sk avatar rasel-sk commented on June 28, 2024

@jsuchal Blbé je, že WebView JavaFX mi práve zle zobrazuje obrázky podpisov a nenašiel som spôsob ako to vyriešiť - náhľad nezobrazuje reálny obsah PDF. Menil som rozlíšenie, pridával 1px obrázky medzi faksimile a podobné zverstvá a bez výsledku. Z toho pramení zadanie tohto issue na GitHub. Mať pod kontrolou to čo nie je pod kontrolou je trocha paradox...

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class OpenInDefaultBrowserExample extends Application {

@Override
public void start(Stage primaryStage) {
    Button openBrowserButton = new Button("Open in Default Browser");
    openBrowserButton.setOnAction(e -> {
        String url = "http://www.example.com";
        openWebpage(url);
    });

    BorderPane root = new BorderPane();
    root.setCenter(openBrowserButton);

    Scene scene = new Scene(root, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.setTitle("Open in Default Browser Example");
    primaryStage.show();
}

public static void openWebpage(String url) {
    try {
        URI uri = new URI(url);
        if (Desktop.isDesktopSupported()) {
            Desktop.getDesktop().browse(uri);
        } else {
            String os = System.getProperty("os.name").toLowerCase();
            Runtime runtime = Runtime.getRuntime();
            if (os.contains("win")) {
                runtime.exec("cmd /c start " + url);
            } else if (os.contains("mac")) {
                runtime.exec("open " + url);
            } else if (os.contains("nix") || os.contains("nux")) {
                String[] browsers = { "xdg-open", "google-chrome", "firefox" };
                String browser = null;
                for (String b : browsers) {
                    if (runtime.exec(new String[] { "which", b }).getInputStream().read() != -1) {
                        browser = b;
                        break;
                    }
                }
                if (browser != null) {
                    runtime.exec(new String[] { browser, url });
                } else {
                    throw new UnsupportedOperationException("No supported browser found.");
                }
            }
        }
    } catch (URISyntaxException | IOException e) {
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    launch(args);
}

}

from autogram.

celuchmarek avatar celuchmarek commented on June 28, 2024

Skúsil som práve použiť pdf-box na renderovanie pdf ako obrázok v #452 Je to trochu pomalšie, ale aspoň to teda zobrazuje správne veci. Vedeli by sme ešte nastavneie DPI hodiť do nastavení a na slabších systémoch by si to vedeli ľudia ešte zmenšiť. Ak však 99% podpisovaných PDF je do 5 strán, tak good enough. Čo myslíte?

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

Mať pod kontrolou to čo nie je pod kontrolou je trocha paradox...

Je, ale este stale moze byt horsie :D

Overime ci pdfbox je pouzitelny, @durasj to z nejakeho dovodu nepouzil, cize si na to treba davat pozor. @celuchmarek ma nejake prvotne riesenie, ale este by som to kukol.

from autogram.

jsuchal avatar jsuchal commented on June 28, 2024

FYI. Volal som si s Jakubom a vyzera, ze na pouzitie pdfbox nema blocker, resp. nevie o ziadnom probleme, ze ked kedysi davno pdf.js do octosign daval, ze by pdfbox zavrhol z nejakeho dobreho dovodu. Skor pdf.js bol projekt mozilla / firefox tak ho zobral ako doveryhodnejsi.

from autogram.

celuchmarek avatar celuchmarek commented on June 28, 2024

Prerobili sme to do obrázkov z PDF Boxu. Celkovo to funguje a scrolluje lepšie než kedykoľvek predtým. Avšak pri väčších súboroch by sa hodil lazy loading - #456

from autogram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.