Have a large multipage .pdf, and would like to export all pages as single pdf?
Help with the script required, using pdftk??
Thanks.
You can do pdftk in.pdf burst. The equivalent in cpdf is cpdf -split in.pdf -o %%%.pdf or similar.
Related
I'm try to apply OCR with Ghostscript to pdf file with this command
gswin64c -sOCRLanguage="fast/eng" -sDEVICE=pdfocr24 -o out.pdf in.pdf
Original PDF is 300DPI and Colored and 4.1MB, but after run OCR, i have a PDF with 42.5MB
I have tried to add -r300 -dDownScaleFactor=4 but these options decrease quality image and ocr accuracy.
Expected is to have a PDF a little bit large of original (same quality as original, but with OCR).
There are any advices for accomplish that?
I am trying to render a PDF with another embedded font for musical notation and I don't know how to do it.
I am trying to rasterize a music staff in a PDF and I realized that the PDF is rendering the musical notation bad because of the embeded font. Then I want to try with another font.
I extract text with ghostscript, or convert PDF to PS and edit the .ps, but I believe if I can understand how to re-redender the PDF...
gs -dBATCH -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=Betlem_pdf.txt Betlem.pdf
iconv.exe -f MACROMAN -t UTF-8 Betlem_pdf.txt > Betlem_pdf_txt_utf8.txt
enscript.exe -f Petrucci40 Betlem_pdf_txt_utf8.txt -o Betlem_pdf_txt_utf8.ps
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=Betlem_2.pdf Betlem_pdf_txt_utf8.ps
The expected result is to see the same staff than in the original PDF but with another font. But I don't know what I am doing...
http://www.xn--estudiantladolaina-lvb.com/partitures/baixa/pdf/26
The PDF you linked does not have fonts for the music notes. The music notes are PDF shape/image objects. Best you can do here is use a OCR (optical character recognition) for the PDF and hope that OCR supports music notes.
I have converted this file to PDF using rsvg-convert.
I’m now embedding it within this LaTeX document:
\documentclass{standalone}
\usepackage{graphicx}
\begin{document}
\includegraphics{nucleosynthesis_periodic_table.pdf}
\end{document}
that I compile to test_lualatex.pdf which I then process using this command: gs -o test_output_lualatex.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress test_lualatex.pdf (I’m normally doing this on my bigger main document, where this helps a lot reducing the PDF size —here I’m only providing a MWE). And I get this: test_output_lualatex.pdf.
Why is the output so different after ghostscript processing? Is there anything I can do about it?
I have got some pdf documents that need to be printed to A4 paper.
I know there are options in my pdf reader (evince) to scale the document to fit the exact paper size it's printed to, and that works fine with printing to a file, too.
So there must be a CLI-solution to get this job done, right?
Whenever I want a pdf to be 2 pages on one sheet, I use
pdfnup in.pdf --nup 2x1 --outfile out.pdf
But that doesn't work – in.pdf is not scaled to fit, instead it's too tiny compared to the output of evince printed to a file. So how can I scale it before (or while) using pdfnup? It would be great if that worked for any input format, not just for A5. Thanks in advance for any answer!
Regards, LDer
Oh boy, I just figured something out on my own. Sorry for bothering anyone!
gs -o out.pdf -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 in.pdf
When I use the following ghostscript command to generate jpg thumbnails from PDFs, the image quality is often very poor:
gs -q -dNOPAUSE -dBATCH -sDEVICE=jpeggray -g465x600 -dUseCropBox -dPDFFitPage -sOutputFile=pdf_to_lowres.jpg test.pdf
By contrast, if I use ghostscript to generate a high-resolution png, and then use mogrify to convert the high-res png to a low-res jpg, I get pretty good results.
gs -q -dNOPAUSE -dBATCH -sDEVICE=pnggray -g2550x3300 -dUseCropBox -dPDFFitPage -sOutputFile=pdf_to_highres.png test.pdf
mogrify -thumbnail 465x600 -format jpg -write pdf_to_highres_to_lowres.jpg pdf_to_highres.png
Is there any way to achieve good results while bypassing the intermediate pdf -> high-res png step? I need to do this for a large number of pdfs, so I'm trying to minimize the compute time.
Here are links to the images referenced above:
test.pdf
pdf_to_lowres.jpg
pdf_to_highres.png
pdf_to_highres_to_lowres.jpg
One option that seems to improve the output a lot: -dDOINTERPOLATE. Here's what I got by running the same command as you but with the -dDOINTERPOLATE option:
I'm not sure what interpolation method this uses but it seems pretty good, especially in comparison to the results without it.
P.S. Consider outputting PNG images (-sDEVICE=pnggray) instead of JPEG. For most PDF documents (which tend to have just a few solid colors) it's a more appropriate choice.
Your PDF looks like it is just a wrapper around a jpeg already.
Try using the pdfimages program from xpdf to extract the actual image rather than rendering
to a file.