PDF 파일을 TIFF 파일로 변환하는 가장 좋은 방법
문제
약 1000개의 PDF 파일이 있는데 이를 300dpi tiff 파일로 변환해야 합니다.이를 수행하는 가장 좋은 방법은 무엇입니까?SDK나 스크립트를 작성할 수 있는 도구가 있다면 이상적입니다.
해결책
Imagemagick을 사용하거나 더 나은 방법으로는 Ghostscript를 사용하세요.
http://www.ibm.com/developerworks/library/l-graf2/#N101C2 imagemagick에 대한 예가 있습니다.
convert foo.pdf pages-%03d.tiff
http://www.asmail.be/msg0055376363.html 고스트스크립트에 대한 예가 있습니다:
gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit
나는 ghostscript를 설치하고 gs의 매뉴얼 페이지를 읽어서 필요한 정확한 옵션이 무엇인지 확인하고 실험할 것입니다.
다른 팁
과거에는 명령줄에서 GhostScript를 사용하여 다음을 사용했습니다.
Windows의 경우:
gswin32c -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf
*nix에서:
gs -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf
파일 수가 많은 경우 간단한 배치/셸 스크립트를 사용하여 임의 수의 파일을 변환할 수 있습니다.
나는 디렉토리 구조를 살펴보고 고스트스크립트를 사용하여 모든 pdf 파일을 tiff 파일로 변환하는 작은 powershell 스크립트를 작성했습니다.내 스크립트는 다음과 같습니다.
$tool = 'C:\Program Files\gs\gs8.63\bin\gswin32c.exe'
$pdfs = get-childitem . -recurse | where {$_.Extension -match "pdf"}
foreach($pdf in $pdfs)
{
$tiff = $pdf.FullName.split('.')[0] + '.tiff'
if(test-path $tiff)
{
"tiff file already exists " + $tiff
}
else
{
'Processing ' + $pdf.Name
$param = "-sOutputFile=$tiff"
& $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param -r300 $pdf.FullName -c quit
}
}
1) 고스트스크립트 설치
2) ImageMagick 설치
3) "Convert-to-TIFF.bat"(Windows XP, Vista, 7)를 생성하고 다음 줄을 사용합니다.
for %%f in (%*) DO "C:\Program Files\ImageMagick-6.6.4-Q16\convert.exe" -density 300 -compress lzw %%f %%f.tiff
단일 페이지 PDF 파일을 이 파일로 드래그하면 300DPI의 압축된 TIFF로 변환됩니다.
Python을 사용하면 이것이 내가 끝내는 것입니다.
import os
os.popen(' '.join([
self._ghostscriptPath + 'gswin32c.exe',
'-q',
'-dNOPAUSE',
'-dBATCH',
'-r300',
'-sDEVICE=tiff12nc',
'-sPAPERSIZE=a4',
'-sOutputFile=%s %s' % (tifDest, pdfSource),
]))
PDF Focus .Net은 다음과 같은 방식으로 이를 수행할 수 있습니다.
1. PDF를 TIFF로
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string pdfPath = @"c:\My.pdf";
string imageFolder = @"c:\images\";
f.OpenPdf(pdfPath);
if (f.PageCount > 0)
{
//Save all PDF pages to image folder as tiff images, 200 dpi
int result = f.ToImage(imageFolder, "page",System.Drawing.Imaging.ImageFormat.Tiff, 200);
}
2. PDF를 다중 페이지-TIFF로
//Convert PDF file to Multipage TIFF file
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string pdfPath = @"c:\Document.pdf";
string tiffPath = @"c:\Result.tiff";
f.OpenPdf(pdfPath);
if (f.PageCount > 0)
{
f.ToMultipageTiff(tiffPath, 120) == 0)
{
System.Diagnostics.Process.Start(tiffPath);
}
}
ABCPDF도 그렇게 할 수 있습니다. 확인해 보세요. http://www.websupergoo.com/helppdf6net/default.html
우분투에서 테스트 된 고스트 스크립트 및 TIFFCP 필수 고스트 스크립트
import os
def pdf2tiff(source, destination):
idx = destination.rindex('.')
destination = destination[:idx]
args = [
'-q', '-dNOPAUSE', '-dBATCH',
'-sDEVICE=tiffg4',
'-r600', '-sPAPERSIZE=a4',
'-sOutputFile=' + destination + '__%03d.tiff'
]
gs_cmd = 'gs ' + ' '.join(args) +' '+ source
os.system(gs_cmd)
args = [destination + '__*.tiff', destination + '.tiff' ]
tiffcp_cmd = 'tiffcp ' + ' '.join(args)
os.system(tiffcp_cmd)
args = [destination + '__*.tiff']
rm_cmd = 'rm ' + ' '.join(args)
os.system(rm_cmd)
pdf2tiff('abc.pdf', 'abc.tiff')
pdf2tiff는 어떻습니까? http://python.net/~gherman/pdf2tiff.html
http://python.net/~gherman/projects/pdf2tiff/
또한 pdf2ps, ps2image를 사용한 다음 다른 유틸리티를 사용하여 결과 이미지를 tiff로 변환할 수도 있습니다('paul'을 기억합니다 [paul - 또 다른 이미지 뷰어(PNG, TIFF, GIF, JPG 등 표시]).
부인 성명:내가 추천하는 제품에 대한 작업
Atalasoft에는 다음을 수행할 수 있는 .NET 라이브러리가 있습니다. PDF를 TIFF로 변환 --저희는 FOXIT의 파트너이므로 PDF 렌더링이 매우 좋습니다.
이것도 시도해 보시겠어요? PDF 포커스
이 .Net 라이브러리를 사용하면 문제를 해결할 수 있습니다. :)
이 코드는 도움이 될 것입니다(C#에서 1000개의 PDF 파일을 300dpi TIFF 파일로 변환).
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string[] pdfFiles = Directory.GetFiles(@"d:\Folder with 1000 pdfs\", "*.pdf");
string folderWithTiffs = @"d:\Folder with TIFFs\";
foreach (string pdffile in pdfFiles)
{
f.OpenPdf(pdffile);
if (f.PageCount > 0)
{
//save all pages to tiff files with 300 dpi
f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile), System.Drawing.Imaging.ImageFormat.Tiff, 300);
}
f.ClosePdf();
}
나는 PDFTIFF.com을 좋아합니다 PDF를 TIFF로 변환, 무제한 페이지를 처리할 수 있습니다.