Open Scorpovi4 opened 5 years ago
Hi @Scorpovi4 , I find work arround. I just use iframe to show the PDF in a html file:
const makePDF = () => {
return download(URL_TO_PDF)
.pipe(rename(PDF_OUTPUT_NAME+'.pdf'))
.pipe(dest(PATH_TO_BUILD))
.pipe(connect.reload())
}
const makeHTML = () => {
return src(URL_TO_PDF)
.pipe(add(PDF_OUTPUT_NAME+'.html', '<html><body><object style="width: 100%;height: 100%;" '+'data="'+PDF_OUTPUT_NAME+'.pdf'+'" type="application/pdf"><embed src="'+PDF_OUTPUT_NAME+'.pdf'+'" type="application/pdf" /></object></body></html>'))
.pipe(dest(PATH_TO_BUILD)
.pipe(connect.reload())
}
const watcher = () => {
watch(PATH_TO_PDF).on('change', createShoppingListPDF)
}
/*
* Tasks
*/
const createPDF = series(makePDF, makeHTML);
exports.createPDF = createPDF;
Inspired by @digzit's answer, I have found this works for me. I'm using Apache FOP.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<object style="width: 100vw; height: 100vh;" data="file.pdf#page=1" type="application/pdf"></object>
</body>
</html>
TIP: Set page=2
in the data URL to automatically go to page 2
browser-sync start --server --files *.pdf
fop.bat -c fop.xconf -xml data.xml -xsl template.xsl -pdf file.pdf
Issue details
What to do if I need to run pdf file from baseDir not manualy as i do now, but automatic when browser sync starts?! Set pdf as entry running, as index.html.
One more thing relates to this, how to force reload browser window where this pdf was opened? API as bs.reload doesn't match, actually it shows in terminal reloading but don;t make it in browser!