Answers.Body: <p>As all pages are having the same or very similar width and height, this seems a "simple" problem of some pages having the wrong resolution. Most pages have metadata that specifies 600 DPI others only 96 DPI. That later are then of course displayed much larger.</p>
  
  <p>My Linux distribution comes with <code>djvutoxml</code> and the corresponding <code>djvuxmlparser</code> (from package <code>djuvlibre-bin</code>) which can extract the metadata, resp. merge the metadata back in. Those should be available for Windows as well (<a href="http://djvu.sourceforge.net/" rel="nofollow noreferrer">http://djvu.sourceforge.net/</a>, make sure the executables are in your PATH) That metadata includes the DPI information from the file. Actual changing of the XML is fast, but extracting and merging takes a long (several minutes) time.</p>
  
  <p>Make sure you have a copy of your book, in case the merging breaks something, and run <code>python program.py book.djvu</code> on this <code>program.py</code>:</p>
  
  <pre><code>import sys
  import subprocess
  
  book = sys.argv[1]
  xml_in = 'in.xml'
  xml_out = 'out.xml'
  
  print('extracting XML')
  subprocess.check_output(['djvutoxml', book, xml_in])
  
  print('converting XML')
  with open(xml_in) as inf:
      with open(xml_out, 'w') as outf:
          for line in inf:
              if line.startswith('&lt;PARAM name="DPI" value="96" /&gt;'):
                  line = line.replace('96', '600')
              outf.write(line)
  print('merging XML')
  subprocess.check_output(['djvuxmlparser', '-o', book, xml_out])
  
  print('done')
  </code></pre>
  
  <p>In general I am against parsing XML without a real parser, but you don't need regex or anything that easily breaks to get this information fixed. </p>
  
  <p>The intermediate XML (two files) has the same order of size as the DjVu file itself, although the XML has no image information, it is just inefficient. Make sure you have enough room (and run this program on a fast/local drive)</p>
  
  <p>There are 367 incorrect pages out of 1201, you might be able to speed up the process by only including the incorrect pages in the output XML, but then you should use an XML parser. If this is a one off conversion, I would not bother with such an optimisation.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T16:55:27.590Z
Answers.Text: I'm sorry. I do have python. I quite lost you from the "Those should be available for Windows as well (http://djvu.sourceforge.net/, make sure the executables are in your PATH)". Could you please give me a detailed explanation of steps on this, I do have python (2.7 & > 3.0). I would like to do this and probably make an app so that others can benefit too.
Answers.UserDisplayName: Rene Duchamp
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T17:59:50.760Z
Answers.Text: Sorry, but I seriously doubt that you can make an app out of this if you don't have the basic understanding of why it is necessary. Apart from that you would have to adhere to the copyrights of `djvuxmlparser` and `djvutoxml`. Contact me via email so I have a return email address and I can sent you a link to the converted document, which AFAICT is copyrighted as well.
Answers.UserDisplayName: Anthon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-19T05:06:59.143Z
Answers.LastActivityDate: 2017-07-19T05:06:59.143Z
Answers.UserDisplayName: Anthon
Answers.Body: <p>If you want to try to make all  your kindle reader there's other easy way around. try <a href="http://www.willus.com/k2pdfopt/" rel="nofollow noreferrer">K2pdfopt</a> it will help you resizing all pages to a specific screen size.  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T17:09:06.133Z
Answers.Text: I din't quite understand what you are trying to say. Are you saying you want to batch process the djvu file to kindle format so that it automatically has specific screen size all over it ?
Answers.UserDisplayName: Rene Duchamp
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T23:52:44.317Z
Answers.Text: @abhilashsukumari Yes that's the idea. Not just kindle format but to any other eBook reader format of choice. K2pdfopt supports many.
Answers.UserDisplayName: v_sukt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-21T08:14:31.210Z
Answers.LastActivityDate: 2017-07-21T08:14:31.210Z
Answers.UserDisplayName: v_sukt
Body: <p>I have a djvu book that has different sized pages.
  How can I solve this by making all pages to same size. I am familiar with Python programming and I'm ready to try it. Any advise is appreciated.</p>
  
  <p><a href="https://i.sstatic.net/KCMJe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KCMJe.png" alt="1"></a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-18T17:10:40.510Z
Comments.Text: Should the "smaller" pages be scaled, or just displayed on a larger canvas without scaling? Do you have an example file (of a few pages)? What platform do you work on (i.e. can you run the common DjVu tools available on linux)?
Comments.UserDisplayName: Anthon
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-18T22:19:02.333Z
Comments.Text: Yes I would like the smaller page to be scaled. https://drive.google.com/file/d/0Byj8JxXAeyj_OXU1WGk0QlNDcGc/view?usp=sharing
  I work on Windows 10 64 bit
Comments.UserDisplayName: Rene Duchamp
Tags: <djvu>
Title: Different size pages in DJVU book
UserDisplayName: Rene Duchamp
ThreadText: # Different size pages in DJVU book
  
  (Asked by: username_0 on 2017-07-18)
  
  I have a djvu book that has different sized pages.
  How can I solve this by making all pages to same size. I am familiar with Python programming and I'm ready to try it. Any advise is appreciated.
  
  [![1](https://i.sstatic.net/KCMJe.png)](https://i.sstatic.net/KCMJe.png)
  
  **Tags:** djvu
  
  > **Comments:**
  > **username_1**: Should the "smaller" pages be scaled, or just displayed on a larger canvas without scaling? Do you have an example file (of a few pages)? What platform do you work on (i.e. can you run the common DjVu tools available on linux)?  
  > **username_0**: Yes I would like the smaller page to be scaled. https://drive.google.com/file/d/0Byj8JxXAeyj_OXU1WGk0QlNDcGc/view?usp=sharing I work on Windows 10 64 bit  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-07-19. Score: 3 | Accepted answer
  
  As all pages are having the same or very similar width and height, this seems a "simple" problem of some pages having the wrong resolution. Most pages have metadata that specifies 600 DPI others only 96 DPI. That later are then of course displayed much larger.
  My Linux distribution comes with djvutoxml and the corresponding djvuxmlparser (from package djuvlibre-bin) which can extract the metadata, resp. merge the metadata back in. Those should be available for Windows as well (http://djvu.sourceforge.net/, make sure the executables are in your PATH) That metadata includes the DPI information from the file. Actual changing of the XML is fast, but extracting and merging takes a long (several minutes) time.
  Make sure you have a copy of your book, in case the merging breaks something, and run python program.py book.djvu on this program.py:
  import sys
  import subprocess
  
  book = sys.argv[1]
  xml_in = 'in.xml'
  xml_out = 'out.xml'
  
  print('extracting XML')
  subprocess.check_output(['djvutoxml', book, xml_in])
  
  print('converting XML')
  with open(xml_in) as inf:
      with open(xml_out, 'w') as outf:
          for line in inf:
              if line.startswith(''):
                  line = line.replace('96', '600')
              outf.write(line)
  print('merging XML')
  subprocess.check_output(['djvuxmlparser', '-o', book, xml_out])
  
  print('done')
  
  In general I am against parsing XML without a real parser, but you don't need regex or anything that easily breaks to get this information fixed. 
  The intermediate XML (two files) has the same order of size as the DjVu file itself, although the XML has no image information, it is just inefficient. Make sure you have enough room (and run this program on a fast/local drive)
  There are 367 incorrect pages out of 1201, you might be able to speed up the process by only including the incorrect pages in the output XML, but then you should use an XML parser. If this is a one off conversion, I would not bother with such an optimisation.
  
  > **Comments:**
  > **username_0**: I'm sorry. I do have python. I quite lost you from the "Those should be available for Windows as well (http://djvu.sourceforge.net/, make sure the executables are in your PATH)". Could you please give me a detailed explanation of steps on this, I do have python (2.7 & > 3.0). I would like to do this and probably make an app so that others can benefit too.  
  > **username_1**: Sorry, but I seriously doubt that you can make an app out of this if you don't have the basic understanding of why it is necessary. Apart from that you would have to adhere to the copyrights of `djvuxmlparser` and `djvutoxml`. Contact me via email so I have a return email address and I can sent you a link to the converted document, which AFAICT is copyrighted as well.  
  
  ---
  
  ### Answer by username_2 on 2017-07-21. Score: 0
  
  If you want to try to make all your kindle reader there's other easy way around. try [K2pdfopt](http://www.willus.com/k2pdfopt/) it will help you resizing all pages to a specific screen size.
  
  > **Comments:**
  > **username_0**: I din't quite understand what you are trying to say. Are you saying you want to batch process the djvu file to kindle format so that it automatically has specific screen size all over it ?  
  > **username_2**: @abhilashsukumari Yes that's the idea. Not just kindle format but to any other eBook reader format of choice. K2pdfopt supports many.  
  
  ---
  
  