I have been using the following command to convert a pdf file into a grayscale png:
magick.exe convert -density 300 +antialias -quality 100 -type grayscale test1.pdf test1.png
It worked fine, until I came along a pdf file created by Microsoft Word 365. The source file contains a logo and some text, but the result is nothing but a black box. Using a pdfinfo.exe, I get the following information from the pdf:
Title: XXXX
Author: XX
Creator: Microsoft« Word for Microsoft 365
Producer: Microsoft« Word for Microsoft 365
CreationDate: 08/30/21 10:10:10
ModDate: 08/30/21 10:10:10
Tagged: no
Form: none
Pages: 6
Encrypted: no
Page size: 595.32 x 842.04 pts (A4) (rotated 0 degrees)
File size: 208803 bytes
Optimized: no
PDF version: 1.7
I'm using the latest version of imagemagick.exe:
Version: ImageMagick 7.1.0-8 Q16-HDRI x64 2021-09-18 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenCL
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib
Compiler: Visual Studio 2019 (192930133)
I'm wondering if this is in fact a GhostScript related issue.
Any ideas?
Related
I have a PDF which shows properly on the browser but some text is not showing on the PDF viewer on on UBUNTU, I checked the fonts of the pdf and it return
Syntax Error: non-embedded font using identity encoding: Arial-BoldMT
Syntax Error: non-embedded font using identity encoding: ArialMT
I tried to add font substitute but it is not working.
The actual text is
Benefits (After 90 Days Full Time)
but it shows like following
Benefits (After 90 Days)XOO7LPH)
I have installed arial font on ubuntu also but its still not working.
Please help.
UPDATE : The file is showing properly on adobe pdf viewer and browsers but not on ubuntu.
It appears to be a bug in Firefox.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1766039.
The same bug was also reported in pdf.js github https://github.com/mozilla/pdf.js/issues/15317
Question:I can generate Chinese watermark normally in windows environment and macos environment, but it reports an error in linux environment.
linux environment
java 1.8
pdfbox 3.0.0-alpha2
The system seems to have successfully installed the font
fc-list |grep STFangsong
/usr/share/fonts/zh_CN/STFANGSO.TTF: STFangsong:style=Regular
java.lang.IllegalArgumentException: No glyph for U+FFFD (?) in font STFangsong
at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:378) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:443) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:335) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at org.apache.pdfbox.pdmodel.font.PDFont.getStringWidth(PDFont.java:366) ~[pdfbox-3.0.0-alpha2.jar!/:3.0.0-alpha2]
at com.tencent.converter.service.PDFBox.processTextOnePage(PDFBox.java:117) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.addTextAllPageWAtermark(PDFBox.java:96) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.addTextWatermark(PDFBox.java:83) ~[classes!/:0.0.1-SNAPSHOT]
at com.tencent.converter.service.PDFBox.textWatermark(PDFBox.java:68) ~[classes!/:0.0.1-SNAPSHOT]
PDFont font = PDType0Font.load(doc, new FileInputStream("/usr/local/services/converter-1.0/lib/STFANGSO.TTF"), false);
And I tried some fonts that support Chinese, all have the same problem
I found a solution to the problem that works for me.
启动服务时 强制指定编码
java -Dfile.encoding=utf-8 -jar
I have a PDF file and an AI file and I want it to convert SVG.
I have installed PHP IMAGICK extension in my localhost and also installed the GHOSTSCRIPT.
code which I have tried is
$image = new Imagick();
$image->setResolution(1000,1000);
$image->readImage('C:\xampp\htdocs\project\test.pdf');
$color = $image->getImageColors();
$image->setBackgroundColor(new ImagickPixel('transparent'));
$image->scaleImage(600, 270);
$image->setImageFormat("svg");
$image->writeImage('C:\xampp\htdocs\project\test_convert.svg');
Following error is coming:
Fatal error: Uncaught ImagickException: PDFDelegateFailed `The system cannot find the file specified. ' # error/pdf.c/ReadPDFImage/794 in C:\xampp\htdocs\Project\Test.php:4 Stack trace: #0 C:\xampp\htdocs\Project\Test.php(4): Imagick->readimage('C:\xampp\htdocs...') #1 {main} thrown in C:\xampp\htdocs\Project\Test.php on line 4
I'm using Xampp and it has installed Imagick x86 (32 bits), so installing Ghostscript for 32 bits and tried 64 bits and also renamed gswin64.exe to gs.exe
Can anyone help me out to solve this error?
try the following code
$file= fopen('anycloud.ai', 'rb'); // pu here your ai or eps file
$img = new imagick(); // [0] can be used to set page number
$img->setResolution(300,300);
$img->readImageFile($file);
$img->setImageFormat( "jpg");
$img->setImageCompression(imagick::COMPRESSION_JPEG);
$img->setImageCompressionQuality(90);
$img->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
$img->writeImage('convert_jpg_from_ai.jpg');
I am trying to set the font for a pdf document created in rMarkdown
---
title: "Intro"
date: "10/07/2020"
output:
pdf_document:
latex_engine: xelatex
mainfont: Arial
---
This doesn't work. I get the following error
tlmgr.pl: Local TeX Live (2019) is older than remote repository (2020).
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
See https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `unicode-math.sty' not found.
! Emergency stop.
<read *>
What am I doing wrong?
I have the following file uploader
class ItemImageUploader < CarrierWave::Uploader::Base
include ::CarrierWave::Backgrounder::Delay
include CarrierWave::MiniMagick
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
asset_path("fallback/" + [version_name, "image.png"].compact.join('_'))
end
def cache_dir
"uploads/tmp"
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [80,80]
end
def extension_white_list
%w(jpg jpeg gif png)
end
Picture class
class Picture < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
mount_uploader :image, ItemImageUploader
process_in_background :image
validates_presence_of :image
def copy
Picture.new(:image => self.image)
end
And the following config in carrier_wave.rb initialization file:
CarrierWave.configure do |config|
config.enable_processing = true
#config.permissions = 0666
#config.directory_permissions = 0777
config.storage = :file
end
Images uploaded properly, but no thumbnails created, no errors occurred. Please advise.
Just hit my head against this one myself. As the comments suggest, using carrierwave_backgrounder causes this problem. You can see it in their documentation:
process_in_background - This stores the original file with no processing/versioning.
Doesn't help with a solution, but I thought I'd verify the problem.
I struggled with this for a couple of hours today, because I had the same issue. Uploading of the original version would work, but it was not resized. It was working locally, but not on my production machine. Hope someone with the same issues stumbles on this answer and saves some time.
Turned out that my version of ImageMagick was not build with the correct delegates, this was the output of $ convert -version:
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-08-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): zlib
I used this answer to install the delegates and build a fresh version of ImageMagick: ImageMagick missing decode delegates
After that, pulled up the ImageMagick info with $ convert -version:
Version: ImageMagick 6.9.1-10 Q16 x86_64 2015-08-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): bzlib djvu fontconfig freetype gvc jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib
And now I'm rollin'!