Edit PDF file without loss of quality

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
vasiliy_b
Posts: 4
Joined: 2016-10-06T23:59:46-07:00
Authentication code: 1151

Edit PDF file without loss of quality

Post by vasiliy_b »

1.Convert PDF File to JPEG.

Code: Select all

convert t.pdf output.jpg
(and trying change density 300 or 100)
2.Overlay image

Code: Select all

composite -compose atop -geometry +0+0 file1.jpeg file2.jpeg file3.jpeg
(file2.jpeg very easy)
3.Collect the file back to PDF, the file increases in size, but the quality is much worse.

Code: Select all

convert *.jpg -adjoin file3.pdf
Tell me where is my mistake.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Edit PDF file without loss of quality

Post by dlemstra »

I have moved your topic since this does not look like paid consultancy.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Edit PDF file without loss of quality

Post by fmw42 »

Your pdf file is a vector file and has no size. It is controlled by setting the density before reading the pdf, which defaults to density 72. So the vector file is converted to a raster at low density. Going from vector to raster will definitely increase the file size. To get better quality, you should increase the density before reading the pdf and then if that is too big an image (WxH), then resize down by the same ratio of 72/density.

Code: Select all

convert -density 288 t.pdf -resize 25% output.jpg
Perhaps you should provide your input PDF file so we can test with it. You can upload to some place such as dropbox.com and put the URL here.

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images,

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
vasiliy_b
Posts: 4
Joined: 2016-10-06T23:59:46-07:00
Authentication code: 1151

Re: Edit PDF file without loss of quality

Post by vasiliy_b »

As far as I understand the pdf file, not a vector.

https://www.dropbox.com/sh/jq9xxha9olhh ... CtbMa?dl=0
The link you can see there is an example of a pdf file and the image that I'm trying to impose.
Version: ImageMagick 7.0.3-2 Q16 x64 2016-10-02 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
OS: Windows 7 x64
PS:
Sorry by my English is very simple
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Edit PDF file without loss of quality

Post by fmw42 »

You may have a raster image imbedded in a PDF vector shell. If that is the case, you have two options.

1) Remover the raster image from the PDF shell. See the section on extracting the image from the pdf (pdf to image) at http://www.imagemagick.org/Usage/formats/#ps

2) Try

Code: Select all

convert -density 288 t.pdf[0] -resize 25output.png
or

Code: Select all

convert -density 288 t.pdf[0] output2.png
Then copy the barcode from the result.
thisiszivko
Posts: 1
Joined: 2018-03-27T02:17:53-07:00
Authentication code: 1152

Re: Edit PDF file without loss of quality

Post by thisiszivko »

Maybe I missed something, does Adobe Acrobat not allow to do that?
Brandon Wheeler
Posts: 1
Joined: 2018-03-27T03:58:20-07:00
Authentication code: 1152

Re: Edit PDF file without loss of quality

Post by Brandon Wheeler »

I had some attempts to work with PDF files, and I must say that it is laborious and long work.

Not long ago I started using the online PDF file editor https://edit-pdf.pdffiller.com/ and now it takes only a couple of minutes to edit the document, you should try this tool and evaluate the benefits of using it as I did.

It worked. Well, the same procedure applies if part of the corresponding editing should be included a data file.
Post Reply