Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. convert foo.pdf pages-%03d.tiff
  2.  
  3. gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit
  4.  
  5. $tool = 'C:Program Filesgsgs8.63bingswin32c.exe'
  6. $pdfs = get-childitem . -recurse | where {$_.Extension -match "pdf"}
  7.  
  8. foreach($pdf in $pdfs)
  9. {
  10.  
  11. $tiff = $pdf.FullName.split('.')[0] + '.tiff'
  12. if(test-path $tiff)
  13. {
  14. "tiff file already exists " + $tiff
  15. }
  16. else
  17. {
  18. 'Processing ' + $pdf.Name
  19. $param = "-sOutputFile=$tiff"
  20. & $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param -r300 $pdf.FullName -c quit
  21. }
  22. }
  23.  
  24. import os
  25. os.popen(' '.join([
  26. self._ghostscriptPath + 'gswin32c.exe',
  27. '-q',
  28. '-dNOPAUSE',
  29. '-dBATCH',
  30. '-r300',
  31. '-sDEVICE=tiff12nc',
  32. '-sPAPERSIZE=a4',
  33. '-sOutputFile=%s %s' % (tifDest, pdfSource),
  34. ]))
  35.  
  36. for %%f in (%*) DO "C:Program FilesImageMagick-6.6.4-Q16convert.exe" -density 300 -compress lzw %%f %%f.tiff
  37.  
  38. import os
  39.  
  40. def pdf2tiff(source, destination):
  41. idx = destination.rindex('.')
  42. destination = destination[:idx]
  43. args = [
  44. '-q', '-dNOPAUSE', '-dBATCH',
  45. '-sDEVICE=tiffg4',
  46. '-r600', '-sPAPERSIZE=a4',
  47. '-sOutputFile=' + destination + '__%03d.tiff'
  48. ]
  49. gs_cmd = 'gs ' + ' '.join(args) +' '+ source
  50. os.system(gs_cmd)
  51. args = [destination + '__*.tiff', destination + '.tiff' ]
  52. tiffcp_cmd = 'tiffcp ' + ' '.join(args)
  53. os.system(tiffcp_cmd)
  54. args = [destination + '__*.tiff']
  55. rm_cmd = 'rm ' + ' '.join(args)
  56. os.system(rm_cmd)
  57. pdf2tiff('abc.pdf', 'abc.tiff')
  58.  
  59. SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
  60.  
  61. string pdfPath = @"c:My.pdf";
  62.  
  63. string imageFolder = @"c:images";
  64.  
  65. f.OpenPdf(pdfPath);
  66.  
  67. if (f.PageCount > 0)
  68. {
  69. //Save all PDF pages to image folder as tiff images, 200 dpi
  70. int result = f.ToImage(imageFolder, "page",System.Drawing.Imaging.ImageFormat.Tiff, 200);
  71. }
  72.  
  73. //Convert PDF file to Multipage TIFF file
  74.  
  75. SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
  76.  
  77. string pdfPath = @"c:Document.pdf";
  78. string tiffPath = @"c:Result.tiff";
  79.  
  80. f.OpenPdf(pdfPath);
  81.  
  82. if (f.PageCount > 0)
  83. {
  84. f.ToMultipageTiff(tiffPath, 120) == 0)
  85. {
  86. System.Diagnostics.Process.Start(tiffPath);
  87. }
  88. }
  89.  
  90. SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
  91.  
  92. string[] pdfFiles = Directory.GetFiles(@"d:Folder with 1000 pdfs", "*.pdf");
  93. string folderWithTiffs = @"d:Folder with TIFFs";
  94.  
  95. foreach (string pdffile in pdfFiles)
  96. {
  97. f.OpenPdf(pdffile);
  98.  
  99. if (f.PageCount > 0)
  100. {
  101. //save all pages to tiff files with 300 dpi
  102. f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile), System.Drawing.Imaging.ImageFormat.Tiff, 300);
  103. }
  104. f.ClosePdf();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement