It doesn’t work for PDF files, which text content couldn’t be copied and printing is disabled. I get following error message during execution. I couldn’t get InputStream .
org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Error: End-of-File, expected line
at com.pdf.reader.ReadPdfFromBrowser.invokeMethod(ReadPdfFromBrowser.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at print.run(print:10)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1578260748461.run(TempTestCase1578260748461.groovy:23)
Caused by: java.io.IOException: Error: End-of-File, expected line
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1124)
at org.apache.pdfbox.pdfparser.COSParser.parseHeader(COSParser.java:2603)
at org.apache.pdfbox.pdfparser.COSParser.parsePDFHeader(COSParser.java:2574)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:219)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1222)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1122)
at org.apache.pdfbox.pdmodel.PDDocument$load.call(Unknown Source)
at com.pdf.reader.ReadPdfFromBrowser.Pdf2Image(ReadPdfFromBrowser.groovy:72)
... 14 more
Exception in thread "main" java.io.IOException: Error: End-of-File, expected line
at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1124)
at org.apache.pdfbox.pdfparser.COSParser.parseHeader(COSParser.java:2595)
at org.apache.pdfbox.pdfparser.COSParser.parsePDFHeader(COSParser.java:2574)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:219)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1222)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1122)
at ScreenshotFromPdf.Pdf2Image(ScreenshotFromPdf.java:24)
at ScreenshotFromPdf.main(ScreenshotFromPdf.java:43)
actually this works too, need to click page that pop up will disappear
after that able to click download button
//save and download pdf file from disk
driver.get(“https://gofile.io/?c=WYPqpZ”);
driver.findElement(By.id(“fileInfoDownload”)).click();
Thread.sleep(3000);
//save pdf to disk
driver.get("https://gofile.io/?c=WYPqpZ");
Thread.sleep(5000);
driver.findElement(By.xpath("/html/body/div[2]/div/div[10]/button[2]")).click();
Thread.sleep(1000);
driver.findElement(By.id("fileInfoDownload")).click();
Thread.sleep(3000);
no needed to use this method, add comment
//openInBrowser(pdfDir+"/"+pdfFile);
I see, but on that site, where file is originally located, saving is disabled. I just tried to reproduce situation with this demo file: http://aplaidshirt.epizy.com/samplePDF.pdf So please don’t use save function in your solution, because it will not work. Please use original pdf, without gofile file hosting solution: http://aplaidshirt.epizy.com/samplePDF.pdf , but without using file save option.
got it, so in fact the issue is at the original URL you try to access it, not with the pdf himself.
can you share that URL? (i think not, just asking … but worth to try)