Ideas to view and reorder PDFs

Hi.

I’m working in a place where PDF handling is commonplace. A lot of documentation comes back and forth and in a lot of places PDFs need either to be split (after visual review) or reordered (to comply with directives).

Coming from Mac this to me looks pretty simple to do. I’m used to Preview allowing for easy page-level management of PDFs. But here Windows is used and people jump through hoops to try and make their workflows more efficient (commonly, they just open the PDF and print to a new PDF individual pages when they want to split or reorder).

Looking around I’m surprised that I can’t find any easy PDF handler. There’re tons of PDF generation tools (which I don’t need), Conversion (same) and there’re a few that do what I want but, unexplainably, can’t display the PDFs themselves (which makes it weird to move pages around if you can’t see them).

I was looking for a way to dump the PDF contents into images I could display in a canvas and then save the reordered file and thought I could use perhaps xpdf and pdftk together, but thought to ask for advice here, in case there’re better ways to do it.

On Mac I could replicate a lot of Preview by calling cocoa classes but I’m ont familiar on how to do it in Windows. I know there’s a native PDF Reader in Windows and perhaps I can call that programmatically for getting page previews but I can’t find anything about it.

I don’t think there’s any native way to generate the new PDFs out of separate pages on the original, but then again there might (Office can “save as PDF”, for example).

Any ideas?

I’m not looking at generating PDFs but at moving PDF pages without modification to new files (either to split, combine or reorder).

Additional functionality (tagging, UX optimisation, etc.) would come later and should be easier.

MBS DynaPDF might be the easiest thing to do since, if you get the right license, you can read & write pdf’s with it

On Windows 10, you can use the Microsoft print to PDF feature to create PDF documents natively. Previous Windows releases don’t have this feature, so a PDF creator of some kind is required (many are available as you said).

This is not a Xojo based solution (reading your post, I was not certain this is a requirement): I believe that PDFSAM Enhanced (the not-free version) does what you want. It lets you edit PDF documents directly, move pages around, etc. The usual split and merge functionality of the free version is obviously also available. Some dislike PDFSAM because it is a Java program.

PDFTK has command line tools for both Windows and MAC to do what your asking for.

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

There is a new pdf plugin from

Einhugur

But I do not have tested the plugin so far.

iText is THE pdf engine. See http://itextpdf.com/itext7suite . Only for Java and .Net I think. And the pricing is enterprisey (meaning totally insane).

Thanks to all for the responses. No clear solution yet, but I’ll keep looking :slight_smile:

Yes, it’s one of the ones I checked, but it seemed to be so focused on PDF generation and so little in PDF display (even the demo videos show Preview opening the PDFs) that I assumed it was seriously overkill (I can understand its priorities and the problem it solves, but it looked to have different priorities than my needs).

Also, while it may have native display of PDFs I wanted to see if I could find a native way in Windows first, which is likely it would be faster.

I still have it there, as a last option, though :slight_smile:

[quote=269358:@Louis Desjardins]On Windows 10, you can use the Microsoft print to PDF feature to create PDF documents natively. Previous Windows releases don’t have this feature, so a PDF creator of some kind is required (many are available as you said).

This is not a Xojo based solution (reading your post, I was not certain this is a requirement): I believe that PDFSAM Enhanced (the not-free version) does what you want. It lets you edit PDF documents directly, move pages around, etc. The usual split and merge functionality of the free version is obviously also available. Some dislike PDFSAM because it is a Java program.[/quote]

Thanks. I want to have the functionality in a helper command-line program, natively through declares or in a library. No tool exists in Windows that does what I’m looking for in the way I’m looking for (I have fifteen of them installed by now, including PDFSAM). I have no problem trying to code it myself, but I’m looking for the backend tools to use as a basis.

Accessing Windows’s native PDF renderer and programmatically “printing” to PDF could work, if I could access those functions from within Xojo.

[quote=269359:@Stephen Koger]PDFTK has command line tools for both Windows and MAC to do what your asking for.

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ [/quote]

Yes. I mentioned PDFTK which covers some of the things and XPDF which covers some of the rest. Currently they’re my best bet but it seemed cumbersome to use one to generate the thumbnails, manipulate internally and then send to the other for processing.

[quote=269364:@Thomas Fangmeier]There is a new pdf plugin from

Einhugur

But I do not have tested the plugin so far.[/quote]

I wasn’t aware of this! I have an older version of Einhugur and was considering updating recently. From what I can see this is a plugin to create PDFs (if it’s for viewing them, it’s not obvious from the description). I’ll look further into it but it doesn’t seem to do what I want :frowning:

I saw this. It can do everything under the sun but is waaay out of the park from what I want to do. And, as mostly everything else, is geared mostly at PDF generation.

What I’m looking for is mostly a viewer (so I can show thumbnails) with basic page-level edition (which doesn’t usually require re-generation of the PDF). Seems to be an unusual need, since almost everything out there focuses on PDF creation.

Creating PDF’s is easier than opening loading & viewing them
You can generate a simple one using a subset of whats allowed in PDF (with something like libharu etc)
But opening one you need to support most anything since you have no idea what the input might be
This is one area where DynaPDF seems to have the edge on most other means

And I’m sure that IF you asked Christian he could whip up a “load & preview” of a PDF in no time and that would get you a long way down the road in terms of doing what you want.

As Norman indicates, DynaPDF is one option that definitely works well with Xojo. I believe that there is a product from Debenu that can also fulfill the requirement. I tested the free version of the QuickPDF library and it works well with Xojo (in DLL or in ActiveX version on Windows). They have other products with more capabilities, that I have not tested.

DynaPDF can import PDFs with Lite version.
The Pro version can do single page import and render pages for display.

The examples usually write PDF files and open them with folderitem.launch.
But there is also a nice PDFPreview example to show them in a window.

We have in our plugin also PDFKit and CoreGraphics classes to work on PDFs on Mac. But those built in PDF functions from OS X are limited in the PDF features they support. So not everything survives.

With DynaPDF we have more options including support for Windows and Linux (including Raspberry Pi)

I appreciate the insistence, but I probably haven’t made clear how little I actually need to deal with the PDF itself for my intentions, and how much overhead using DynaPDF would be for this.

I can see how complete DynaPDF is, and how useful it could be, but I whipped the basic functionality for this in Mac OS with native calls in an hour. I need to get image previews for the pages –but I don’t need to render them myself nor do I need the vector data– that will serve as shortcuts for the page numbers, so when the final files are built I can just address them by page.

On Mac I can use CGContextDrawPDFPage to get these thumbnails. On Windows I thought I could use Windows.Data.Pdf but I’ve never handled declares on the platform and I’m not confident at all.

I agree with this, but I don’t think it applies, as I don’t want to do either myself. I want to find the simplest way to get PDF thumbnails from a PDF, preferrably in a native library, and then the simplest way to build new PDFs from the pages of others, preferrably natively but I don’t mind if it’s through a CLI helper.

if you want to support older Windows versions or you want something cross platform, you should consider licensing DynaPDF Pro.
It’s a one time investment to get it added to your toolbox. And you can use it in all your projects.

[quote=269405:@Christian Schmitz]if you want to support older Windows versions or you want something cross platform, you should consider licensing DynaPDF Pro.
It’s a one time investment to get it added to your toolbox. And you can use it in all your projects.[/quote]

I’ve already acknowledged DynaPDF’s usefulness and how I won’t be using it for the time being. I believe it to be overkill for what I want to do (which means I would avoid using it even with a valid license) and I explicitly want to find alternate solutions.

Please, I don’t want to sound rude but it’s hard to find more ways to say “thank you, but no, thank you”. I understand how many of you consider this to be the best option and I respect that. There’s no need to keep at it.

I consider Norman close to the “voice of God” regarding Xojo and I already refused his recommendation to use it :slight_smile:

There’s a ton of possible situations I don’t plan to have where choosing DynaPDF today would cover, all of which I can cover with DynaPDF if the need ever arises. This is for an in-house tool for a very controlled environment.

[quote=269402:@Eduardo Gutierrez de Oliveira]On Windows I thought I could use Windows.Data.Pdf but I’ve never handled declares on the platform and I’m not confident at all.
[/quote]
I’d share your doubts about making this work

Dyna still seems to be “the best choice” but you dont want to use it

I wish you luck finding an alternate means

I truly believe it isn’t the best choice, but I blame this on my (poor) ability to explain what I need rather than DynaPDF’s capabilities. I hesitated to post this originally because as soon as “PDF” is mentioned DynaPDF comes up (partly because it’s usually the best tool, which in turn is partly because it’s so extensive) but since I had been able to do exactly what I need in Cocoa I raised this especifically in the Windows section trying to find something similar for this platform.

I’m convinced it should be possible but if I find it isn’t then I’ll happily admit defeat and go back to using something else.

There are also the software listed here : https://sourceforge.net/projects/jpdftweak/?source=directory

I have not tried any of them, but on the surface, jPDF Tweak, or PDF Split and Merge look like they could do.

You’re comparing apples and oranges. Windows pdf support is nowhere near what cocoa has.

Yes and no. I’m comparing only a specific function, which generates an image from a PDF page. The larger set of PDF functions are lightyears apart but this specific need is equivalent enough for my needs. I don’t need all the extra functionality. Generating the thumbnails from the PDF is all I need.

Sample app doing what I need for Visual Studio: https://code.msdn.microsoft.com/windowsapps/PDF-viewer-sample-85a4bb30

This is like the DynaPDF discussion: I know and understand all I wouldn’t be able to do, but I don’t mind because I don’t want to do it. It’s a very specific need (which I currently can cover with xpdf as a helper but should be faster using a built-in library if available).

[quote=269429:@Michel Bujardet]There are also the software listed here : https://sourceforge.net/projects/jpdftweak/?source=directory

I have not tried any of them, but on the surface, jPDF Tweak, or PDF Split and Merge look like they could do.[/quote]

Yes, I saw this before. There’re lots of tools for splitting/combining but very few for creating an image out of PDFs (understandably) so I’m not looking at built-in libraries. xpdf can do it but isn’t very fast, so I’m still looking.

It may still not get you there, but for the viewing you can perhaps use HTMLViewer with Webkit? Or pdf.js (also on the HTMLViewer). Still a two step process (since the viewer does not do the PDF re-pagination you are after), but it is a viewer option.