How can I combine pieces of pdf file using QPrinter and print on A4 paper? - qprinter

I want to combine 3 different pdf files with ECG wave forms and print on one A4 paper.
Any help?

I got the problem using pdftk and QProcess in Linux.
QProcess shellProc;
QString cpCommand;
QStringList cpArgs;
cpCommand="pdfunite";
cpArgs<<"/home/pmon/Desktop/spectrogramECGI.pdf";
cpArgs<<"/home/pmon/Desktop/spectrogramECGII.pdf";
cpArgs<<"/home/pmon/Desktop/spectrogramECGIII.pdf";
cpArgs<<"/home/pmon/Desktop/spectrogramOUTPUT.pdf"; //Combined Pdf
shellProc.start(cpCommand,cpArgs);
shellProc.waitForFinished();
link for pdftk

Related

How to save/export array as PDF in MATLAB

I have a large cell array which I want to export as report-like format. Is it possible to export arrays (strings and numbers) as a PDF file?
For example, say I have this cell array
data = {'Frank' 'Diana' '06-May-2018'}
and I want to export the this array content to a PDF file. In this case it should simply create a PDF file with the text:
Frank Diana 06-May-2018
The only way I know of for MATLAB to generate a PDF file is through a figure window. You can write text to a figure window, and print it to a PDF file:
fh = figure;
ah = axes('parent',fh,'position',[0,0,1,1],'visible','off',...
'xlim',[0,1],'ylim',[0,40],'ydir','reverse',...
'fontsize',14);
text(0.01,1,'text line 1','parent',ah);
text(0.01,2,'text line 2','parent',ah);
print(fh,'-dpdf','output.pdf')
The MATLAB File Exchange has a bunch of submissions that can help you print text to a figure window. Search for the tag "fprintf".
An alternative solution is to write the data to e.g. a Word document, or a Markdown or LaTeX file, and call appropriate programs from within MATLAB to convert those to PDF. The File Exchange has a submission to control Word. The pandoc or pdflatex external programs can be invoked through the ! or system functions.
Yes, easiest is use Matlab Notebook. Make it as pretty as you like.
Suggest to remove matlab-guide tag from your question, doesn't belong there.

Convert Impress ODP Presentation to several JPG images from command line

I would like to use openoffice or libreoffice to convert a presentation made with Impress ( odp file, but might be powerpoint ppt, too ) to jpg images.
My point is: I have an odp presentation file, composed with 10 slides, then I would receive 10 jpeg images, one for each slide.
I tried with :
soffice --headless --convert-to jpg presentation.odp
This works perfect, but I just receive the very first slide of my presentation, not all. I do need all of them.
I don't know if there's an option to tell soffice to convert all the slides instead of the first one.
I know there are other ways like converting to pdf and then use IM, but I want to solve this using soffice. Im doing everything under Ubuntu Linux.
Thanks in advance.
Juan
Im going to reply my own answer.
To convert, massively, from .odp to images, under Linux using CLI, I'll do:
soffice --headless --convert-to pdf presentation.odp
Then:
convert -density 400 converted.pdf -resize 800x600 my_filename%d.jpg
This solution works, but it needs some improvements to make it faster and to prevent it from failing due to lack of hardware resources.
But, if your odp is not that big, you converted from odp/ppt/pptx/whatever to images, massively, it is scriptable, and using just CLI.

perl, extract TOC from PDF file

I have checked through CAM::PDF and other PDF related modules, but can not figure if there a way to extract table of content from a clear PDF file.
If there any ideas I would be grateful!
I have not been able to find a library that supports the extraction of pdf bookmarks (which is what I assume you mean by table of contents) reliably.
However, pdftk does a great job at this and can be run from the command line;
pdftk myfile.pdf dump_data | grep BookmarkTitle > outline.txt

PDF output from MATLAB and inclusion in LaTeX

I'm printing some figures in MATLAB in PDF form, and can view them fine with the Evince PDF viewer on Fedora 16.
When I try to include them in LaTeX (TeXLive 2011), however, I get an error
!pdfTeX error: /usr/local/texlive/2011/bin/x86_64-linux/pdflatex (file ./caroti
d_amp_mod_log.pdf): xpdf: reading PDF image failed
However, I can take an example PDF image generated in Mathematica and include it just fine, which tells me that the problem is with the PDF's generated by MATLAB and not with PDF's in general.
Might it have something to do with the set(0,'defaultfigurepaperpositionmode','auto')I put in my startup.m file so that pages would auto-fit the images?
EDIT: I just tried using saveas(figure(1), 'filename.pdf') instead of print(figure(1), 'filename.pdf') and it worked fine, but the PaperPositionMode property is ignored. Any way around this?
Finally found the problem. The correct way to print images is to use the print(handle, '-dformat', 'filename') syntax.
So, for PDF's, we need print(figure(1), '-dpdf', 'myfigure'). See MATLAB documentation on graphics file formats for more information.
Using print(figure(1), 'filename.pdf') still produces a valid PDF for viewing, but it can't be included in LaTeX.
You can try using
pdfpages
or
pgf
to include pdf files. However, you need to use pdflatex only, as you are doing right now.

How can I merge PDF files with Perl?

Using Perl, how can I combine or merge the sample PDF files into a single PDF file?
CAM::PDF can do this quite easily, and has a simple command-line front end to help. Note: I'm the author of that library. Example:
appendpdf.pl file1.pdf file2.pdf outfile.pdf
From the SYNOPSIS section of the perldoc:
my $anotherpdf = CAM::PDF->new('test2.pdf');
$pdf->appendPDF($anotherpdf);
Why do you need to do it from Perl? Chris has already mentioned CAM::PDF.
If you just need to merge them, pdftk (PDF ToolKit) works just fine. It's a simple command line:
pdftk file1.pdf file2.pdf cat output merged.pdf
You can use the GhostScript utility pdf2ps to convert the PDFs into PostScript files, concatenate the PostScript files, and then use ps2pdf to convert the result back into a PDF.
Perlmonks has a fine discussion of this topic with, well, more than one way to do it.